Announcement Announcement Module
Collapse
No announcement yet.
GGTS 3.1 Groovy Logging Issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • GGTS 3.1 Groovy Logging Issue

    I have a compile error using a very basic example of groovy.util.logging

    Running this code as a Groovy Script:
    Code:
    import groovy.util.logging.*
    
    @Log4j("logger")
    class Car {
    	Car() {
    		logger.info 'Car constructed'
    	}
    }
    
    def c = new Car()
    gives the following compile error in GGTS 3.1 in Eclipse 3.8

    Code:
    General error during semantic analysis: null groovy.lang.GroovyRuntimeException: null at 
     org.codehaus.groovy.transform.LogASTTransformation
     $AbstractLoggingStrategy.classNode(LogASTTransformation.java:235) at groovy.util.logging.Log4j
     $Log4jLoggingStrategy.addLoggerFieldToClass(Log4j.java:70) at 
     org.codehaus.groovy.transform.LogASTTransformation$1.visitClass(LogASTTransformation.java:91) at 
     org.codehaus.groovy.transform.LogASTTransformation.visit(LogASTTransformation.java:136) at 
     org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:147) at 
     org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:220) at 
     org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1191) at 
     org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:623) at 
     org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:601) at 
     org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:578) at 
     org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompi
     lationUnitDeclaration.java:171) at 
     org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUni
     tDeclaration.java:1994) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:827) at 
     org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137) at 
     java.lang.Thread.run(Thread.java:722) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger at 
     java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:
     355) at java.security.AccessController.doPrivileged(Native Method) at 
     java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:
     423) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:648) at 
     groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:758) at 
     groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:746) at java.lang.Class.forName0(Native 
     Method) at java.lang.Class.forName(Class.java:264) at org.codehaus.groovy.transform.LogASTTransformation
     $AbstractLoggingStrategy.classNode(LogASTTransformation.java:233) ... 14 more
    The example in Groovy docs at: http://groovy.codehaus.org/Logging

    Code:
    import groovy.util.logging.*
    
    @Log("logger")
    class Car {
    	Car() {
    		logger.info 'Car constructed'
    	}
    }
    
    def c = new Car()
    does work but as soon as I try to use Log4j it fails to compile.

    log4j-1.2.17.jar is on the build path for this project and other groovy scripts in the same project which call log4j using java api work fine.

    Any help with what I am missing would be appreciated, many thanks.

    Peter

  • #2
    Please update to the latest groovy-eclipse using this update site:

    http://dist.springsource.org/release/GRECLIPSE/e4.2/

    Looks like you are hitting this bug:
    https://jira.codehaus.org/browse/GRECLIPSE-1503

    Trying this script myself and it is working for me, so it is likely already fixed.

    Comment


    • #3
      Andrew

      Thanks. I did try updating with http://dist.springsource.org/release/GRECLIPSE/e4.2/ but problem persisted. I have been trying all sorts of plugins and eclipse settings out so assumed as you had it working it was in some other setting I had. I started with a new install of eclipse 3.8 (without the GGTS this time) and it worked as expected. I haven't tried back in a clean GGTS 3.8 but assume it would work also.

      Thanks for your help.

      Peter

      Comment


      • #4
        Thanks for getting back to me on this. I can't explain this, but I'm glad it is working for you.

        Comment

        Working...
        X