Reputation: 3937
When generating QueryDSL's Q... classes with the apt-maven-plugin the maven build fails with a NullPointerException
in SimpleSerializerConfig
- but only for maven versions since 3.1.0.
We already tried debugging into the maven build but that did not lead to any conclusions.
The maven configuration looks like this:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
<logOnlyOnError>true</logOnlyOnError>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<classifier>apt</classifier>
<version>${querydsl.version}</version>
</dependency>
</dependencies>
</plugin>
with ${querydsl.version}
being 2.9.0 - using a newer version does not fix the problem.
The exact stacktrace is
java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.tools.javac.main.Main.compile(Main.java:469)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at com.mysema.maven.apt.AbstractProcessorMojo.execute(AbstractProcessorMojo.java:314)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
Caused by: java.lang.NullPointerException
at com.mysema.query.codegen.SimpleSerializerConfig.getConfig(SimpleSerializerConfig.java:29)
at com.mysema.query.apt.DefaultConfiguration.<init>(DefaultConfiguration.java:129)
at com.mysema.query.apt.jpa.JPAConfiguration.<init>(JPAConfiguration.java:69)
at com.mysema.query.apt.jpa.JPAAnnotationProcessor.createConfiguration(JPAAnnotationProcessor.java:46)
at com.mysema.query.apt.AbstractQuerydslProcessor.process(AbstractQuerydslProcessor.java:102)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
... 23 more
Upvotes: 3
Views: 3592
Reputation: 581
Just sharing my experience with a similar error but a different cause in case somebody else runs into this.
The same error appeared after adding an annotation from a test-scoped dependency to a class in src/main/java. Eclipse didn't complain because m2eclipse isn't very good at distinguishing compile and test scoped dependencies and just adds every dependency to the project classpath regardless of the scope.
To see the actual compilation error, I had to perform the following steps :
mvn compile
(without clean
to not delete the classes generated in step 1)Upvotes: 1
Reputation: 149
We ran into this, too. We noticed that the cause was related directly to annotations. We added an annotation to a class that Maven proper was able to resolve, but mysema was not. We explicitly added the compile dependency to the pom in question and everything worked out.
Upvotes: 0
Reputation: 22180
This exception usually happens when there is a dependency conflict in the build. Try disabling the apt execution and see if there are other issues in the build.
Upvotes: 4