Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

Gitlab java build fails even though eclipse and tomcat don't give me any error

I added this method to my java maven project

private Subquery<Date> latestEvent(final CriteriaQuery<?> query, final CriteriaBuilder cb, Root<Documento> superRoot){

        Subquery<Date> subquery = query.subquery(Date.class);
        Root<DocumentoEvent> documentoEvent = subquery.from(DocumentoEvent.class);
        subquery.select(cb.greatest(documentoEvent.get(DocumentoEvent_.BPM_TASK_END_TIME)));

        List<Predicate> predicateSubquery = new ArrayList<Predicate>();

        predicateSubquery.add(
                cb.and(
                        cb.isNotNull(documentoEvent.get(DocumentoEvent_.bpmTaskEndTime)),
                        cb.equal(
                                documentoEvent.get(DocumentoEvent_.DOCUMENTO).get(Documento_.ID),
                                superRoot.get(Documento_.ID))
                        )
                );

        subquery.where(predicateSubquery.toArray( new Predicate[predicateSubquery.size()]));

        return subquery;
    }

and when I pushed it to gitlab the build failed in less than a minute with following message:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project pnp-repositories: Compilation failure/builds/documentale-no-problem/dnp/pnp/pnp-repositories/src/main/java/it/[MASKED]/pnp/specifications/DocumentoSpecification.java:[2608,35] method greatest in interface javax.persistence.criteria.CriteriaBuilder cannot be applied to given types;

So apparently the third line of the method is what's causing the issue (namely cb.greatest()).

Before pushing I started the project on tomcat from inside eclipse with no error messages at all. I even debugged it and each line of the method was being executed with no exception or errors being thrown.

Now I know that eclipse will start and post to Tomcat even when the project has build problems (at least that's what has been happening to me), so I wanted to experiment and changed that same method to make it just uncompilable:

private Subquery<Date> latestEvent(final CriteriaQuery<?> query, final CriteriaBuilder cb, Root<Documento> superRoot){

        Subquery<Date> subquery = query.subquery(Date.class);
        Root<DocumentoEvent> documentoEvent = subquery.from(DocumentoEvent.class);
        subquery.select(cb.greatest(documentoEvent.get(DocumentoEvent_.BPM_TASK_END_TIME)));

        List<Predicate> predicateSubquery = new ArrayList<Predicate>();

sdjfhsduifgvsdiyufgvsdyufgs hfasd

        predicateSubquery.add(
                cb.and(
                        cb.isNotNull(documentoEvent.get(DocumentoEvent_.bpmTaskEndTime)),
                        cb.equal(
                                documentoEvent.get(DocumentoEvent_.DOCUMENTO).get(Documento_.ID),
                                superRoot.get(Documento_.ID))
                        )
                );

        subquery.where(predicateSubquery.toArray( new Predicate[predicateSubquery.size()]));

        return subquery;
    }

and as expected Tomcat was still starting with no error messages, but when execution reached that method I would get the following error:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.Error: Unresolved compilation problems: Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration Syntax error, insert ";" to complete LocalVariableDeclarationStatement rgkjxflkvj cannot be resolved

which means Tomcat was at least getting up-to-date sources and was able to detect errors.

So what's happening here? I'm assuming gitlab is not making up the error, and I can get behind Tomcat/Eclipse not detecting it (with Java Generics being involved and all) but then why am I able to execute each new line of code, even the one that's obviously causing the build error on gitlab?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...