Issue Details (XML | Word | Printable)

Key: GLASSFISH-18862
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: sandeep.shrivastava
Reporter: Sanjeeb Sahoo
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
glassfish

NPE in logging annotation processor when not doing clean build

Created: 03/Jul/12 08:01 AM   Updated: 18/Jan/13 10:29 PM   Resolved: 18/Jan/13 10:29 PM
Component/s: logging
Affects Version/s: 4.0_b43
Fix Version/s: 4.0_b71

Time Tracking:
Not Specified

Environment:

Linux/jdk1.6_31/maven 3


Tags:
Participants: michael.cico, naman_mehta, rajendra_inamdar, Romain Grécourt, sandeep.shrivastava and Sanjeeb Sahoo


 Description  « Hide

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]



naman_mehta added a comment - 03/Jul/12 09:27 AM

Assigning to Sandeep to look into this...


michael.cico added a comment - 07/Sep/12 02:08 PM

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".


rajendra_inamdar added a comment - 07/Sep/12 02:53 PM

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)


sandeep.shrivastava added a comment - 31/Oct/12 02:34 PM

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.


Romain Grécourt added a comment - 03/Dec/12 04:46 PM - 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>

sandeep.shrivastava added a comment - 18/Jan/13 10:29 PM

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.