Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

Re: [groovy-user] Very simple script failing when run from jar

polinastya-groovy

2010-03-16

Replies: Find Java Web Hosting

Author LoginPost Reply
I do not get the NullPointerException from CallSiteClassLoader when I used groovy-all-1.5.5.jar, but this version of groovy causes an error in the scriptom library.  My classes load and run just fine when I run this from eclipse using groovy-all-1.7.0.jar.  When I move them out (regardless of whether I run them from a jar or by putting the .class files in the classpath) I get the NPE from CallSiteClassLoader.

I made sure that the order of the jars in my command line classpath matched that of the eclipse project.

groovy 1.5.5 is incompatible with scriptom 1.6.0 (and 1.5.4b11).  And groovy 1.7.0 does not even load a trivial Test class with hello world.  I am using the groovy-all-1.7.0.jar that came from the Groovy eclipse plug-in.

> Curious why do you put the Groovy jar in the bootclasspath? (and not
> just on the "normal" classpath)

I am loading my classes from a jar file. When I just use classpath rather than Xbootclasspath, I get the following error:
CLASSPATH=lib\scriptom-1.6.0.jar;lib\jacob-1.14.3.jar;lib\log4j.jar;lib\jtds-1.2.jar;lib\groovy-all-
1.5.5.jar;lib\commons-cli-1.2.jar;.
java -Xbootclasspath/a:lib\scriptom-1.6.0.jar;lib\jacob-1.14.3.jar;lib\log4j.jar;lib\jtds-1.2.jar;li
b\groovy-all-1.5.5.jar;lib\commons-cli-1.2.jar;. -jar lib\tal-dealbuilder.jar
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/Script
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Caused by: java.lang.ClassNotFoundException: groovy.lang.Script
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 12 more
Could not find the main class: Test. Program will exit.

 
"He that lives upon hope will die fasting.... He that falls in love with himself will have no rivals."
~~ Benjamin Franklin



From: Guillaume Laforge <glaforge@codehaus.org>
To: user@groovy.codehaus.org
Sent: Tue, March 16, 2010 12:39:21 PM
Subject: Re: [groovy-user] Very simple script failing when run from jar

Curious why do you put the Groovy jar in the bootclasspath? (and not
just on the "normal" classpath)

On Tue, Mar 16, 2010 at 17:28,  <polinastya-groovy@yahoo.com> wrote:
> I have a one line script in a file Test.java
>
> Test.java:
>   println "Hello world"
>
> It is packaged in a jar file with the following manifest:
>
> Manifest-Version: 1.0
> Ant-Version: Apache Ant 1.6.5
> Created-By: 1.5.0_09-b01 (Sun Microsystems Inc.)
> Main-Class: Test
> Build-Time: 2010/03/16 12:14
>
>
> I am getting the following error:
>
> java -Xbootclasspath/a:lib\groovy-all-1.7.0.jar; -jar
> lib\tal-dealbuilder.jar
> Exception in thread "main" java.lang.NullPointerException
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteClassLoader.loadClass(CallSiteClassLoader.java:45)
>         at java.lang.ClassLoader.loadClass(Unknown Source)
>         at
> org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.loadClass(ClassLoaderForClassArtifacts.java:43)
>         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>         at java.lang.ClassLoader.defineClass1(Native Method)
>         at java.lang.ClassLoader.defineClass(Unknown Source)
>         at
> org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.define(ClassLoaderForClassArtifacts.java:27)
>         at
> org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts$1.run(ClassLoaderForClassArtifacts.java:71)
>         at
> org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts$1.run(ClassLoaderForClassArtifacts.java:69)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.defineClassAndGetConstructor(ClassLoaderForClassArtifacts.java:69)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteGenerator.compileStaticMethod(CallSiteGenerator.java:239)
>         at
> org.codehaus.groovy.reflection.CachedMethod.createStaticMetaMethodSite(CachedMethod.java:268)
>         at
> org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.createStaticMetaMethodSite(StaticMetaMethodSite.java:111)
>         at
> groovy.lang.MetaClassImpl.createStaticSite(MetaClassImpl.java:2998)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:59)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:144)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:129)
>         at Test.main(Test.groovy)
>
> "He that lives upon hope will die fasting.... He that falls in love with
> himself will have no rivals."
> ~~ Benjamin Franklin
>
>



--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


©2008 gg3721.com - Jax Systems, LLC, U.S.A.