You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-dev@jakarta.apache.org by Jiger Patel <ji...@hotmail.com> on 2003/05/28 09:45:21 UTC

Strange Classpath issue.

Hi,
    I am facing some problem vis-a-vis setting up Jython Engine to recognise 
jars in a dir. Actually other  Engines namely Javascript, Beanshell seem to 
be working fine but Jython does not load classes from the Current CL but 
rather picks up classes from the System ClassLoader. Now to hack it away, I 
am setting classpath directly into the SYS. CL so that Jython works fine. 
Jython starts working fine, BUT Javascript seems to be having problems and 
gives me this error
java.lang.NoClassDefFoundError: org/mozilla/javascript/NativeScript
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:431)
	at org.mozilla.classfile.DefiningClassLoader.defineClass(Unknown Source)
	at org.mozilla.javascript.optimizer.Codegen.compile(Unknown Source)
	at org.mozilla.javascript.Context.compile(Unknown Source)
	at org.mozilla.javascript.Context.compile(Unknown Source)
	at org.mozilla.javascript.Context.compileReader(Unknown Source)
	at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
	at org.mozilla.javascript.Context.evaluateString(Unknown Source)
	at org.apache.bsf.engines.javascript.JavaScriptEngine.eval(Unknown Source)
	at org.apache.bsf.BSFManager$5.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.bsf.BSFManager.eval(Unknown Source)
	at java.awt.Component.processEvent(Component.java:4943)
	at java.awt.Container.processEvent(Container.java:1566)
	at java.awt.Component.dispatchEventImpl(Component.java:3639)
	at java.awt.Container.dispatchEventImpl(Container.java:1623)
	at java.awt.Component.dispatchEvent(Component.java:3480)
	at 
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1688)
	at 
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:593)
	at 
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:765)
	at 
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:698)
	at 
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:559)
	at java.awt.Component.dispatchEventImpl(Component.java:3509)
	at java.awt.Container.dispatchEventImpl(Container.java:1623)
	at java.awt.Window.dispatchEventImpl(Window.java:1590)
	at java.awt.Component.dispatchEvent(Component.java:3480)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
	at 
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
	at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

Because it is finding Duplicate Class? or not finding it at all since I am 
modifying java.class.path Dynamically based on the language selection is 
Jython or not. For other Languages, I set the java.class.path property to 
the Original ClassPath setting. Could anyone help me sort out this bug?.

My second question is, How can I get the Language Interpreter object such 
that for Jython I could directly add the external jars to its Interpreter 
instead of manipulating the System Classpath Dynamically. Can I write a 
script in Jython which accesses the PySystemState and adds the jars to the 
interpreter. Does anyone have any tips for this. I am sure Dynamic Language 
Switching would be a good feature and many Gurus out here must be having a 
solution to this problem.

Thirdly ain't Rhino BSF Engine maintained? I am running a very old version 
of Rhino (I think 1_5_R3 or something) and using the new version gives me 
some errors. If you want I could send you the errors I get.


Awaiting your replies,
Jiger Patel.

_________________________________________________________________
Race along with NK. The fastest Indian 
http://server1.msn.co.in/sp03/tataracing/index.asp Feel the thrill!


Re: Strange Classpath issue.

Posted by Igor Bukanov <ig...@mir2.org>.
On Wed, 28 May 2003 13:15:21 +0530, "Jiger Patel" <ji...@hotmail.com>
said:
> Hi,
>     I am facing some problem vis-a-vis setting up Jython Engine to
>     recognise 
> jars in a dir. Actually other  Engines namely Javascript, Beanshell seem
> to 
> be working fine but Jython does not load classes from the Current CL but 
> rather picks up classes from the System ClassLoader. Now to hack it away,
> I 
> am setting classpath directly into the SYS. CL so that Jython works fine. 
> Jython starts working fine, BUT Javascript seems to be having problems
> and 
> gives me this error
> java.lang.NoClassDefFoundError: org/mozilla/javascript/NativeScript
> 	at java.lang.ClassLoader.defineClass0(Native Method)

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.