sofastack / sofa-ark

SOFAArk is a light-weight,java based classloader isolation framework.
https://www.sofastack.tech/projects/sofa-boot/sofa-ark-readme/
Apache License 2.0
1.56k stars 497 forks source link

sofa-ark-spring-guides使用本地sofaark一直出错 #594

Closed springcoco closed 1 year ago

springcoco commented 1 year ago

问题: sofa-ark-spring-guides中maven依赖有sofa-ark-springboot-starter,我将sofaark项目下载到本地,然后使用IDEA引入sofa-ark-springboot-starter这个module,直接使用本地的sofa-ark-springboot-starter,但这样一直出现错误。之后我尝试将sofaark在本地打包,引入maven中,发现依然出错。按照官网指引操作的话,sofa-ark-spring-guides在IDEA可以正常启动。但是替换到本地的一些依赖,就出错。

疑惑: 这种情况是因为什么原因呢?还是因为缺少一些东西。

报错信息: java.lang.RuntimeException: Meet exception when determine whether to start SOFAArk! at com.alipay.sofa.ark.springboot.listener.ArkApplicationStartListener.onApplicationEvent(ArkApplicationStartListener.java:66) ~[classes/:na] at com.alipay.sofa.ark.springboot.listener.ArkApplicationStartListener.onApplicationEvent(ArkApplicationStartListener.java:39) ~[classes/:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85) ~[spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66) ~[spring-boot-2.7.6.jar:2.7.6] at java.util.ArrayList.forEach(ArrayList.java:1259) ~[na:1.8.0_312] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120) ~[spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114) ~[spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65) ~[spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:343) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:301) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) [spring-boot-2.7.6.jar:2.7.6] at com.example.gudies.GudiesApplication.main(GudiesApplication.java:13) [classes/:na] Caused by: java.lang.RuntimeException: java.lang.NullPointerException at com.alipay.sofa.ark.support.startup.EmbedSofaArkBootstrap.launch(EmbedSofaArkBootstrap.java:65) ~[classes/:na] at com.alipay.sofa.ark.springboot.listener.ArkApplicationStartListener.startUpArkEmbed(ArkApplicationStartListener.java:93) ~[classes/:na] at com.alipay.sofa.ark.springboot.listener.ArkApplicationStartListener.onApplicationEvent(ArkApplicationStartListener.java:53) ~[classes/:na] ... 16 common frames omitted Caused by: java.lang.NullPointerException: null at com.alipay.sofa.ark.bootstrap.AbstractLauncher.createContainerClassLoader(AbstractLauncher.java:139) ~[classes/:na] at com.alipay.sofa.ark.bootstrap.AbstractLauncher.launch(AbstractLauncher.java:64) ~[classes/:na] at com.alipay.sofa.ark.support.startup.EmbedSofaArkBootstrap.launch(EmbedSofaArkBootstrap.java:62) ~[classes/:na] ... 18 common frames omitted

gaosaroma commented 1 year ago

这个看起来像是运行jar包的报错?应该运行jar包是sofa-ark-spring-guides-0.0.1-SNAPSHOT-ark-biz.jar,可能是指定的jar出错了。另:没有太理解“本地下载的sofa-ark-springboot-starter包“是什么意思呢,与demo中版本一致就没问题的

springcoco commented 1 year ago

@gaosaroma 是这样的,比如说,我现在下载了sofaark这个项目,然后用idea打开sofaark,我再用idea打开一个spring项目,然后在spring中我想使用我下载的这个sofaark,比如说里面的sofa-ark-springboot-starter,我可以以引入maven的方式引入到spring项目中,但是这个时候,spring项目运行就会报错。如果我直接在spring中使用maven官网仓库的sofaark便可以正常运行。为了解决本地使用的问题,我尝试将我下载的这个sofaark在本地打包,即打包成jar包,然后再spring项目中引用,发现依然报错。

gaosaroma commented 1 year ago

目前 master 是 2.0.7 吧,我本地运行是正常的呢

lylingzhen commented 1 year ago

问题还有吗?

sususama commented 1 year ago

@springcoco 可能是因为打包的命令或者之类的东西有问题,尝试使用这个命令:

mvn clean install -DskipTests -Dmaven.javadoc.skip=true -B -U

然后将Ark生成的包放在maven仓库中,直接替换掉你需要版本的.jar包,就会正常运行,这个我做过实验。

sususama commented 1 year ago

这个issue先close了,如果还有问题reopen一下

hionwi commented 1 year ago

在application.properties未配置spring.application.name也会导致Meet exception when determine whether to start SOFAArk!错误 足足排查了一天