Pages

Tuesday, 18 March 2014

SOLVED: NullPointerException thrown by Java Annotation Processing

The workspace i was using suddenly had errors related to the static meta model that are generated using the maven plugins during compile time. On checking further noticed that few of the meta model files were missing from the generated path. This looked strange as the same was working the previous day.
Tried the following without any luck:
1) Close my workspace and start it again.
2) Modify the File annotated with Entity so that the metamodel generates (This gave an error FileNotFound) in the .log file generated under the .metadata folder of the workspace.
3) A maven clean (which actaully removed all the generated srcs and new ones did not get generated).

Finally found a solution here. Just followed the steps to manually clean and build the project and voila everything went back to normal.

Error:

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2014-03-19 07:15:12.450
!MESSAGE Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final

!ENTRY org.eclipse.jdt.apt.pluggable.core 4 1 2014-03-19 07:15:12.490
!MESSAGE Exception thrown by Java annotation processor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor@6d2418
!STACK 0
java.lang.NullPointerException
 at org.eclipse.jdt.apt.core.internal.AptCompilationParticipant.addJava6GeneratedFile(AptCompilationParticipant.java:272)
 at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl.addNewUnit(IdeProcessingEnvImpl.java:132)
 at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeJavaSourceOutputStream.close(IdeJavaSourceOutputStream.java:72)
 at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:320)
 at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:149)
 at java.io.OutputStreamWriter.close(OutputStreamWriter.java:233)
 at java.io.BufferedWriter.close(BufferedWriter.java:266)
 at java.io.PrintWriter.close(PrintWriter.java:339)
 at org.hibernate.jpamodelgen.ClassWriter.writeFile(ClassWriter.java:80)
 at org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.createMetaModelClasses(JPAMetaModelEntityProcessor.java:155)
 at org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.process(JPAMetaModelEntityProcessor.java:145)
 at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
 at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
 at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
 at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:134)
 at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:820)
 at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:434)
 at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:366)
 at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:178)
 at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:303)
 at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:60)
 at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
 at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:270)
 at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
 at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
 at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
 at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
 at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
 at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
 at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
 at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
 at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
 at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
 at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
 at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Solution Steps:
1) Uncheck Build Automatically.
2) Clean all Projects
3) Refresh the Project
4) Check the Build Automatically setting Back.



No comments:

Post a Comment