2.7b3 JSR-223 ScriptEngine == null (b2 works)

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

2.7b3 JSR-223 ScriptEngine == null (b2 works)

Johan Van Noten

Dear Jython users/devs,

 

I had an application, working fine with 2.7b2.

Same application with 2.7b3 fails: the command ScriptEngineManager.getEngineByName(“python”) returns null.

 

Environment:

·         Small OSGi application (see binary & source links below)

·         Uses JSR-223 to get a ScriptEngine for python

 

Steps to reproduce (good run with 2.7b2):

·         Download http://www.qtc.be/TestJythonOSGi.zip

·         Extract in any directory (This archive is for Windows x64 and Java x64 only. Other OS/VM on request.)

·         Adjust the file TestJythonOSGi.ini to point to a 64-bit VM on your machine. Take java.exe, not javaw.exe in order to see the console.

·         Run TestJythonOSGi.exe

·         You should see how Jython initializes (producing the cachedir).

·         The last line will say “2”, being the result of scriptEngine.eval(“1+1”, context).

·         Then the “>Exit” promp appears, type shutdown or exit.

 

Steps to reproduce (bad run with 2.7b3):

·         Remove the cachedir (just to make sure)

·         Goto TestJythonOSGi\plugins\TestJythonOSGi_1.0.0.201410151320\lib

·         The application uses jython-2.7-b2.jar, but the directory contains two other files:

o   The original jython-2.7-b2-realb2.jar (identical to the one above)

o   The jython-2.7-b2-renamedb3.jar (with is the b3 version)

·         Remove jython-2.7-b2.jar

·         Rename jython-2.7-b2-renamedb3.jar to jython-2.7-b2.jar

·         You now essentially have the same app, but with b3 (fakely renamed to b2)

·         Execute in the same manner as above.

·         Instead of “2”, the last line will now say “getEngineByName returned null”

 

Already tried:

·         I debugged into the application. It seems that the ScriptEngine is registered fine.
The javax ScriptEngineManager finds the ScriptEngineFactory.
When it then requests the creation of the ScriptEngine, null is returned.
I was unable to trace into this.

·         I tried by building my own jython-2.7-b3+ head version.
Behaviour is identical.

·         The reproduction scenario above replaces the lib without recompilation.
One could assume that this causes issues as well.
Nicely rebuilding with the other library results in the same issue, though.

 

Sources:

·         The file http://www.qtc.be/TestJythonOSGiSources.zip contains two Eclipse Kepler projects

·         The relevant source file is TestJythonOSGi\src\testjythonosgi\Activator.java

·         Can’t immediately think of a way to make it easier for others to debug L

 

Questions / remarks:

·         Is the behavior of b3 different from b2 with respect to OSGi?

·         Is the issue caused by additional requirements (I suddenly see a lot of netty, bouncycastle etc turning up in b3).

·         I also see that the b3.jar contains duplicate files (same file occurring multiple times within the MANIFEST directory.)
As far as I see, no essential files are involved in this issue. Could it be an issue anyway?

 

Thanks for any assistance,

Johan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Curtis Rueden

Hi Johan,

Presumably, if you build b2 from source all is well?

If so, is it possible to bisect the Jython source between the b2 and b3 tags to isolate the commit which introduced the issue?

-Curtis

On Oct 15, 2014 7:04 AM, "Johan Van Noten" <[hidden email]> wrote:

Dear Jython users/devs,

 

I had an application, working fine with 2.7b2.

Same application with 2.7b3 fails: the command ScriptEngineManager.getEngineByName(“python”) returns null.

 

Environment:

·         Small OSGi application (see binary & source links below)

·         Uses JSR-223 to get a ScriptEngine for python

 

Steps to reproduce (good run with 2.7b2):

·         Download http://www.qtc.be/TestJythonOSGi.zip

·         Extract in any directory (This archive is for Windows x64 and Java x64 only. Other OS/VM on request.)

·         Adjust the file TestJythonOSGi.ini to point to a 64-bit VM on your machine. Take java.exe, not javaw.exe in order to see the console.

·         Run TestJythonOSGi.exe

·         You should see how Jython initializes (producing the cachedir).

·         The last line will say “2”, being the result of scriptEngine.eval(“1+1”, context).

·         Then the “>Exit” promp appears, type shutdown or exit.

 

Steps to reproduce (bad run with 2.7b3):

·         Remove the cachedir (just to make sure)

·         Goto TestJythonOSGi\plugins\TestJythonOSGi_1.0.0.201410151320\lib

·         The application uses jython-2.7-b2.jar, but the directory contains two other files:

o   The original jython-2.7-b2-realb2.jar (identical to the one above)

o   The jython-2.7-b2-renamedb3.jar (with is the b3 version)

·         Remove jython-2.7-b2.jar

·         Rename jython-2.7-b2-renamedb3.jar to jython-2.7-b2.jar

·         You now essentially have the same app, but with b3 (fakely renamed to b2)

·         Execute in the same manner as above.

·         Instead of “2”, the last line will now say “getEngineByName returned null”

 

Already tried:

·         I debugged into the application. It seems that the ScriptEngine is registered fine.
The javax ScriptEngineManager finds the ScriptEngineFactory.
When it then requests the creation of the ScriptEngine, null is returned.
I was unable to trace into this.

·         I tried by building my own jython-2.7-b3+ head version.
Behaviour is identical.

·         The reproduction scenario above replaces the lib without recompilation.
One could assume that this causes issues as well.
Nicely rebuilding with the other library results in the same issue, though.

 

Sources:

·         The file http://www.qtc.be/TestJythonOSGiSources.zip contains two Eclipse Kepler projects

·         The relevant source file is TestJythonOSGi\src\testjythonosgi\Activator.java

·         Can’t immediately think of a way to make it easier for others to debug L

 

Questions / remarks:

·         Is the behavior of b3 different from b2 with respect to OSGi?

·         Is the issue caused by additional requirements (I suddenly see a lot of netty, bouncycastle etc turning up in b3).

·         I also see that the b3.jar contains duplicate files (same file occurring multiple times within the MANIFEST directory.)
As far as I see, no essential files are involved in this issue. Could it be an issue anyway?

 

Thanks for any assistance,

Johan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho

_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Johan Van Noten

Hi Curtis,

 

Never used bisect before, so I already learned something today J (not a Mercurial user). Nice feature.

 

Result: 7332 with comment “Ensure that the site module is imported when using PythonInterpreter”.

Remark: in order to make this revision work, I had to manually add extlibs\antlr-runtime-3.1.3.jar, since its absence seemed to break the build in that revision.

 

Analysis:

In my environment, “site.py” is not always available.

This probably causes the issue.

I will check to make sure that it is available anyway.

 

Question:

On the other hand, I am wondering why site.py now suddenly becomes a requirement.

Is that intentional?

 

Thanks,

Johan

 

Van: [hidden email] [mailto:[hidden email]] Namens Curtis Rueden
Verzonden: woensdag 15 oktober 2014 14:10
Aan: Johan Van Noten
CC: [hidden email]
Onderwerp: Re: [Jython-users] 2.7b3 JSR-223 ScriptEngine == null (b2 works)

 

Hi Johan,

Presumably, if you build b2 from source all is well?

If so, is it possible to bisect the Jython source between the b2 and b3 tags to isolate the commit which introduced the issue?

-Curtis

On Oct 15, 2014 7:04 AM, "Johan Van Noten" <[hidden email]> wrote:

Dear Jython users/devs,

 

I had an application, working fine with 2.7b2.

Same application with 2.7b3 fails: the command ScriptEngineManager.getEngineByName(“python”) returns null.

 

Environment:

·         Small OSGi application (see binary & source links below)

·         Uses JSR-223 to get a ScriptEngine for python

 

Steps to reproduce (good run with 2.7b2):

·         Download http://www.qtc.be/TestJythonOSGi.zip

·         Extract in any directory (This archive is for Windows x64 and Java x64 only. Other OS/VM on request.)

·         Adjust the file TestJythonOSGi.ini to point to a 64-bit VM on your machine. Take java.exe, not javaw.exe in order to see the console.

·         Run TestJythonOSGi.exe

·         You should see how Jython initializes (producing the cachedir).

·         The last line will say “2”, being the result of scriptEngine.eval(“1+1”, context).

·         Then the “>Exit” promp appears, type shutdown or exit.

 

Steps to reproduce (bad run with 2.7b3):

·         Remove the cachedir (just to make sure)

·         Goto TestJythonOSGi\plugins\TestJythonOSGi_1.0.0.201410151320\lib

·         The application uses jython-2.7-b2.jar, but the directory contains two other files:

o   The original jython-2.7-b2-realb2.jar (identical to the one above)

o   The jython-2.7-b2-renamedb3.jar (with is the b3 version)

·         Remove jython-2.7-b2.jar

·         Rename jython-2.7-b2-renamedb3.jar to jython-2.7-b2.jar

·         You now essentially have the same app, but with b3 (fakely renamed to b2)

·         Execute in the same manner as above.

·         Instead of “2”, the last line will now say “getEngineByName returned null”

 

Already tried:

·         I debugged into the application. It seems that the ScriptEngine is registered fine.
The javax ScriptEngineManager finds the ScriptEngineFactory.
When it then requests the creation of the ScriptEngine, null is returned.
I was unable to trace into this.

·         I tried by building my own jython-2.7-b3+ head version.
Behaviour is identical.

·         The reproduction scenario above replaces the lib without recompilation.
One could assume that this causes issues as well.
Nicely rebuilding with the other library results in the same issue, though.

 

Sources:

·         The file http://www.qtc.be/TestJythonOSGiSources.zip contains two Eclipse Kepler projects

·         The relevant source file is TestJythonOSGi\src\testjythonosgi\Activator.java

·         Can’t immediately think of a way to make it easier for others to debug L

 

Questions / remarks:

·         Is the behavior of b3 different from b2 with respect to OSGi?

·         Is the issue caused by additional requirements (I suddenly see a lot of netty, bouncycastle etc turning up in b3).

·         I also see that the b3.jar contains duplicate files (same file occurring multiple times within the MANIFEST directory.)
As far as I see, no essential files are involved in this issue. Could it be an issue anyway?

 

Thanks for any assistance,

Johan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho

_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Jim Baker-2
In reply to this post by Johan Van Noten
Johan,

Thanks for your testing and your details on reproducing these observed problems! I will answer some questions that I can immediately answer without first digging further into JSR 223 and OSGI details:

On Wed, Oct 15, 2014 at 6:03 AM, Johan Van Noten <[hidden email]> wrote:

...

 

·         I debugged into the application. It seems that the ScriptEngine is registered fine.

The javax ScriptEngineManager finds the ScriptEngineFactory.
When it then requests the creation of the ScriptEngine, null is returned.
I was unable to trace into this.

·         I tried by building my own jython-2.7-b3+ head version.
Behaviour is identical.

Try restoring extlibs/livetribe-jsr223-2.0.6.jar. I may have been mistaken in removing this jar - among other things it may have a subtly different behavior:

changeset:   7346:a00987ea4da6
user:        Jim Baker <[hidden email]>
date:        Wed Jul 02 14:50:21 2014 -0600
files:       build.xml extlibs/livetribe-jsr223-2.0.6.jar
description:
Java since Java 6 supports JSR 223 scripting, so no need to include
supporting jar. 

·         The reproduction scenario above replaces the lib without recompilation.
One could assume that this causes issues as well.
Nicely rebuilding with the other library results in the same issue, though.

 

Sources:

·         The file http://www.qtc.be/TestJythonOSGiSources.zip contains two Eclipse Kepler projects

·         The relevant source file is TestJythonOSGi\src\testjythonosgi\Activator.java

·         Can’t immediately think of a way to make it easier for others to debug L

 

Questions / remarks:

·         Is the behavior of b3 different from b2 with respect to OSGi?

We really haven't considered OSGI issues, although this would be a great thing to consider for 2.7.x, where x>0, and we would value your feedback here. Having said that, I think we are in better shape for unloading as of beta 3 and some of the recent work in beta 4 development.

·         Is the issue caused by additional requirements (I suddenly see a lot of netty, bouncycastle etc turning up in b3).

I would not expect this to be a problem, due to the use of shading via Jar Jar Links, given that we do this for other dependencies that can potentially cause conflicts (examples include ASM, Google Collections, Xerces - all widely used).

·         I also see that the b3.jar contains duplicate files (same file occurring multiple times within the MANIFEST directory.)

This is an important bug, to resolved in the ant build process: http://bugs.jython.org/issue2196

I have made it urgent, which means it now blocks 2.7.0 beta 4 in our triage

As far as I see, no essential files are involved in this issue. Could it be an issue anyway?

We do not care about these files, but such duplicates in the single jar building process certainly causes problems elsewhere, so we will fix regardless and hope this helps for JSR 223 support.

- Jim

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Johan Van Noten
In reply to this post by Johan Van Noten

Guys,

 

Sorry to say that I’m stuck…

 

Summary of the issue of this thread:

since revision 7332 added the automatic loading of site.py, I can’t create a ScriptEngine anymore.

 

Trial 1: debugging

 

I was tracing into the Jython code and I see that imp.class is trying to load site.py.

That seems to work fine, since I see it then loading so.py and stat.py and so on, which is to be expected because they are the ones required by site.py.

At the end, it does seem to fail on the site.py anyway (RuntimeException in imp.createFromCode) and I don’t understand why.

My Python / Jython knowledge is getting to its limits here…

 

Trial 2: small test program to verify whether I can import anything at all.

I tried also to execute (in my OSGi test program):

>>> import hashlib

null

>>> m = hashlib.md5()

null

>>> m.update('Nobody inspects')

null

>>> m.update(' the spammish repetition')

null

>>> m.hexdigest()

bb649c83dd1ea5c9d9dec9a18df0ffe9

>>> import site

 

And then an exception is raised (ImportError: No module named sysconfig in <script> at line number 1)

  File "<script>", line 1, in <module>

  File "__pyclasspath__/site.py", line 563, in <module>

  File "__pyclasspath__/site.py", line 545, in main

  File "__pyclasspath__/site.py", line 278, in addusersitepackages

  File "__pyclasspath__/site.py", line 253, in getusersitepackages

  File "__pyclasspath__/site.py", line 242, in getuserbase

 

The fact that I can import hashlib seems to prove that I can correctly import modules.

The site.py doesn’t load anyway.

Any issue with this file?

 

Trial 3: small test, other python libs

 

Please note: For this example I’m using the libraries from jython\lib-python\2.7.

This is a different set from jython\Lib.

What’s the difference?

Anyway, when trying jython\Lib, it seems hashlib is not available.

I then just imported gzip.

Seems to find and load gzip, but while doing so it gets stuck on stat.py.

 

(. . .)

Caused by: javax.script.ScriptException: ImportError: No module named stat in <script> at line number 1

       at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)

       at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)

       at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)

       at testjythonosgi.Activator.exec(Activator.java:55)

       at testjythonosgi.Activator.start(Activator.java:48)

       at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)

       at java.security.AccessController.doPrivileged(Native Method)

       at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)

       ... 12 more

Caused by: Traceback (most recent call last):

  File "<script>", line 1, in <module>

  File "__pyclasspath__/gzip.py", line 8, in <module>

  File "__pyclasspath__/os.py", line 64, in <module>

  File "__pyclasspath__/ntpath.py", line 10, in <module>

ImportError: No module named stat

 

 

Getting fully confused now L

 

Johan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Jim Baker-2
You can configure whether site.py is imported with org.python.core.Options.importSite, setting it to be false. (I would assume this is the best way to do with respect to JSR 223 support.) Or you can use the Jython registry or control with a command line property setting.

On Wed, Oct 15, 2014 at 10:43 AM, Johan Van Noten <[hidden email]> wrote:

Guys,

 

Sorry to say that I’m stuck…

 

Summary of the issue of this thread:

since revision 7332 added the automatic loading of site.py, I can’t create a ScriptEngine anymore.

 

Trial 1: debugging

 

I was tracing into the Jython code and I see that imp.class is trying to load site.py.

That seems to work fine, since I see it then loading so.py and stat.py and so on, which is to be expected because they are the ones required by site.py.

At the end, it does seem to fail on the site.py anyway (RuntimeException in imp.createFromCode) and I don’t understand why.

My Python / Jython knowledge is getting to its limits here…

 

Trial 2: small test program to verify whether I can import anything at all.

I tried also to execute (in my OSGi test program):

>>> import hashlib

null

>>> m = hashlib.md5()

null

>>> m.update('Nobody inspects')

null

>>> m.update(' the spammish repetition')

null

>>> m.hexdigest()

bb649c83dd1ea5c9d9dec9a18df0ffe9

>>> import site

 

And then an exception is raised (ImportError: No module named sysconfig in <script> at line number 1)

  File "<script>", line 1, in <module>

  File "__pyclasspath__/site.py", line 563, in <module>

  File "__pyclasspath__/site.py", line 545, in main

  File "__pyclasspath__/site.py", line 278, in addusersitepackages

  File "__pyclasspath__/site.py", line 253, in getusersitepackages

  File "__pyclasspath__/site.py", line 242, in getuserbase

 

The fact that I can import hashlib seems to prove that I can correctly import modules.

The site.py doesn’t load anyway.

Any issue with this file?

 

Trial 3: small test, other python libs

 

Please note: For this example I’m using the libraries from jython\lib-python\2.7.

This is a different set from jython\Lib.

What’s the difference?

Anyway, when trying jython\Lib, it seems hashlib is not available.

I then just imported gzip.

Seems to find and load gzip, but while doing so it gets stuck on stat.py.

 

(. . .)

Caused by: javax.script.ScriptException: ImportError: No module named stat in <script> at line number 1

       at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)

       at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)

       at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)

       at testjythonosgi.Activator.exec(Activator.java:55)

       at testjythonosgi.Activator.start(Activator.java:48)

       at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)

       at java.security.AccessController.doPrivileged(Native Method)

       at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)

       ... 12 more

Caused by: Traceback (most recent call last):

  File "<script>", line 1, in <module>

  File "__pyclasspath__/gzip.py", line 8, in <module>

  File "__pyclasspath__/os.py", line 64, in <module>

  File "__pyclasspath__/ntpath.py", line 10, in <module>

ImportError: No module named stat

 

 

Getting fully confused now L

 

Johan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users




--

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Jeff Allen-2
In reply to this post by Johan Van Noten
Johan:

You appear to be loading the Python site.py, not the Jython one. (I guess that's what the __pyclasspath__ is about.) I'm going by the line numbers in your stack dump. In a recent Python 2.7, site.py line 563 is a call to main, line 545 is a call to addusersitepackages, and so on. Not so in the Jython one.

We use the same libraries for a lot of things but there are many critical differences in these low-level "platform" files. Path problem of some kind. (It may need python.home defined on the java command line, in the registry or some equivalent.)

During
    scriptEngineManager.getEngineByName("python")
and during imp("site"), my sys.path looks like:
    ['C:\\Users\\Jeff\\Documents\\Eclipse\\jython-trunk\\dist\\Lib', '__classpath__', '__pyclasspath__/', '']

(Not sure that trailing "/" is right for Windows!)
Jeff Allen

On 15/10/2014 17:43, Johan Van Noten wrote:

Guys,

 

Sorry to say that I’m stuck…

 

Summary of the issue of this thread:

since revision 7332 added the automatic loading of site.py, I can’t create a ScriptEngine anymore.

 

Trial 1: debugging

 

I was tracing into the Jython code and I see that imp.class is trying to load site.py.

That seems to work fine, since I see it then loading so.py and stat.py and so on, which is to be expected because they are the ones required by site.py.

At the end, it does seem to fail on the site.py anyway (RuntimeException in imp.createFromCode) and I don’t understand why.

My Python / Jython knowledge is getting to its limits here…

 

Trial 2: small test program to verify whether I can import anything at all.

I tried also to execute (in my OSGi test program):

>>> import hashlib

null

>>> m = hashlib.md5()

null

>>> m.update('Nobody inspects')

null

>>> m.update(' the spammish repetition')

null

>>> m.hexdigest()

bb649c83dd1ea5c9d9dec9a18df0ffe9

>>> import site

 

And then an exception is raised (ImportError: No module named sysconfig in <script> at line number 1)

  File "<script>", line 1, in <module>

  File "__pyclasspath__/site.py", line 563, in <module>

  File "__pyclasspath__/site.py", line 545, in main

  File "__pyclasspath__/site.py", line 278, in addusersitepackages

  File "__pyclasspath__/site.py", line 253, in getusersitepackages

  File "__pyclasspath__/site.py", line 242, in getuserbase

 

The fact that I can import hashlib seems to prove that I can correctly import modules.

The site.py doesn’t load anyway.

Any issue with this file?

 

Trial 3: small test, other python libs

 

Please note: For this example I’m using the libraries from jython\lib-python\2.7.

This is a different set from jython\Lib.

What’s the difference?

Anyway, when trying jython\Lib, it seems hashlib is not available.

I then just imported gzip.

Seems to find and load gzip, but while doing so it gets stuck on stat.py.

 

(. . .)

Caused by: javax.script.ScriptException: ImportError: No module named stat in <script> at line number 1

       at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)

       at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)

       at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)

       at testjythonosgi.Activator.exec(Activator.java:55)

       at testjythonosgi.Activator.start(Activator.java:48)

       at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)

       at java.security.AccessController.doPrivileged(Native Method)

       at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)

       ... 12 more

Caused by: Traceback (most recent call last):

  File "<script>", line 1, in <module>

  File "__pyclasspath__/gzip.py", line 8, in <module>

  File "__pyclasspath__/os.py", line 64, in <module>

  File "__pyclasspath__/ntpath.py", line 10, in <module>

ImportError: No module named stat

 

 

Getting fully confused now L

 

Johan



------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho


_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Jeff Allen-2
In reply to this post by Johan Van Noten
On 15/10/2014 17:43, Johan Van Noten wrote:
...

 

Please note: For this example I’m using the libraries from jython\lib-python\2.7.

This is a different set from jython\Lib.

What’s the difference?

Anyway, when trying jython\Lib, it seems hashlib is not available.

I then just imported gzip.

Seems to find and load gzip, but while doing so it gets stuck on stat.py.


Ahh!

Neither of those is right. You want the Lib from the installation directory, which is ~\dist\Lib if you've just built Jython from source. This should be on the path searched by imp().

~\lib-python\2.7 is a copy of what it says it is. And ~\Lib is all the files of which we need a special version. When we build Jython, we effectively copy lib-python\2.7 into ~\dist\Lib, then ~\Lib on top, to supersede any files with the same name, and to add any extra ones.

Without looking, hashlib must be one of those we use unmodified, so you found it in lib-python.

Jeff

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users
Reply | Threaded
Open this post in threaded view
|

Re: 2.7b3 JSR-223 ScriptEngine == null (b2 works)

Johan Van Noten

Hi Jeff,

 

That takes away my confusion. Thanks!

 

Based on your suggestion, I now add

     Options.importSite = false;

Before I perform the getEngineByName.

Result: it works J

 

Remains strange that Options.importSite = true keeps resulting in the getEngineByName == null.

This happens even after double checking the correct usage of Lib files as you pointed out.

 

Conclusion:

·         My problem seems solved. My needs are satisfied with importSite = false.

·         I can’t judge whether the remaining issue could be relevant to anyone.

 

Thanks,

Johan

 

Van: Jeff Allen [mailto:[hidden email]]
Verzonden: woensdag 15 oktober 2014 22:10
Aan: Johan Van Noten
CC: [hidden email]
Onderwerp: Re: [Jython-users] 2.7b3 JSR-223 ScriptEngine == null (b2 works)

 

On 15/10/2014 17:43, Johan Van Noten wrote:

...

 

Please note: For this example I’m using the libraries from jython\lib-python\2.7.

This is a different set from jython\Lib.

What’s the difference?

Anyway, when trying jython\Lib, it seems hashlib is not available.

I then just imported gzip.

Seems to find and load gzip, but while doing so it gets stuck on stat.py.

 

Ahh!

Neither of those is right. You want the Lib from the installation directory, which is ~\dist\Lib if you've just built Jython from source. This should be on the path searched by imp().

~\lib-python\2.7 is a copy of what it says it is. And ~\Lib is all the files of which we need a special version. When we build Jython, we effectively copy lib-python\2.7 into ~\dist\Lib, then ~\Lib on top, to supersede any files with the same name, and to add any extra ones.

Without looking, hashlib must be one of those we use unmodified, so you found it in lib-python.

Jeff


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users