[groovy-user] Perplexing build problems - joint compiler + eclipse + ant

3 просмотра
Перейти к первому непрочитанному сообщению

David Watson

не прочитано,
8 мар. 2008 г., 16:39:4408.03.2008
– us...@groovy.codehaus.org
We've recently started using Groovy in a medium-large Java project at work
(900 files, 300KLOCs). For the most part, everything works pretty well,
and the joint compiler (running from ant) lets us call back and forth
between Groovy and Java, which is great. We're using the Groovy plugin for
Eclipse, most recent version from the update site.

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

не прочитано,
11 мар. 2008 г., 06:02:3811.03.2008
– us...@groovy.codehaus.org, eclipse-p...@groovy.codehaus.org
I'm adding the Eclipse plugin mailing-list in CC in case they have
some idea of what's going wrong here with the incremental compiler and
joint compiler.

--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com

David Watson

не прочитано,
20 мар. 2008 г., 15:02:1220.03.2008
– us...@groovy.codehaus.org
I now believe this is 100% an issue with the joint compiler. I haven't yet
been able to create a small testcase that causes this issue, but I have
now determined the following:

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. :(

David Watson

не прочитано,
20 мар. 2008 г., 16:33:0120.03.2008
– us...@groovy.codehaus.org
Oh, one thing I forgot to mention is that I *have* gotten this to happen
without using the Eclipse plugin (or Eclipse) at all, building only with
ant, so the Eclipse issue is a red herring.

Jochen Theodorou

не прочитано,
20 мар. 2008 г., 17:51:1520.03.2008
– us...@groovy.codehaus.org
David Watson schrieb:

> Oh, one thing I forgot to mention is that I *have* gotten this to happen
> without using the Eclipse plugin (or Eclipse) at all, building only with
> ant, so the Eclipse issue is a red herring.

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/

David Watson

не прочитано,
20 мар. 2008 г., 18:58:2620.03.2008
– us...@groovy.codehaus.org
I created an issue: GROOVY-2700.

I'm glad this issue is making some sense - I was about ready to tear my
hair out!

--

Dave Watson
Software Engineer
MIMvista Corp

---------------------------------------------------------------------

Marco Mornati

не прочитано,
21 мар. 2008 г., 10:42:5321.03.2008
– us...@groovy.codehaus.org
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)
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 Dillon

не прочитано,
21 мар. 2008 г., 12:38:0821.03.2008
– us...@groovy.codehaus.org
What is the source its trying to generate stubs for?

--jason

Marco Mornati

не прочитано,
21 мар. 2008 г., 13:13:1321.03.2008
– us...@groovy.codehaus.org
Bah... the reality is that we don't need to generate stubs because we
are directly working in groovy.
I "Solved" the problem but i think there's an error in maven-groovy-plugin.

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 Dillon

не прочитано,
1 апр. 2008 г., 05:04:5901.04.2008
– us...@groovy.codehaus.org
What was the source that caused this failure? It may be a bug, but
with out a test case its going to be hard to track down. If you have
the source which fails and can share it that would be very helpful.

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

Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений