querydsl / apt-maven-plugin

Maven APT plugin
Apache License 2.0
79 stars 41 forks source link

NullPointerException with Java 7.0.6 #4

Closed bennixview closed 12 years ago

bennixview commented 12 years ago

Hi,

when compiling my project with java 7.0.6 i had the following NullPointerException in mysema-apt-plugin. As an example project I have checked in the following : https://github.com/bennixview/apt-java7

[INFO] --- maven-apt-plugin:1.0.3:process (default) @ apt-java7 --- [ERROR] execute error 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:205) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 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:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 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:601) 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:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: java.lang.NullPointerException at com.mysema.query.codegen.SimpleSerializerConfig.getConfig(SimpleSerializerConfig.java:29) at com.mysema.query.apt.DefaultConfiguration.(DefaultConfiguration.java:129) at com.mysema.query.apt.jpa.JPAConfiguration.(JPAConfiguration.java:63) at com.mysema.query.apt.jpa.JPAAnnotationProcessor.createConfiguration(JPAAnnotationProcessor.java:45) at com.mysema.query.apt.AbstractQuerydslProcessor.process(AbstractQuerydslProcessor.java:94) 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 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.566s [INFO] Finished at: Tue Aug 28 20:59:57 CEST 2012 [INFO] Final Memory: 10M/150M

timowest commented 12 years ago

Could you try with Java 7.0.7? All the getElementsAnnotatedWith calls seem to fail.

bennixview commented 12 years ago

Same Exception

java -version java version "1.7.0_07" Java(TM) SE Runtime Environment (build 1.7.0_07-b10) Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

also with plugin version 1.0.4

timowest commented 12 years ago

This is caused by the following entry

<sourceDirectory>${project.basedir}</sourceDirectory>

Remote it, and your build will pass.

bennixview commented 12 years ago

THX

It works for my little example here : https://github.com/bennixview/apt-java7. But in my other project i've got the same exception after removeing the ${project.basedir} tag.

mvn help:effective-pom shows the same plugin configuration on both projects

I don't have any idea

timowest commented 12 years ago

Ok, I will make some further tests. Could you maybe try modifying the example project to be more similar to your real projects?

bennixview commented 12 years ago

Ok, I made another example as an multi-maven Module and a src/main/java Folder for Entities and a src-gen/main/java for the Base-Classes of the Entities. I added the

${project.basedir}

beacause the plugin does not find the Base - Classes in the src-gen Folder.

It is something with the

Tag. I need it to find the Base - Classes. You can find the Example here : https://github.com/bennixview/apt-java7-ext
timowest commented 12 years ago

The sourceDirectory needs to be directory where sources are directly placed in, not an ancestor directory. Do the builds fail without it? I haven't yet had the time to run them, but the parameter is misused, the default is src/main/java under the project.

bennixview commented 12 years ago

No, :
--- maven-apt-plugin:1.0.4:process (default) @ apt-java7-entity-impl --- ..........OtherThingImpl.java:8: error: cannot find symbol public class OtherThingImpl extends OtherThingBase { .... symbol: class OtherThingBase

timowest commented 12 years ago

Ok, the problem you had was related to having multiple source directories, I fixed that by reading the source directories directly from the injected Maven project.

The version 1.0.5 works, it will be in the central repositories in about 2 hours.

Also the artifactId changed from maven-apt-plugin to apt-maven-plugin, since maven-* artifact ids are now reserved for Maven's own plugins.

bennixview commented 12 years ago

Vielen Dank :-),

it works perfect!

timowest commented 12 years ago

Nichts zu danken ;)