idea 2024.1
gradle 8.8
gradle plugins org.springframework.boot 3.3.0
gradle plugins io.spring.dependency-management 1.1.5

java -jar .\startup-application.jar

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:91)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 18, end -1, length 43
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
        at java.base/java.lang.String.substring(String.java:2709)
        at org.springframework.boot.loader.jar.MetaInfVersionsInfo.get(MetaInfVersionsInfo.java:85)
        at org.springframework.boot.loader.jar.MetaInfVersionsInfo.get(MetaInfVersionsInfo.java:69)
        at org.springframework.boot.loader.zip.ZipContent.lambda$getInfo$0(ZipContent.java:326)
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
        at org.springframework.boot.loader.zip.ZipContent.getInfo(ZipContent.java:324)
        at org.springframework.boot.loader.jar.NestedJarFile.getMetaInfVersionsInfo(NestedJarFile.java:337)
        at org.springframework.boot.loader.jar.NestedJarFile.getVersionedContentEntry(NestedJarFile.java:279)
        at org.springframework.boot.loader.jar.NestedJarFile.hasEntry(NestedJarFile.java:247)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.hasEntry(JarUrlClassLoader.java:170)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.definePackage(JarUrlClassLoader.java:144)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.definePackageIfNecessary(JarUrlClassLoader.java:125)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:98)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at com.houkunlin.cloud.micro.AllInOneServerApplication.main(AllInOneServerApplication.java:34)
        ... 7 more

Unzip startup-application.jar to test folder, then cd test exec java -cp . -Xdebug -Xnoagent org.springframework.boot.loader.launch.JarLauncher is ok

Comment From: houkunlin

It looks like the path content of META-INF/versions/ in one of my dependency jars is incomplete. I am currently checking my dependency list.

Comment From: houkunlin

At present, it is found that the META-INF/versions/ path of dubbo-3.2.13.jar is suspected to not meet the conditional content of https://github.com/spring-projects/spring-boot/blob/45f09df7fe4ef4fbee7514ec34f98a1beff604cf/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/MetaInfVersionsInfo.java#L84, resulting in a -1 value.

Comment From: wilkinsona

Thanks, @houkunlin. That's exactly it. The code expects entries beneath META-INF/versions/ to be of the form META-INF/versions/<number>/*. The Apache Dubbo 3.2.13 jar has several entries that don't match this expectation:

     3077  04-01-2020 08:04   META-INF/versions/.artifacts
       89  04-01-2020 08:04   META-INF/versions/dubbo
       97  04-01-2020 08:04   META-INF/versions/dubbo-cluster
       96  04-01-2020 08:04   META-INF/versions/dubbo-common
      100  04-01-2020 08:04   META-INF/versions/dubbo-compatible
      100  04-01-2020 08:04   META-INF/versions/dubbo-config-api
      103  04-01-2020 08:04   META-INF/versions/dubbo-config-spring
      112  04-01-2020 08:04   META-INF/versions/dubbo-configcenter-zookeeper
      109  04-01-2020 08:04   META-INF/versions/dubbo-configcenter-apollo
      108  04-01-2020 08:04   META-INF/versions/dubbo-configcenter-nacos
      103  04-01-2020 08:04   META-INF/versions/dubbo-container-api
      106  04-01-2020 08:04   META-INF/versions/dubbo-container-spring
      102  04-01-2020 08:04   META-INF/versions/dubbo-filter-cache
      107  04-01-2020 08:04   META-INF/versions/dubbo-filter-validation
      102  04-01-2020 08:04   META-INF/versions/dubbo-metadata-api
      115  04-01-2020 08:04   META-INF/versions/dubbo-metadata-report-zookeeper
      111  04-01-2020 08:04   META-INF/versions/dubbo-metadata-report-nacos
      111  04-01-2020 08:04   META-INF/versions/dubbo-metadata-report-redis
      118  04-01-2020 08:04   META-INF/versions/dubbo-metadata-definition-protobuf
      101  04-01-2020 08:04   META-INF/versions/dubbo-metrics-api
      105  04-01-2020 08:04   META-INF/versions/dubbo-metrics-default
      106  04-01-2020 08:04   META-INF/versions/dubbo-metrics-registry
      108  04-01-2020 08:04   META-INF/versions/dubbo-metrics-prometheus
      106  04-01-2020 08:04   META-INF/versions/dubbo-metrics-metadata
      111  04-01-2020 08:04   META-INF/versions/dubbo-metrics-config-center
      101  04-01-2020 08:04   META-INF/versions/dubbo-monitor-api
      105  04-01-2020 08:04   META-INF/versions/dubbo-monitor-default
       94  04-01-2020 08:04   META-INF/versions/dubbo-auth
       97  04-01-2020 08:04   META-INF/versions/dubbo-qos-api
       93  04-01-2020 08:04   META-INF/versions/dubbo-qos
       98  04-01-2020 08:04   META-INF/versions/dubbo-security
       98  04-01-2020 08:04   META-INF/versions/dubbo-reactive
      105  04-01-2020 08:04   META-INF/versions/dubbo-spring-security
      102  04-01-2020 08:04   META-INF/versions/dubbo-registry-api
      108  04-01-2020 08:04   META-INF/versions/dubbo-registry-multicast
      107  04-01-2020 08:04   META-INF/versions/dubbo-registry-multiple
      104  04-01-2020 08:04   META-INF/versions/dubbo-registry-nacos
      108  04-01-2020 08:04   META-INF/versions/dubbo-registry-zookeeper
      102  04-01-2020 08:04   META-INF/versions/dubbo-remoting-api
      103  04-01-2020 08:04   META-INF/versions/dubbo-remoting-http
      104  04-01-2020 08:04   META-INF/versions/dubbo-remoting-netty
      105  04-01-2020 08:04   META-INF/versions/dubbo-remoting-netty4
      108  04-01-2020 08:04   META-INF/versions/dubbo-remoting-zookeeper
      117  04-01-2020 08:04   META-INF/versions/dubbo-remoting-zookeeper-curator5
       97  04-01-2020 08:04   META-INF/versions/dubbo-rpc-api
       99  04-01-2020 08:04   META-INF/versions/dubbo-rpc-dubbo
       99  04-01-2020 08:04   META-INF/versions/dubbo-rpc-injvm
       98  04-01-2020 08:04   META-INF/versions/dubbo-rpc-rest
      100  04-01-2020 08:04   META-INF/versions/dubbo-rpc-triple
      107  04-01-2020 08:04   META-INF/versions/dubbo-serialization-api
      112  04-01-2020 08:04   META-INF/versions/dubbo-serialization-hessian2
      113  04-01-2020 08:04   META-INF/versions/dubbo-serialization-fastjson2
      107  04-01-2020 08:04   META-INF/versions/dubbo-serialization-jdk

MetaInfVersionsInfo needs to be updated to tolerate these unexpected entries by ignoring them.

Comment From: houkunlin

It was found that the previous version 3.2.3 was running normally. During this period, this check code did not seem to have changed.

2024-06-06T19:33:46.348+08:00  INFO 72676 --- [all-in-one-server] [           main] d.s.b.c.e.WelcomeLogoApplicationListener :  [DUBBO]

 :: Dubbo (v3.2.11) : https://github.com/apache/dubbo
 :: Discuss group : dev@dubbo.apache.org
, dubbo version: 3.2.11, current host: 127.0.0.1
2024-06-06T19:33:46.375+08:00  WARN 72676 --- [all-in-one-server] [           main] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: Could not initialize Logback Nacos logging from classpath:nacos-logback.xml

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.3)
gradle 7.5.x
gradle plugins org.springframework.boot 3.2.3
gradle plugins io.spring.dependency-management 1.1.4

Comment From: wilkinsona

You're using a different version of Apache Dubbo there. 3.2.11 does not have Multi-Release: true in its manifest but 3.2.13 does. As a result of this different, you won't see the problem with 3.2.11.

Comment From: houkunlin

Got it, thanks @wilkinsona