ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bendfelt, Tim (MED, nVisia, GEMS-IT)" <Timothy.Bendf...@med.ge.com>
Subject RE: problems with ant and rmi
Date Fri, 22 Mar 2002 19:31:35 GMT

FWIW I've had a lot of similar problems when using rmi from a class
loaded by a custom classloader. The RMI subsystem is loaded by the
system classloader which does not have acces to classes visible only to
the custom loader. The solution is to set a context classloader on the
thread that invokes the rmi call:

ClassLoader currentClassLoader = this.getClass().getClassLoader();
Thread.currentThread().setContextClassLoader(currentClassLoader);

Thus the System classloader (rmi) can access the ant custom classloader
(serialized arguments) to load the specific classes on rmi
unmarshalling/deserializing.

--Tim



> -----Original Message-----
> From: Lawrence W. Leung [mailto:larryl@cory.EECS.Berkeley.EDU]
> Sent: Thursday, March 21, 2002 11:58 PM
> To: ant-user@jakarta.apache.org
> Subject: problems with ant and rmi
> 
> 
> hi,
> 
> I've been trying to get ant to run the RMI sample code 
> (computing PI from
> Javasoft) and I can make it work from command line but not ant.
> 
> Basically, if I type :
> java -cp . engine.ComputeEngine
> 
> it works and if I put together an ant script to do the same thing:
> <project name="Cl" default="xtest" basedir=".">
>    <target name="xtest" description="Runx tests">
>         <java classname="engine.ComputeEngine" classpath="." />
>   </target>
> </project>
> 
> it dies with this error:
> BUILD FAILED
> 
> C:\cygwin\home\Administrator\rmi\build.xml:8:
> java.lang.NoClassDefFoundError:
> sun/reflect/SerializationConstructorAccessorImpl
>         at
> org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.
> java:132)
>         at org.apache.tools.ant.taskdefs.Java.run(Java.java:305)
>         at 
> org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:127)
>         at org.apache.tools.ant.taskdefs.Java.execute(Java.java:88)
>         at org.apache.tools.ant.Task.perform(Task.java:217)
>         at org.apache.tools.ant.Target.execute(Target.java:184)
>         at org.apache.tools.ant.Target.performTasks(Target.java:202)
>         at 
> org.apache.tools.ant.Project.executeTarget(Project.java:601)
>         at 
> org.apache.tools.ant.Project.executeTargets(Project.java:560)
>         at org.apache.tools.ant.Main.runBuild(Main.java:454)
>         at org.apache.tools.ant.Main.start(Main.java:153)
>         at org.apache.tools.ant.Main.main(Main.java:176)
> --- Nested Exception ---
> java.lang.NoClassDefFoundError:
> sun/reflect/SerializationConstructorAccessorImpl
>         at sun.misc.Unsafe.defineClass(Native Method)
>         at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
>         at
> sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenera
> tor.java:381)
> 
> ...
> 
> Any ideas?  Is this a known bug in ant?
> Please also reply by email.
> 
> Thanks,
> --------------
> -Larry
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message