使用Java 调用 jython 报错 URI is not hierarchical

IllegalArgumentException: URI is not hierarchical] with root cause
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.ThreadStateMapping.getThreadState(ThreadStateMapping.java:56)
	at org.python.core.Py.getThreadState(Py.java:1741)
	at org.python.core.Py.getThreadState(Py.java:1737)
	at org.python.core.Py.getSystemState(Py.java:1757)
	at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:100)
	at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:93)
	at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:70)
	at com.example.kimnara.controller.KafkaProducer.invokPy(KafkaProducer.java:138)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)

在这里插入图片描述

通过idea 远程断点发现
发现url是如下的: jar:file:/D:/maven/apache-maven-3.3.9/repository/org/python/jython/2.7.2/jython-2.7.2.jar!/org/python/core/PrePy.class
嵌套不能用
解决方案:maven打包时候将jython剔除;运行时候加载外部jar包即可。

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <layout>ZIP</layout>
                    <excludeGroupIds>
                        org.python
                    </excludeGroupIds>
                </configuration>
            </plugin>
        </plugins>
    </build>

在这里插入图片描述
java -Dloader.path=“lib/” -jar kimnara-0.0.1-SNAPSHOT.jar

lib里面放的jar包
文件目录结构

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值