Issue2870

classification
Title: PrePy.getJarFileNameFromURL fails hard when Jython jar is embedded in another jar
Type: crash Severity: major
Components: Core Versions: Jython 2.7.2
Milestone: Jython 2.7.3
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: electricsam, jeff.allen, maku
Priority: normal Keywords:

Created on 2020-03-12.14:49:03 by maku, last changed 2020-06-06.00:52:22 by electricsam.

Messages
msg13014 (view) Author: Maku (maku) Date: 2020-03-12.14:51:30
For example, if the path to PrePy.class is jar:file:spring-boot-application.jar!/BOOT-INF/lib/jython-2.7.2.jar!/org/python/core/PrePy.class, the method will fail in new File() call in the end of method with java.lang.IllegalArgumentException: URI is not hierarchical in java.io.File.<init>(File.java:420) (on OpenJDK 11).
msg13016 (view) Author: Maku (maku) Date: 2020-03-12.14:52:29
This effectively makes it impossible to use Jython in such case, as the getJarFileNameFromURL gets called by any Jython initializer method.
msg13018 (view) Author: Jeff Allen (jeff.allen) Date: 2020-03-13.20:48:13
JARs in JARs is not a case I had considered. I tidied up the code around here from a previous implementation, fixing #2410. The move from Py.java to PrePy.java is not an issue, I think, it would be the code I changed when it was in Py.java, if I've broken anything.

Did this work in earlier versions (v2.7.1), with JARs in JARs?
msg13020 (view) Author: Maku (maku) Date: 2020-03-20.15:33:12
Yes, this did work with 2.7.1 and earlier 2.7.2 beta release.
msg13022 (view) Author: Jeff Allen (jeff.allen) Date: 2020-03-20.17:56:10
" ... and earlier 2.7.2 beta release".

Does this mean it worked in b2 but not b3? b3 but not rc1? (b1 never became public.)

This is hopeful, but puzzling. The change of logic and the move to PrePy precede 2.7.2b2 release. After that there is only affects vfs: or vfszip: URLs AFAICT.
msg13102 (view) Author: Chris Slater (electricsam) Date: 2020-06-06.00:52:21
I too am experiencing this with 2.7.2, b2, b3, and rc1.  I am using Spring Boot 2.2.6 and Oracle Java 1.8.0_202.

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [gov.noaa.ncei.cmg.pycamel.PythonObjectFactory]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: URI is not hierarchical
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:217)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312)
        ... 24 more
Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
        at java.io.File.<init>(File.java:418)
        at org.python.core.PrePy.getJarFileNameFromURL(PrePy.java:427)
        at org.python.core.PrePy._getJarFileName(PrePy.java:362)
        at org.python.core.PrePy.getJarFileName(PrePy.java:345)
        at org.python.core.PySystemState.doInitialize(PySystemState.java:1195)
        at org.python.core.PySystemState.initialize(PySystemState.java:1130)
        at org.python.core.PySystemState.initialize(PySystemState.java:1085)
        at org.python.core.PySystemState.initialize(PySystemState.java:1080)
        at org.python.core.PySystemState.initialize(PySystemState.java:1075)
        at org.python.core.PySystemState.initialize(PySystemState.java:1070)
        at org.python.core.PySystemState.<init>(PySystemState.java:207)
        at gov.noaa.ncei.cmg.pycamel.PythonObjectFactory.<init>(PythonObjectFactory.java:13)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:204)
        ... 26 more
History
Date User Action Args
2020-06-06 00:52:22electricsamsetmessages: + msg13102
2020-06-05 22:32:48electricsamsetnosy: + electricsam
2020-03-20 17:56:10jeff.allensetmessages: + msg13022
milestone: Jython 2.7.3
2020-03-20 15:33:13makusetmessages: + msg13020
2020-03-13 20:48:14jeff.allensetpriority: normal
resolution: accepted
messages: + msg13018
nosy: + jeff.allen
milestone: Jython 2.7.2 -> (no value)
2020-03-12 14:52:30makusetmessages: + msg13016
2020-03-12 14:51:30makusetmessages: + msg13014
2020-03-12 14:49:03makucreate