NullPointerException near the annotations used in eclipse

765 views
Skip to first unread message

Bharat Akkinepalli

unread,
Sep 19, 2011, 9:48:57 AM9/19/11
to androidannotations
Hi,
First of all, Android annotation is an awesome project and I liked it
very much.

I am facing the below error when using the android-annotation in my
project. It was working fine till yesterday. But all of a sudden
when I clean & rebuild my eclipse project, I am facing this problem.
This leads to compilation issues in the project.

Version of android annotation : 2.1

Please let me know if you need more information in identifying the
problem. Thank you


Unexpected error. Please report an issue on AndroidAnnotations, with
the following content: 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:301)
at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:130)
at java.io.OutputStreamWriter.close(OutputStreamWriter.java:216)
at java.io.FilterWriter.close(FilterWriter.java:87)
at java.io.BufferedWriter.close(BufferedWriter.java:248)
at java.io.PrintWriter.close(PrintWriter.java:295)
at
com.googlecode.androidannotations.internal.codemodel.JFormatter.close(JFormatter.java:
137)
at
com.googlecode.androidannotations.internal.codemodel.JPackage.build(JPackage.java:
439)
at
com.googlecode.androidannotations.internal.codemodel.JCodeModel.build(JCodeModel.java:
311)
at
com.googlecode.androidannotations.generation.CodeModelGenerator.generate(CodeModelGenerator.java:
42)
at
com.googlecode.androidannotations.AndroidAnnotationProcessor.generateSources(AndroidAnnotationProcessor.java:
342)
at
com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:
232)
at
com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:
205)
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:
809)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:
428)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:
364)
at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:
321)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:
301)
at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:
134)
at
org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:
265)
at
org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:
193)
at org.eclipse.core.internal.events.BuildManager
$2.run(BuildManager.java:629)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:
172)
at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:
203)
at org.eclipse.core.internal.events.BuildManager
$1.run(BuildManager.java:255)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:
258)
at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:
311)
at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:
343)
at
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:
144)
at
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:
242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
SearchRideRequestActivity.java /CloudTasks-Android/src/carshare/app/
activity line 58 Annotation Problem (Java 6 processor)

Pierre-Yves Ricau

unread,
Sep 19, 2011, 10:14:25 AM9/19/11
to androidan...@googlegroups.com
Thank you for the feedback, we'll try to get it sorted together ;-) .

You said you were using AndroidAnnotations 2.1, could you please retry with 2.1.2 (latest release), just to be sure it doesn't solve the problem?

Then, could you tell us what version of Eclipse you are using, as well as what JDK, and what Android Plugin & SDK version ? It's not essential, but it should help reproduce the problem.

Next step (the most important) will be to communicate us the eclipse logs. Here is how to get them in Eclipse : Window > Show View > Error Log

There should be some AndroidAnnotations related error messages in there, if you could double click on the error log and then "Copy event details to clipboard" (button on the top right corner) and then paste it here ?

It would also be great if you gave us other AndroidAnnotations related logs (says stuff about the number of files generated, etc).

Maybe you could also try to "re import" the project, and stuff like cleaning it, or removing / adding annotation processing.. all the magical stuff that sometimes work.

Thanks for reporting the error !

2011/9/19 Bharat Akkinepalli <bharat.ak...@gmail.com>



--
Pierre-Yves Ricau


Akkinepalli Bharat

unread,
Sep 19, 2011, 1:05:57 PM9/19/11
to androidan...@googlegroups.com
Hi Pierre-Yves Ricau,
Thank you for the reply.
 
I have tried the same with 2.1.2 but still facing the same issue. 
 
Eclipse Version: Spring Source Tool Suite 2.5.1 release (Eclipse 3.6.1)
Android Plugin: v 12
Android SDK Version: 10
 
Error Log:
eclipse.buildId=2.5.1.201011111000-RELEASE
java.version=1.6.0_02
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os win32 -ws win32 -arch x86 -product com.springsource.sts.ide

Info
Mon Sep 19 18:56:54 IST 2011
Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerExceptionat 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:301)
at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:130)
at java.io.OutputStreamWriter.close(OutputStreamWriter.java:216)
at java.io.FilterWriter.close(FilterWriter.java:87)
at java.io.BufferedWriter.close(BufferedWriter.java:248)
at java.io.PrintWriter.close(PrintWriter.java:295)
at com.googlecode.androidannotations.internal.codemodel.JFormatter.close(JFormatter.java:137)
at com.googlecode.androidannotations.internal.codemodel.JPackage.build(JPackage.java:439)
at com.googlecode.androidannotations.internal.codemodel.JCodeModel.build(JCodeModel.java:311)
at com.googlecode.androidannotations.generation.CodeModelGenerator.generate(CodeModelGenerator.java:42)
at com.googlecode.androidannotations.AndroidAnnotationProcessor.generateSources(AndroidAnnotationProcessor.java:342)
at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:232)
at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:205)
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:809)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:178)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
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.build(JavaBuilder.java:173)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)

at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)

at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
 
 
 
Other Information:
===============
eclipse.buildId=2.5.1.201011111000-RELEASE
java.version=1.6.0_02
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os win32 -ws win32 -arch x86 -product com.springsource.sts.ide

Info
Mon Sep 19 18:56:54 IST 2011
Number of files generated by AndroidAnnotations: 1
eclipse.buildId=2.5.1.201011111000-RELEASE
java.version=1.6.0_02
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os win32 -ws win32 -arch x86 -product com.springsource.sts.ide

Info
Mon Sep 19 18:56:54 IST 2011
Dummy source file: file:///D:/Developer/STS/sts-2.5.1.RELEASE/workspace/TestAndAnnotation/.apt_generated/dummy1316438814210.java
eclipse.buildId=2.5.1.201011111000-RELEASE
java.version=1.6.0_02
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os win32 -ws win32 -arch x86 -product com.springsource.sts.ide

Info
Mon Sep 19 18:56:54 IST 2011
Starting AndroidAnnotations annotation processing

I have tried to create a new project and all together and I can see that the issue is reproduced in my environment. 
 
Please let me know if you need more information.
 
Regards,
Bharat Akkinepalli.
--
Regards,
Bharat Akkinepalli

An Intelligent person solves a problem, but a wise man avoids it.........

Pierre-Yves Ricau

unread,
Sep 19, 2011, 3:10:21 PM9/19/11
to androidan...@googlegroups.com
Thanks for the detailed answer !

I found this via Google : http://groups.google.com/group/gwt-platform/browse_thread/thread/785c0183d5a2e73f

It seems that someone had the same exception with another annotation processing framework. He didn't find any solution, it disappeared when he switched to Eclipse Helios. However, you are already using Helios so that won't fix anything.

If you create a new Android project, add AndroidAnnotations, and annotates the existing activity, does the error appear ? Or is it only with your current code ?

Also, is your project "private / secret", or is it a test project ? It would be great if you could share your project (if it's not private), so that we check if the problem reproduces on other environments.

Could you try this :

- uncheck "Project > Build automatically"
- do a "Project > Clean"
- do a "right click -> refresh" on the project
- recheck "Project > Build automatically"

If you still have the exception, could you also try this :

Go to properties => disable annotation processing => let eclipse do a build (there will probably be errors)
Then, once it has done at least one build without annotation processing, re enable it and let it do another build.


=> it seems that either "aboutToBuild" is not called before annotation processing, or "buildComplete" is called before annotation processing. In any case, that's a weird bug..

Another question : do you use Maven + Eclipse ? Or is it a simple Android / Eclipse project ?

Another hint if the rest doesn't work : could you try to refactor the name of the annotated activities ? Just to check if it changes anything (that's a bit of a guess)..

Thanks you for helping !!

2011/9/19 Akkinepalli Bharat <bharat.ak...@gmail.com>

Akkinepalli Bharat

unread,
Sep 20, 2011, 11:02:18 AM9/20/11
to androidan...@googlegroups.com

Hi I have downloaded a latest version of eclipse and installed ADT.  i have added android annotations and the problem disappeared. Not sure why my earlier version of eclipse behaved weirdly. Any way my problem is solved now.  thanks a lot for your time.  android annotation rocks!!!

Pierre-Yves Ricau

unread,
Sep 20, 2011, 12:25:04 PM9/20/11
to androidan...@googlegroups.com
Well that's great !!

Please let us know if you release any application that use AndroidAnnotations, and we will add it to the frontpage ;-) !

2011/9/20 Akkinepalli Bharat <bharat.ak...@gmail.com>

Akkinepalli Bharat

unread,
Sep 20, 2011, 9:30:44 PM9/20/11
to androidan...@googlegroups.com

Sure. Thank you

Ganaraj Tejasvi

unread,
Mar 18, 2014, 11:08:15 PM3/18/14
to androidan...@googlegroups.com
Hi,
Faced a similar issue with Annotation post processing, but this was during the static meta model generation. More details of the error stack has been provided on the link. The issue was resolved after doing a manual clean and Build.
!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)
Reply all
Reply to author
Forward
0 new messages