Results 1 to 4 of 4

Thread: GGTS 3.1 Groovy Logging Issue

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Posts
    4

    Default 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. #2
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    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.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

  3. #3
    Join Date
    Dec 2011
    Posts
    4

    Default

    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

  4. #4
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    Thanks for getting back to me on this. I can't explain this, but I'm glad it is working for you.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •