|
From: Alexey N. S. <A.S...@md...> - 2005-01-31 22:56:04
|
I think it indicates that your code is loaded by another (global?) class loader. Where do you have Jython jar installed? - Alexey. Travis Bear wrote: >I'm really puzzled by an issue I'm seeing running Jython. I've compiled >my scripts with jythonc into java class files. These scripts import >some classes from external jar files. From the command line, everything >runs just fine. However, when I invoke the Jython scripts from inside >Tomcat, they break because they can't locate any of the packages I try >to import from. The puzzling part is that other (non-Jython) code in my >webapp imports the same pacakges just fine, and it's all running in the >same VM. > >Here is the Jython script Setup.py: > >print "Entering Setup" > >from org.jtmb.sql import DataEngine >from java.io import File > >propsFile = File("conf/DataEngine.properties") >de = DataEngine.getStaticInstance(propsFile) >print de.getString("select version as name from branch") > >Here is the code from the Velocity context where I statically invoke the >jython script: > >com.myrio.setup.Setup.main(new String[]{}); > >Here's an alternate effort in the Velocity context where I try to >explicitly use the same classloader: > > ClassLoader loader = this.getClass().getClassLoader(); > Object setup = Class.forName("com.myrio.setup.Setup", true, >loader).newInstance(); > logger.fatal ("Attempting to load setup with custom classloader"); > ((com.myrio.setup.Setup) setup).main(new String[]{}); > > >In both cases, I get the same result. Here's the output in >catalina.out. > >Entering Setup >Traceback (innermost last): > File "/home/travis/p4/3.5/qa/qas/code/jython/Setup.py", line 0, in >main >ImportError: No module named jtmb > > > >Thanks in advance -- this is my first effort at using classloaders, so I >could easily be missing something. I'm pretty sure I could get it to >work by manually setting the classpath via system properties. But that >seems like a pretty broken approach. Any help is appreciated! > > >-Travis > > > -- ------------------------------------------------------------------------ / Alexey N. Solofnenko home: http://trelony.cjb.net/ / |