[hibernate-issues] [Hibernate-JIRA] Commented: (HV-575) NPE in annotation processor ConstraintHelper.getName()

Daniel Ford (JIRA) noreply at atlassian.com
Thu Apr 12 09:11:48 EDT 2012


    [ https://hibernate.onjira.com/browse/HV-575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46257#comment-46257 ] 

Daniel Ford commented on HV-575:
--------------------------------

Yes, it works.  I added org.hibernate:hibernate-validator as a dependency of the end-test project and it now compiles without complaint.

I think having the AP silently stop processing would be best.  I expect most developers will have the AP configured for their entire project in one place and expect the AP to apply itself as appropriate.   I think a WARN log message would just add to the "noise" on the console; it would be there in every build, forever, and have no good way to suppress it other then adding an "unnecessary" dependency.  If there are annotations present to be processed, and the dependency is missing, however, then an informative ERROR that complains about the missing dependency might be the correct response.

> NPE in annotation processor ConstraintHelper.getName()
> ------------------------------------------------------
>
>                 Key: HV-575
>                 URL: https://hibernate.onjira.com/browse/HV-575
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: annotation-processor
>    Affects Versions: 4.3.0.Beta1
>         Environment: Java 1.6_31, Windows 7
>            Reporter: Daniel Ford
>            Assignee: Gunnar Morling
>         Attachments: HV575.zip
>
>
> First attempt to compile code base causes NPE from annotation processor.  I might be able to create a reproducible example if needed.
> Thanks!
> Dan
> [INFO] --- maven-processor-plugin:2.0.5:process (process) @ end-util-testing ---
> [INFO] Source directory: Z:\workspaces\endspring38\end-util-testing\target\generated-sources\apt added
> [INFO] No processors specified. Using default discovery mechanism.
> [INFO] javac option: -cp
> [INFO] javac option: z:\maven\repository\org\hibernate\hibernate-validator-annotation-processor\4.3.0.Beta1\hibernate-validator-annotation-processor-4.3.0.Beta1.jar;z:\maven\repository\org\sonatype\sisu\sisu-inject-bean\1.4.3.1\sisu-inject-bean-1.4.3.1.jar;z:\maven\repository\org\sonatype\sisu\sisu-guice\2.9.1\sisu-guice-2.9.1-noaop.jar;z:\maven\repository\org\sonatype\aether\aether-util\1.8\aether-util-1.8.jar;z:\maven\repository\org\codehaus\plexus\plexus-interpolation\1.14\plexus-interpolation-1.14.jar;z:\maven\repository\org\codehaus\plexus\plexus-utils\2.0.4\plexus-utils-2.0.4.jar;z:\maven\repository\org\codehaus\plexus\plexus-component-annotations\1.5.5\plexus-component-annotations-1.5.5.jar;z:\maven\repository\org\sonatype\plexus\plexus-sec-dispatcher\1.3\plexus-sec-dispatcher-1.3.jar;z:\maven\repository\org\sonatype\plexus\plexus-cipher\1.4\plexus-cipher-1.4.jar;Z:\workspaces\endspring38\end-util-testing\src\main\resources;Z:\workspaces\endspring38\end-util-testing\target\classes;z:\maven\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar;
> [INFO] javac option: -proc:only
> [INFO] javac option: -d
> [INFO] javac option: Z:\workspaces\endspring38\end-util-testing\target\classes
> [INFO] javac option: -s
> [INFO] javac option: Z:\workspaces\endspring38\end-util-testing\target\generated-sources\apt
> An annotation processor threw an uncaught exception.
> Consult the following stack trace for details.
> java.lang.NullPointerException
> 	at org.hibernate.validator.ap.util.ConstraintHelper.getName(ConstraintHelper.java:701)
> 	at org.hibernate.validator.ap.util.ConstraintHelper.getSupportedTypesForBuiltInConstraint(ConstraintHelper.java:508)
> 	at org.hibernate.validator.ap.util.ConstraintHelper.registerAllowedTypesForBuiltInConstraint(ConstraintHelper.java:668)
> 	at org.hibernate.validator.ap.util.ConstraintHelper.<init>(ConstraintHelper.java:140)
> 	at org.hibernate.validator.ap.ConstraintAnnotationVisitor.<init>(ConstraintAnnotationVisitor.java:64)
> 	at org.hibernate.validator.ap.ConstraintValidationProcessor.process(ConstraintValidationProcessor.java:104)
> 	at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
> 	at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556)
> 	at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701)
> 	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987)
> 	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
> 	at com.sun.tools.javac.main.Main.compile(Main.java:353)
> 	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
> 	at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:350)
> 	at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:197)
> 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
> 	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:319)
> 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
> 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
> 	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:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	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)
> [ERROR] error on execute: error during compilation

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list