sofa-ark icon indicating copy to clipboard operation
sofa-ark copied to clipboard

Windows environment idea debug start ark package (including multiple spring boot project biz package) can not load other biz packages except the host package

Open HeYisheng opened this issue 6 years ago • 4 comments

宿主包和其依赖的biz包都是idea上的本地工程时,对应的classpath为其tartget/classes目录,此时不会生成对应的com/alipay/sofa/ark/biz/mark文件来标识biz包(plugin也一样)。当手动加入com/alipay/sofa/ark/biz/mark文件后,代码:

                URL resourceUrl = enumeration.nextElement();
                String resourceFile = resourceUrl.getFile();
                String jarFile = resourceFile.substring(0,
                    resourceFile.length() - resource.length() - FILE_IN_JAR.length());
                urlList.add(new URL(jarFile));

new URL(jarFile)由于resourceFile 为/D:/****会出现无协议异常。

  • SOFAArk version: 1.0.0
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

HeYisheng avatar Nov 12 '19 07:11 HeYisheng

Hi @HeYisheng, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

When the host package and its dependent biz package are local projects on the idea, the corresponding classpath is its cartet/classes directory. At this time, the corresponding com/alipay/sofa/ark/biz/mark file is not generated to identify the biz package. (The same is true for plugin). When manually adding the com/alipay/sofa/ark/biz/mark file, the code: URL resourceUrl = enumeration.nextElement(); String resourceFile = resourceUrl.getFile(); String jarFile = resourceFile.substring(0, resourceFile .length() - resource.length() - FILE_IN_JAR.length()); urlList.add(new URL(jarFile)); new URL(jarFile) will appear because resourceFile is /D:/**** No protocol exception. - SOFAArk version: 1.0.0 - JVM version (eg java -version): - OS version (eg uname -a): - Maven version: - IDE version:

sofastack-bot[bot] avatar Nov 12 '19 07:11 sofastack-bot[bot]

@HeYisheng we holp you can provide your demo project, and then we can understand and deal with your problems faster

glmapper avatar Nov 17 '19 06:11 glmapper

we have the same problme

jaxma666 avatar Oct 13 '20 01:10 jaxma666

SOFAArk 2.0 may resolve this issue. cc @yuanyuancin

lylingzhen avatar Mar 28 '22 05:03 lylingzhen

@jaxma666 @HeYisheng 能否提供一下demo或者使用尽量简短的代码复现这个问题呢?

sususama avatar Apr 27 '23 13:04 sususama

@jaxma666 @HeYisheng 异常 java.net.MalformedURLException: no protocol 通常表示 URL 的协议格式不正确,这个问题可能来源于文件的路径格式。具体来说,由于 Windows 和 Unix 之间的路径分隔符不同,反斜杠\在程序中容易导致不同平台上的问题,因此可以将路径分隔符替换为正斜杠 /。如果是构造具有文件协议的 URL,可以使用 file:// 协议,例如:

String jarFileUrl = "file://" + jarFile;
urlList.add(new URL(jarFileUrl));

这样就能够正确地生成对应的 URL 了。

sususama avatar Apr 27 '23 13:04 sususama

Hi,@jaxma666 @HeYisheng 如果还有问题的话请再开issue讨论,这个我先close了。

sususama avatar May 04 '23 12:05 sususama