Issue1611977

classification
Title: Jython not finding classes in Classpath
Type: rfe Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: arn0n, ks_srikanth
Priority: urgent Keywords:

Created on 2006-12-09.04:03:40 by ks_srikanth, last changed 2006-12-26.12:04:07 by ks_srikanth.

Messages
msg3025 (view) Author: Srikanth (ks_srikanth) Date: 2006-12-09.04:03:40
Hi,
I have created .py script and trying to execute the script from my application deployed in Weblogic9.1. I am using Jython2.2 for the same. Though I have set the application jar file in the CLASSPATH, Jython finds only the package.
My script code is as simple as this: 
-----------------------------------
from com.xyz.components.impl import Class1
c1 = Class1()
c1.execute()
-----------------------------------
In the above example, Jython throws an ImportError for Class1 at line1, though it recognizes the package. 
I got some hints when I did some internet search - using PySystemState.addPackage("com.xyz.components.impl.Class1")
Now, the import error has vanished. But it throws a "NullPointerException" at line 2. 
------------------------------
The error is ...
java.lang.NullPointerException
    at java.lang.Class.isAssignableFrom(Native method)
    at org.python.core.PyJavaClass.check_lazy_allowed(PyJavaClass.java:92)
    at org.python.core.PyJavaClass.initLazy(PyJavaClass.java:99)
    at org.python.core.PyJavaClass.initialize(PyJavaClass.java:116)
....
    at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:169)
-------------------------------
Assuming this a class loader problem, I even tried to extend PythonInterpreter and set myClassLoader to PySystemState during initializing. But still it has not resolved my problem. 
Am I going in the right direction? Is there any easy fix for the problem? Can anyone help me find the correct solution for this? 

msg3026 (view) Author: Arnon Klein (arn0n) Date: 2006-12-25.20:48:40
did you try doing:
import sys
sys.add_package("com.xyz.components.impl")
from com.xyz.components.impl import Class1
c1 = Class1()
c1.execute()
msg3027 (view) Author: Srikanth (ks_srikanth) Date: 2006-12-26.12:04:07
Hi,
Thanks for your response. I could resolve this by adding my application jar file to 'sys.path'. But still I'm not sure if this is an elegant way of fixing this problem. As long as it works, no issues!
History
Date User Action Args
2006-12-09 04:03:40ks_srikanthcreate