Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
647 views
in Technique[技术] by (71.8m points)

java - Upgrading Groovy 1.7 - 2.1 Incompatability

I am moving from Groovy 1.76 to groovy 2.1 and am having a problem running some Java code.

I have java 7 and Groovy 2.1 all setup on my classpath. Gradle is running and my project can run all its unit tests and execute successfully just as before.

However, I have one java class that loads up one of the groovy classes and executes it (the class can be executed normally in regular gradle/groovy unit tests) and when I try to run this in the new environment it fails with the following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/transform/powerassert/ValueRecorder
    at com.covestor.glossary.meta.Entity$_Rel__clinit__closure3_closure4.doCall(Entity.groovy:500)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I have seen in other questions/discussions that some classes were removed from Groovy 1.7, so the general advice seems to be to make sure the classes are re-built against a later version of groovy - but my classes are already being built against the later version (my script that kicks off the java code actually calls gradle clean build first to make sure all groovy classes are properly compiled). There are some jar dependencies as well, but none of them are built from Groovy source (all java jars).

Can anyone suggest what the problem might be? I can't see that I have any code anywhere that is still built against 1.7

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The ValueRecorder class is used internally to implement the power assert feature in Groovy. Unfortunately, these classes have been moved to another package from 1.7 to 1.8.

Your error means there is still some 1.7 compiled Groovy code. That's the reason for the NoClassDefFoundError.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...