Repository navigation
AA 2.7 NPE ValidatorHelper.validateConverters(ValidatorHelper.java:1131) #398
Description
Activity
Seems like you have a configuration issue on your
@Restannotated class. Could you please copy & paste the content of your interface here ?EDIT : In fact, I think you forgot to add converters attribute in
@Restannotation. This one is mandatory since AA 2.7 :)
We should add a compilation error if this element is missing.Thanks! Yes it was a problem with an @rest annotated interface. In fact I was in the process of removing that code, but the lack of an explcit error message, made it hard to figure out what was wrong.
Could you provide an
@Restexample that reproduces this bug?@DayS the
providersoption is mandatory and therefore it won't compile without it (java feature) so we do not need to add any compilation error there. We should, however, stop processing an@Restannotated interface whenever there's an error on it.And what if the api and implementation doesn't match ?
convertersis mandatory since 2.7 only, isn't it ?That's definitely another problem. We already have an issue about that, we should compare the API and processor versions and stop any annotation processing if they don't match.
I'm not sure if I can recreate it exactly, because I wasn't making regular commits while the project wasn't compiling. But from what I can tell now, it was user error induced in part by a large amounts of error messages.
With AA 2.7, the error message "The annotation @rest must define the attribute converters" does appear correctly. It was just that it was buried among a ton of "XXXXX_ cannot be resolved" error messages, and that I was already unable to compile previously with AA 2.6. After upgrading to AA 2.7, the error message that did stand out was the "Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException...", but it doesn't give an easy way to identify what the problem is. Another factor that explains my mistake, is that the cause of the problem was in code that I had not changed, and that compiled previously without any errors.
In general I think it would be nice if, in such cases, AA could continue the code generation for the other classes, so that all the irrelevant "XXXXX_ cannot be resolved" error messages would not appear,
Below is one of the interfaces that was causing the error. There was also another one, just let me know if you want it too.
Thanks for creating AA, and for your great support!
package winesecretary.com; import java.util.Map; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import com.googlecode.androidannotations.annotations.rest.Accept; import com.googlecode.androidannotations.annotations.rest.Get; import com.googlecode.androidannotations.annotations.rest.Rest; import com.googlecode.androidannotations.api.rest.MediaType; //ROOT_URL @Rest( "http://services.wine.com/api/beta2/service.svc/json" ) public interface ApiWineCom { @SuppressWarnings ( "rawtypes") @Get( "/catalog?apikey=xxxxxxxxxxxxxxxxxx&search={query}" ) @Accept ( MediaType.APPLICATION_JSON ) Map getWines( String query ) throws RestClientException; @SuppressWarnings ( "rawtypes") @Get ( "/catalog?apikey=xxxxxxxxxxxxxxxxxxxxxxx&filter=product({id})") @Accept ( MediaType.APPLICATION_JSON ) Map getWine( String id ) throws RestClientException; RestTemplate getRestTemplate(); void setRestTemplate(RestTemplate restTemplate); }
Thanks Frank
Rest example from the androidannotations homepage currently reproduces this issue:
@Rest("http://www.bookmarks.com") public interface BookmarkClient { @Get("/bookmarks/{userId}?search={search}") Bookmarks getBookmarks(String search, String userId); }And the stacktrace is:
Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException at com.googlecode.androidannotations.helper.ValidatorHelper.validateConverters(ValidatorHelper.java: 1128) at com.googlecode.androidannotations.validation.rest.RestValidator.validate(RestValidator.java:63) at com.googlecode.androidannotations.validation.ModelValidator.validate(ModelValidator.java:56) at com.googlecode.androidannotations.AndroidAnnotationProcessor.validateAnnotations(AndroidAnnotatio nProcessor.java:414) at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationPr ocessor.java:364) at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.j ava:341) 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(Base AnnotationProcessorManager.java:159) at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(I deAnnotationProcessorManager.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:365) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:329) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:302) 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:726) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) 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)Thanks @isopov for the information, I updated the documentation.
After remving some unused code from my project, AA code generation started crashing with a NPE.
Things I have tried so far, but that have not solved the problem:
The only thing left that I can think of is to try upgrading to Eclipse 4.2 (currently I'm using 3.7).
Stack trace below