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

Gunnar Morling (JIRA) noreply at atlassian.com
Wed Apr 11 19:50:48 EDT 2012


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

Gunnar Morling commented on HV-575:
-----------------------------------

Ah, I think you're applying the annotation processor to a project which hasn't the Bean Validation API (validation-api-1.0.0.GA.jar) as dependency. Then the registration of supported types for built-in constraints ({{@Size}} etc.) fails (the AP hasn't the API itself as dependeny anymore due to HV-457).

I guess we could simply log a WARN message in this case and stop the AP from any further processing. Does the AP work when you add Hibernate Validator (and thus transitively the BV API) as project dependency?

> 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