Search the web
Sign In
New User? Sign Up
JSX-ideas · Ideas on Java Serialization for XML
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
setting classloader   Message List  
Reply | Forward Message #2162 of 2204 |
Hi, (forwarded to mailing list)

You can pass in a classloader as the second arg to ObjectReader (first arg can
be InputStream or Reader):
http://jsx.org/docs/JSX/ObjectReader.html#ObjectReader(java.io.InputStream,%20ja\
va.lang.ClassLoader)
http://jsx.org/docs/JSX/ObjectReader.html#ObjectReader(java.io.Reader,%20java.la\
ng.ClassLoader)

Or, you can use setContextClassLoader on the current thread:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#setContextClassLoa\
der
(java.lang.ClassLoader)
eg:
Thread.currentThread().setContextClassLoader(myCL);

There's some discussion in the mailing list archives:

http://tech.groups.yahoo.com/group/JSX-ideas/msearch?query=setcontextclassloader\
&submit=Search&charset=ISO-8859-1



cheers,
Brendan

> I have one problem I might be able to resolve by using the -D option of java
> to change the default system class loader...the problem is that Jtest when
> running unit tests uses its own class loader but because the sun class
> loader is the default it means JSX uses Sun's but Jtest uses its own which
> means the same class is loaded twice and I get a class cast exception when
> casting an object i read from an xml file and pass as input to a junit test
> case.
>
> Is there any way for me to tell JSX to use a particular class loader apart
> from the default class loader?




Sun Nov 26, 2006 8:24 pm

egroups_yow
Offline Offline
Send Email Send Email

Forward
Message #2162 of 2204 |
Expand Messages Author Sort by Date

Hi, (forwarded to mailing list) You can pass in a classloader as the second arg to ObjectReader (first arg can be InputStream or Reader): ...
Brendan
egroups_yow
Offline Send Email
Nov 26, 2006
8:55 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help