ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Murdoch <adammurd...@apache.org>
Subject Re: Classloader Problems
Date Mon, 08 Apr 2002 07:21:05 GMT
On Mon, 8 Apr 2002 16:22, Bernd wrote:
> I am not the original poster but I came across this also:
>
> ...build\build.xml:51: java.lang.IllegalAccessError:
>   class sun.reflect.GeneratedConstructorAccessor1 cannot access its
> superclass sun.reflect.ConstructorAccessorImpl
>     at
> org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:132)
>
> > The <java> task uses a specialised classloader, which basically ignores
> > everything from the system classloader that is not in the java.* or
> > javax.* packages.  That, of course, includes
> > sun.jdbc.odbc.JdbcOdbcDriver.
>

I should have noted that it only does this if you use the <java> task with an 
explicit classpath.  If you don't use a classpath, then it all works as 
expected.

> is this considered a bug or a feature?
> will it change likely change in future versions?
>

It's by design, I think, so in that respect it's not a bug.  Whether its a 
good feature, well, that's another question.  Perhaps it would be better if 
this 'isolate' mode was optional, and off by default.

As for it changing, I don't imagine there's much chance of that happening in 
Ant 1.x, except maybe to add an option to disable it (patches most welcome :)  
In Ant 2, hopefully, you'll have heaps more control over classloading.

> > You have a few options:
> >
> > * Use fork="true" with <java> task.
>
> this works for me
>
> > * Add the JVM's rt.jar to the classpath that you pass to the <java> task.
>
> this seems to not work for me:
>     <java classname="...">
>        ...
> 	<classpath  refid="myclasspath"/>
> 	<classpath>
>              ...
> 		<pathelement location="E:\Programme\JavaSoft\jdk\1.4.0\jre\lib\rt.jar"/>
> 	</classpath>
>     </java>
>

Actually, thinking about this some more, this was a dud suggestion.  As you've 
discovered.  Best to go with fork='true' if you have to use the sun.* 
classes.  Though, it's a better option to not use them at all, if you have 
the choice.

> can I check the classpath used in the java task?

Nope, unless you're using fork="true".

> Neither -v nor -debug seem to display this classpath?
>
> I also tried to set CLASSPATH from the commandline, but this did not work
> also.

In isolate mode, anything in the CLASSPATH is going to be ignored along with 
the sun.* classes.


-- 
Adam

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