jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Bukanov" <i...@mir2.org>
Subject Re: Strange Classpath issue.
Date Sat, 31 May 2003 11:20:47 GMT
Do you call in your IDE Thread.setContextClassLoader()? When Rhino 1.5R3
needs to load generated Java classes, it uses a special classloader that
points to Thread.getContextClassLoader() as its parent with hope that it
will find find Rhino classes somehow. The default result
Thread.getContextClassLoader() gives loader that can load classes from
CLASSPATH and lib/ext, but some JVMs may have problems with that.

Now if you do not call Thread.setContextClassLoader(), then I believe if
you wrap calls to execute scripts into something like

ClassLoader old = Thread.getContextClassLoader();
Thread.setContextClassLoader(Loader that knows about directory with
try {
    call script execution
} finally {
Thread.setContextClassLoader(Loader that knows about directory with

On Sat, 31 May 2003 10:46:24 +0530, "Jiger Patel" <jiger_ptl@hotmail.com>
> Hi Igor,
> >
> >Did you install JavaScript js.jar into lib/ext dir in the jdk
> >distribution? If so, you should add it to your classpath as well.
> Well I have not put any js.jar in the lib/ext. Actually I am writting
> this 
> plugin for an Open source IDE that provides scripting support for various 
> scripting engines using BSF. So the plugin jar, the bsf.jar and the 
> languages jar files are in the IDE's jars directory. Now when the IDE
> starts 
> up, it adds ALL the jar inside the "jars" directory to its CL. Thus a
> plugin 
> can access any jar if it is in the "jars" directory. But javascript and 
> jython are the two languages that are reciprocal of each other. One loads 
> fine if I don't touch the classpath(sys property java.class.path) or the 
> IDE's ClassLoader the other (jython) does not recognise the current CL
> but 
> only recog. classes either directly added to it via 
> sys.packageManager.addJar() method. so what I have temporarily done is
> load 
> nothing if language is other than Jython. And if the user selects Jython
> in 
> the dropdown, then I call the Jython hack class which would add ALL the
> jar 
> inside the "jars" directory to sys.packageManager. Now the funniest part
> is 
> that sometimes, no matter what, everything works perfectly fine using the 
> above method, but sometimes(if I figure out the steps then wud let you
> know 
> too but right now it is abrupt) Javascript behaves funny and gives me 
> NoClassDefFound:org/mozilla/javascript/NativeScript. This is really 
> un-intutive and I hope the BSF engine for Javascript is updated for the 
> latest rhino specs(I think it is Rhino 1.5R4.1). THe newer version
> complains 
> about some Debugger class not found. So I am using sometimes-workable
> rhino 
> 1.5R3 which is giving me this strange behaviour.
> Any tips.
> -Jiger
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: bsf-dev-help@jakarta.apache.org
> >
> _________________________________________________________________
> Attention NRIs! Send money to India. 
> http://server1.msn.co.in/msnleads/citibankrca/citibankrca2.asp Do it in a 
> jiffy!
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bsf-dev-help@jakarta.apache.org

View raw message