glassfish
  1. glassfish
  2. GLASSFISH-18862

NPE in logging annotation processor when not doing clean build

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0_b43
    • Fix Version/s: 4.0_b71
    • Component/s: logging
    • Labels:
      None
    • Environment:

      Linux/jdk1.6_31/maven 3

      Description

      Running the following command on a module which was already built but only one file needed recompilation
      mvn -f appserver/common/glassfish-naming/pom.xml install

      resulted in build error decsribed at [1], but if I do clean install, then it succeeds. So, this is definitely a bug in the annotation processor.

      [INFO] Compiling 1 source file to /space/ss141213/WS/gf/trunk/appserver/common/glassfish-naming/target/classes
      error: org.glassfish.annotation.processing.logging.LogMessagesResourceBundleGenerator: Resource bundle name not specified for logger
      ...

      An annotation processor threw an uncaught exception.
      Consult the following stack trace for details.
      java.lang.NullPointerException
      at org.glassfish.annotation.processing.logging.LogMessagesResourceBundleGenerator.getRBFileObject(LogMessagesResourceBundleGenerator.java:246)
      at org.glassfish.annotation.processing.logging.LogMessagesResourceBundleGenerator.loadLogMessages(LogMessagesResourceBundleGenerator.java:186)
      at org.glassfish.annotation.processing.logging.LogMessagesResourceBundleGenerator.process(LogMessagesResourceBundleGenerator.java:149)
      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.main.Main.compile(Main.java:279)
      at com.sun.tools.javac.main.Main.compile(Main.java:270)
      at com.sun.tools.javac.Main.compile(Main.java:69)
      at com.sun.tools.apt.main.Main.compile(Main.java:1071)
      at com.sun.tools.apt.Main.processing(Main.java:95)
      at com.sun.tools.apt.Main.process(Main.java:85)
      at com.sun.enterprise.module.maven.HK2CompileMojo$1.compileInProcess(HK2CompileMojo.java:126)
      at com.sun.enterprise.module.maven.AptCompiler.compile(AptCompiler.java:106)
      at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:528)
      at com.sun.enterprise.module.maven.CompilerMojo.execute(CompilerMojo.java:155)
      at com.sun.enterprise.module.maven.HK2CompileMojo.execute(HK2CompileMojo.java:140)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      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:320)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      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)
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.glassfish.hk2:hk2-maven-plugin:2.0.4:hk2-compile (default-hk2-compile) on project glassfish-naming: Fatal error compiling: APT failed: 3 -> [Help 1]
      [ERROR]

        Activity

        Hide
        naman_mehta added a comment -

        Assigning to Sandeep to look into this...

        Show
        naman_mehta added a comment - Assigning to Sandeep to look into this...
        Hide
        michael.cico added a comment -

        I've run into what seems like a different manifestation of this. At times I will get errors like the following when running a "mvn install", which can usually be worked around by running a "mvn clean install":

        [INFO] ------------------------------------------------------------------------
        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.4:compile (default-compile) on project diagnostics-services: Compilation failure: Compilation failure:
        [ERROR] error: org.glassfish.annotation.processing.logging.LogMessagesResourceBundleGenerator: No resource bundle name found. Atleast one String literal constant needs to be decorated with the LogMessagesResourceBundle annotation.
        [ERROR] error: org.glassfish.annotation.processing.logging.LoggerInfoMetadataGenerator: Unable to generate LoggerMetadataInfoService class: null
        [ERROR] -> [Help 1]
        org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.4:compile (default-compile) on project diagnostics-services: Compilation failure

        The annotations are defined properly, and as mentioned this goes away with a "clean install".

        Show
        michael.cico added a comment - I've run into what seems like a different manifestation of this. At times I will get errors like the following when running a "mvn install", which can usually be worked around by running a "mvn clean install": [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.4:compile (default-compile) on project diagnostics-services: Compilation failure: Compilation failure: [ERROR] error: org.glassfish.annotation.processing.logging.LogMessagesResourceBundleGenerator: No resource bundle name found. Atleast one String literal constant needs to be decorated with the LogMessagesResourceBundle annotation. [ERROR] error: org.glassfish.annotation.processing.logging.LoggerInfoMetadataGenerator: Unable to generate LoggerMetadataInfoService class: null [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.4:compile (default-compile) on project diagnostics-services: Compilation failure The annotations are defined properly, and as mentioned this goes away with a "clean install".
        Hide
        rajendra_inamdar added a comment -

        This am able to reproduce this by touching a source file and running mvn install, which resulted in the following (with a change to annotation processor to print stacktrace):

        java.lang.UnsupportedOperationException
        at com.sun.tools.javac.util.DefaultFileManager$RegularFileObject.openReader(DefaultFileManager.java:1299)
        at javax.tools.ForwardingFileObject.openReader(ForwardingFileObject.java:74)
        at org.glassfish.annotation.processing.logging.BaseLoggingProcessor.loadLogMessages(BaseLoggingProcessor.java:103)
        at org.glassfish.annotation.processing.logging.LoggerInfoMetadataGenerator.generateLoggerInfoMetadataService(LoggerInfoMetadataGenerator.java:171)
        at org.glassfish.annotation.processing.logging.LoggerInfoMetadataGenerator.process(LoggerInfoMetadataGenerator.java:131)
        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.main.Main.compile(Main.java:279)
        at com.sun.tools.javac.main.Main.compile(Main.java:270)
        at com.sun.tools.javac.Main.compile(Main.java:87)
        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.compiler.javac.JavacCompiler.compileInProcess0(JavacCompiler.java:554)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:530)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:165)
        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:627)
        at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        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:537)
        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)

        Show
        rajendra_inamdar added a comment - This am able to reproduce this by touching a source file and running mvn install, which resulted in the following (with a change to annotation processor to print stacktrace): java.lang.UnsupportedOperationException at com.sun.tools.javac.util.DefaultFileManager$RegularFileObject.openReader(DefaultFileManager.java:1299) at javax.tools.ForwardingFileObject.openReader(ForwardingFileObject.java:74) at org.glassfish.annotation.processing.logging.BaseLoggingProcessor.loadLogMessages(BaseLoggingProcessor.java:103) at org.glassfish.annotation.processing.logging.LoggerInfoMetadataGenerator.generateLoggerInfoMetadataService(LoggerInfoMetadataGenerator.java:171) at org.glassfish.annotation.processing.logging.LoggerInfoMetadataGenerator.process(LoggerInfoMetadataGenerator.java:131) 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.main.Main.compile(Main.java:279) at com.sun.tools.javac.main.Main.compile(Main.java:270) at com.sun.tools.javac.Main.compile(Main.java:87) 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.compiler.javac.JavacCompiler.compileInProcess0(JavacCompiler.java:554) at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:530) at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:165) at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:627) at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 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:537) 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)
        Hide
        sandeep.shrivastava added a comment -

        Committed revision 56815 for the logging-annotation-processor which emits a warning message instead of an error when either the LogMessages resource bundle name or set of LogMessageInfo annotations is empty. This should be available when the GlassFish build is revved to 1.3 version of this module.

        Show
        sandeep.shrivastava added a comment - Committed revision 56815 for the logging-annotation-processor which emits a warning message instead of an error when either the LogMessages resource bundle name or set of LogMessageInfo annotations is empty. This should be available when the GlassFish build is revved to 1.3 version of this module.
        Hide
        Romain Grécourt added a comment - - edited

        Seems like the preprocessor limits the glassfish build.
        It could instead be implemented as a maven plugin, and instrospect the compiled classes under $

        {project.build.outputDirectory}

        .

        Since the plugin will likely run against all modules, it could be convenient to provide a way to skip the execution.
        the plugin configuration will define something like:

        <configuration>
            <skip>${loggingPlugin.skip}</skip>
        </configuration>
        

        A module that wants to skip the execution of the logging plugin could do the following:

        <properties>
           <loggingPlugin.skip>true</loggingPlugin.skip>
        </properties>
        
        Show
        Romain Grécourt added a comment - - edited Seems like the preprocessor limits the glassfish build. It could instead be implemented as a maven plugin, and instrospect the compiled classes under $ {project.build.outputDirectory} . Since the plugin will likely run against all modules, it could be convenient to provide a way to skip the execution. the plugin configuration will define something like: <configuration> <skip>${loggingPlugin.skip}</skip> </configuration> A module that wants to skip the execution of the logging plugin could do the following: <properties> <loggingPlugin.skip>true</loggingPlugin.skip> </properties>
        Hide
        sandeep.shrivastava added a comment -

        Committed revision 58655. Revved the logging-annotation-processor module to version 1.3 which includes the fix to support incremental build. The build output contains a META-INF/logmessages/LogMessagesMetadata.properties file which includes the name of the package for the LogMessages.properties resource for the module that is used when not building from scratch.

        Show
        sandeep.shrivastava added a comment - Committed revision 58655. Revved the logging-annotation-processor module to version 1.3 which includes the fix to support incremental build. The build output contains a META-INF/logmessages/LogMessagesMetadata.properties file which includes the name of the package for the LogMessages.properties resource for the module that is used when not building from scratch.

          People

          • Assignee:
            sandeep.shrivastava
            Reporter:
            Sanjeeb Sahoo
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: