However, every so often (several times a day, and for a few developers,
just about every time they build), the joint compiler, running from the
ant build, complains that it can't find some class, even though it
obviously exists, since it is both in the source tree being compiled, as
well as already in a .class file that is in the already-built source.
This only occurs when doing an incremental compile, and possibly only when
done from Eclipse. Things are set up as follows:
3 Builders:
1) Ant builder. This runs the joint compiler, and outputs to build/classes
2) Groovy builder. Outputs to build/groovy-classes
3) Java builder. Output to build/classes
Most of the time when building incrementally, and 100% of the time when
building after a clean, everything goes smoothly. However, once it starts
complaining, the only way to fix it is to do a clean. I can run ant 100
times from the commandline once this starts, and it will never fix itself.
Here's what the error looks like:
compile:
[groovyc] Compiling 6 source files to /workspace/myproject/build/classes
[groovyc] /workspace/myproject/com/myproject/internals/SomeClass.groovy
[groovyc] /workspace/myproject/com/myproject/internals/SomeOtherClass.groovy
[groovyc] /workspace/myproject/com/myproject/internals/YetAnotherClass.groovy
[groovyc] /workspace/myproject/com/myproject/mode/FooClass.groovy
[groovyc] /workspace/myproject/com/myproject/mode/DonkeyClass.groovy
[groovyc] /workspace/myproject/com/myproject/mode/BarClass.groovy
[groovyc] Exception in thread "main" java.lang.NoClassDefFoundError: com/myproject/mode/FooClass
[groovyc] at java.lang.Class.getDeclaredFields0(Native Method)
[groovyc] at java.lang.Class.privateGetDeclaredFields(Class.java:2259)
[groovyc] at java.lang.Class.getDeclaredFields(Class.java:1715)
[groovyc] at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:213)
[groovyc] at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:766)
[groovyc] at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:760)
[groovyc] at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:754)
[groovyc] at org.codehaus.groovy.control.CompilationUnit.sortClasses(CompilationUnit.java:480)
[groovyc] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:453)
[groovyc] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:417)
[groovyc] at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:685)
[groovyc] at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:541)
[groovyc] at org.codehaus.groovy.ant.Groovyc.main(Groovyc.java:841)
I'm running groovy 1.5.4, if that matters.
Has anybody else seen this type of thing? What's the recommended setup for
using Groovy with the joint compiler in Eclipse? If I don't have the ant
task, I get all kinds of errors when building initially, because that Java
builder can't find Groovy classes and vice-versa. However, starting out
with the ant build works reasonably well, except for this maddening
problem.
Is the plugin just not ready for prime time? When it's not breaking, it
works great, but I guess at this point the groovy builder doesn't use the
joint compiler.
--
Dave Watson
Software Engineer
MIMvista Corp
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
When the joint compiler encounters an error in java code that causes the
build to stop, *sometimes*, depending on what file it is, it will cause
this problem, and the joint compiler will complain about an unrelated
Groovy class. I think it has something to do with the order that things
are compiled, and somehow when the joint compiler is looking at the
dependecies, it somehow "forgets" about the existence of certain classes.
Please help! I really want to be able to use Groovy, but if I don't find a
soluation for this soon, I'm going to have to rewrite these classes in
Java. :(
for joint compilation to work correctly it is essential that you give
all the files you want to compile, all java and all groovy files. The
compiler is basically able to pick up files you forgot in certain cases,
but groovyc will then not create a stub for javac for this file.
If you get a java.lang.NoClassDefFoundError then this means your class
references a class, that is found, but that class references a class
that is not found.. for example as field type or as super class.
from the trace
>> > [groovyc] Compiling 6 source files to /workspace/myproject/build/classes
>> > [groovyc] /workspace/myproject/com/myproject/internals/SomeClass.groovy
>> > [groovyc] /workspace/myproject/com/myproject/internals/SomeOtherClass.groovy
>> > [groovyc] /workspace/myproject/com/myproject/internals/YetAnotherClass.groovy
>> > [groovyc] /workspace/myproject/com/myproject/mode/FooClass.groovy
>> > [groovyc] /workspace/myproject/com/myproject/mode/DonkeyClass.groovy
>> > [groovyc] /workspace/myproject/com/myproject/mode/BarClass.groovy
>> > [groovyc] Exception in thread "main" java.lang.NoClassDefFoundError: com/myproject/mode/FooClass
>> > [groovyc] at java.lang.Class.getDeclaredFields0(Native Method)
>> > [groovyc] at java.lang.Class.privateGetDeclaredFields(Class.java:2259)
>> > [groovyc] at java.lang.Class.getDeclaredFields(Class.java:1715)
>> > [groovyc] at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:213)
>> > [groovyc] at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:766)
>> > [groovyc] at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:760)
>> > [groovyc] at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:754)
>> > [groovyc] at org.codehaus.groovy.control.CompilationUnit.sortClasses(CompilationUnit.java:480)
>> > [groovyc] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:453)
>> > [groovyc] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:417)
>> > [groovyc] at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:685)
>> > [groovyc] at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:541)
>> > [groovyc] at org.codehaus.groovy.ant.Groovyc.main(Groovyc.java:841)
the groovyc compiler assumes, that if you have foo1 extends foo2, foo2
extends foo3, that if foo2 is a java class, that foo3 will be one too.
So I guess you have this construction here too, where FooClass is a
foo3. but I also think there is a solution to this...
ClassNode.lazyClassInit needs to use the class cache in CompilationUnit
to set the parent class. That would ensure that foo3 is used correctly,
which means as something Groovy compiles and not as an existing class file.
If you fill an issue for this we should be able to fix that soon
bye blackdrag
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/
I'm glad this issue is making some sense - I was about ready to tear my
hair out!
--
Dave Watson
Software Engineer
MIMvista Corp
---------------------------------------------------------------------
I'm writing a project in groovy with maven for compilation and building
process.
By now (and I don't know why) when I try to compile (just simple with a
mvn compile) I've this error reported:
[INFO] [groovy:generateStubs]
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Unknown AST: VARIABLE_DEF
[INFO]
------------------------------------------------------------------------
[INFO] Trace
java.lang.Error: Unknown AST: VARIABLE_DEF
at
org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.unknownAST(QDoxStubTranslator.java:1005)
at
org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.process(QDoxStubTranslator.java:299)
at
org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.parse(QDoxStubTranslator.java:233)
at
org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.translate(QDoxStubTranslator.java:101)
at
org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.write(QDoxStubTranslator.java:112)
at
org.codehaus.mojo.groovy.runtime.v11.StubCompilerFeature$StubCompilerImpl.compile(StubCompilerFeature.java:77)
at
org.codehaus.mojo.groovy.stubgen.AbstractGenerateStubsMojo.compile(AbstractGenerateStubsMojo.java:97)
at
org.codehaus.mojo.groovy.stubgen.AbstractGenerateStubsMojo.process(AbstractGenerateStubsMojo.java:68)
at
org.codehaus.mojo.groovy.ComponentMojoSupport.doExecute(ComponentMojoSupport.java:68)
at org.codehaus.mojo.groovy.MojoSupport.execute(MojoSupport.java:71)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
I don't really know where the problem could be.
Do you have any idea?
Thanks a lot
Marco
--
Dott. Ing. Mornati Marco
Byte-Code s.r.l
via Antonio Cechov, 1
San Giuliano Milanese (MI)
E-Mail: mmor...@byte-code.com
--jason
I simply delete the new added class in my project... try to recompile
with maven and i seen that when it arrived in stubs-generation step
there were others dependencies file to download.
[INFO] Generated 4 Java stubs
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-manager/1.5.3/plexus-compiler-manager-1.5.3.pom
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler/1.5.3/plexus-compiler-1.5.3.pom
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-api/1.5.3/plexus-compiler-api-1.5.3.pom
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-javac/1.5.3/plexus-compiler-javac-1.5.3.pom
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compilers/1.5.3/plexus-compilers-1.5.3.pom
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.0.5/plexus-utils-1.0.5.pom
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-manager/1.5.3/plexus-compiler-manager-1.5.3.jar
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-api/1.5.3/plexus-compiler-api-1.5.3.jar
Downloading:
http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-javac/1.5.3/plexus-compiler-javac-1.5.3.jar
After this I re-added file to the project and the compilation works
correctly!!
So I think it does not have all needed library.
I think (but I'm not shure right now, I'll try to check later what I
suppose) that the problem could be in XmlRPC class (the only thing taht
was added to the killer-file).
See ya
Marco
Jason Dillon wrote:
> What is the source its trying to generate stubs for?
>
> --jason
>
>
> On Mar 21, 2008, at 9:42 PM, Marco Mornati wrote:
>
>> Hi all,
>>
>> I'm writing a project in groovy with maven for compilation and
>> building process.
>> By now (and I don't know why) when I try to compile (just simple with
>> a mvn compile) I've this error reported:
>>
>> [INFO] [groovy:generateStubs]
>> [INFO]
>> ------------------------------------------------------------------------
>> [ERROR] FATAL ERROR
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Unknown AST: VARIABLE_DEF
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Trace
>> java.lang.Error: Unknown AST: VARIABLE_DEF
>> at
>> org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.unknownAST(QDoxStubTranslator.java:1005)
>>
>> at
>> org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.process(QDoxStubTranslator.java:299)
>>
>> at
>> org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.parse(QDoxStubTranslator.java:233)
>>
>> at
>> org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.translate(QDoxStubTranslator.java:101)
>>
>> at
>> org.codehaus.mojo.groovy.runtime.v11.QDoxStubTranslator.write(QDoxStubTranslator.java:112)
>>
>> at
>> org.codehaus.mojo.groovy.runtime.v11.StubCompilerFeature$StubCompilerImpl.compile(StubCompilerFeature.java:77)
>>
>> at
>> org.codehaus.mojo.groovy.stubgen.AbstractGenerateStubsMojo.compile(AbstractGenerateStubsMojo.java:97)
>>
>> at
>> org.codehaus.mojo.groovy.stubgen.AbstractGenerateStubsMojo.process(AbstractGenerateStubsMojo.java:68)
>>
>> at
>> org.codehaus.mojo.groovy.ComponentMojoSupport.doExecute(ComponentMojoSupport.java:68)
>>
>> at
>> org.codehaus.mojo.groovy.MojoSupport.execute(MojoSupport.java:71)
>> at
>> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
>>
>> at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
>>
>> at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
>>
>> at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
>>
>> at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
>>
>> at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
>>
>> at
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
>>
>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
--jason
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .runtime.v11.QDoxStubTranslator.unknownAST(QDoxStubTranslator.java:
>>> 1005)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .runtime.v11.QDoxStubTranslator.process(QDoxStubTranslator.java:299)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .runtime.v11.QDoxStubTranslator.parse(QDoxStubTranslator.java:233)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .runtime.v11.QDoxStubTranslator.translate(QDoxStubTranslator.java:
>>> 101)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .runtime.v11.QDoxStubTranslator.write(QDoxStubTranslator.java:112)
>>> at org.codehaus.mojo.groovy.runtime.v11.StubCompilerFeature
>>> $StubCompilerImpl.compile(StubCompilerFeature.java:77)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .stubgen
>>> .AbstractGenerateStubsMojo.compile(AbstractGenerateStubsMojo.java:
>>> 97)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy
>>> .stubgen
>>> .AbstractGenerateStubsMojo.process(AbstractGenerateStubsMojo.java:
>>> 68)
>>> at
>>> org
>>> .codehaus
>>> .mojo
>>> .groovy.ComponentMojoSupport.doExecute(ComponentMojoSupport.java:68)
>>> at
>>> org.codehaus.mojo.groovy.MojoSupport.execute(MojoSupport.java:71)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:
>>> 447)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .lifecycle
>>> .DefaultLifecycleExecutor
>>> .executeGoals(DefaultLifecycleExecutor.java:539)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .lifecycle
>>> .DefaultLifecycleExecutor
>>> .executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .lifecycle
>>> .DefaultLifecycleExecutor
>>> .executeGoal(DefaultLifecycleExecutor.java:459)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .lifecycle
>>> .DefaultLifecycleExecutor
>>> .executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .lifecycle
>>> .DefaultLifecycleExecutor
>>> .executeTaskSegments(DefaultLifecycleExecutor.java:278)
>>> at
>>> org
>>> .apache
>>> .maven
>>> .lifecycle
>>> .DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
>>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
>>> 333)
>>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
>>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun
>>> .reflect
>>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>> at
>>> sun
>>> .reflect
>>> .DelegatingMethodAccessorImpl