春季启动-codeSource返回为空

时间:2018-10-03 20:00:21

标签: java spring-boot nullpointerexception

警告我是弹簧靴的新手...

任何人都遇到过一个空指针异常试图获取codeSource / URL的情况,我将其范围缩小到了Spring代码库中的这段代码

ProtectionDomain protectionDomain = getClass().getProtectionDomain();
    CodeSource codeSource = protectionDomain.getCodeSource();
    this is line 119: URI location = (codeSource != null) ? codeSource.getLocation().toURI() : null;

这是堆栈跟踪

org.springframework.boot.loader.JarLauncher.main exited with an exception.
java.lang.IllegalStateException: java.lang.NullPointerException
    at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:41)
    at org.springframework.boot.loader.JarLauncher.<init>(JarLauncher.java:35)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
    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:483)
    at com.kabira.platform.MainWrapper.invokeMain(MainWrapper.java:66)
Caused by: java.lang.NullPointerException
    at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:119)
    at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:38)
    ... 7 more

0 个答案:

没有答案