4

I'm rather new to Spring boot and Maven. I have an issue when trying to run my executable .jar. My end goal is to create a docker image of the .jar so that I can deploy my app.

When I do mvn clean install I get .jar of my application but when I try to execute that .jar I get this error:

2022-12-25T13:11:48.421+02:00 ERROR 11132 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:578) ~[spring-context-6.0.2.jar!/:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at fi.jonij.portfoliobackend.PortfolioBackendApplication.main(PortfolioBackendApplication.java:13) ~[classes!/:0.0.1-SNAPSHOT]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[portfolio-backend.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[portfolio-backend.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[portfolio-backend.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[portfolio-backend.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:148) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:110) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:486) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:210) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[spring-boot-3.0.0.jar!/:3.0.0]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-3.0.0.jar!/:3.0.0]
    ... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:938) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:252) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:926) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:129) ~[spring-boot-3.0.0.jar!/:3.0.0]
    ... 21 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[tomcat-embed-core-10.1.1.jar!/:na]
    ... 29 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:938) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[tomcat-embed-core-10.1.1.jar!/:na]
    ... 29 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[tomcat-embed-core-10.1.1.jar!/:na]
    ... 37 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[tomcat-embed-core-10.1.1.jar!/:na]
    ... 37 common frames omitted
Caused by: java.lang.IllegalStateException: zip file closed
    at java.base/java.util.zip.ZipFile.ensureOpen(ZipFile.java:831) ~[na:na]
    at java.base/java.util.zip.ZipFile.getManifestName(ZipFile.java:1057) ~[na:na]
    at java.base/java.util.zip.ZipFile$1.getManifestName(ZipFile.java:1100) ~[na:na]
    at java.base/java.util.jar.JarFile.getManEntry(JarFile.java:937) ~[na:na]
    at java.base/java.util.jar.JarFile.checkForSpecialAttributes(JarFile.java:1000) ~[na:na]
    at java.base/java.util.jar.JarFile.isMultiRelease(JarFile.java:389) ~[na:na]
    at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:68) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:41) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:393) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:328) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:271) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:234) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) ~[tomcat-embed-jasper-10.1.1.jar!/:na]
    at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) ~[tomcat-embed-jasper-10.1.1.jar!/:na]
    at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:83) ~[tomcat-embed-jasper-10.1.1.jar!/:na]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5153) ~[tomcat-embed-core-10.1.1.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.1.jar!/:na]
    ... 43 common frames omitted


Process finished with exit code 1

The Application works fine when I run it with IntelliJ. The .jar runs well also if I remove dependency of tomcat-embed-jasper. However, then I can only access my spring security default login page since all my pages are JSPs and thus I need tomcat-embed-jasper to render those.

Here is my pom.xml:

    <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>3.0.0</version>
          <relativePath/> <!-- lookup parent from repository -->    </parent>    <groupId>fi.jonij</groupId>    <artifactId>portfolio-backend</artifactId>    <version>0.0.1-SNAPSHOT</version>    <name>portfolio-backend</name>    <description>portfolio-backend</description>    <properties>
          <java.version>17</java.version>    </properties>    <dependencies>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
             <version>3.0.0</version>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-security</artifactId>
             <version>3.0.0</version>
          </dependency>
          <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>2.11.0</version>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
             <version>3.0.0</version>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-rest</artifactId>
             <version>3.0.0</version>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-configuration-processor</artifactId>
             <version>3.0.0</version>
             <optional>true</optional>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-tomcat</artifactId>
             <scope>provided</scope>
          </dependency>
          <dependency>
             <groupId>org.apache.tomcat.embed</groupId>
             <artifactId>tomcat-embed-jasper</artifactId>
             <version>10.1.1</version>
             <scope>provided</scope>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-validation</artifactId>
             <version>3.0.0</version>
          </dependency>
          <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>glassfish-jstl</artifactId>
             <version>11.0.12</version>
          </dependency>
          <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <version>8.0.31</version>
          </dependency>
          <dependency>
             <groupId>org.webjars</groupId>
             <artifactId>bootstrap</artifactId>
             <version>5.2.3</version>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-devtools</artifactId>
             <version>3.0.0</version>
             <scope>runtime</scope>
             <optional>true</optional>
          </dependency>
          <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <version>3.0.0</version>
             <scope>test</scope>
          </dependency>
          <dependency>
             <groupId>org.springframework.security</groupId>
             <artifactId>spring-security-test</artifactId>
             <version>6.0.0</version>
             <scope>test</scope>
          </dependency>    </dependencies>
    
       <build>
          <plugins>
             <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
          </plugins>
          <finalName>portfolio-backend</finalName>    </build>
    
    </project>

I have already tried changing the scope of dependencies from provided to compile and vice versa. I also checked that the tomcat version is correct in both the spring-boot-starter-tomcat and the tomcat-embed-jasper from org.apache.tomcat.embed.

I have also tried different maven commands like mvn clean package and mvn -U clean install.

I also tried disabling scanning of jars with tomcat, that also broke the rendering of JSPs.

I might be missing something obvious since I'm quite new with Maven and Spring boot. I'd appreciate if someone could share an idea what might be the issue here. Thanks in advance! :)

6
  • Hi, Welcome, merry Xmas... Who added "tomcat-embed-jasper"? With what reason? Please explain also the (two, very) different jstl versions! Commented Dec 25, 2022 at 12:19
  • AFAIK, since you need JSP support you need to build war, regular spring-boot fat/executable jars do not support JSP Commented Dec 25, 2022 at 13:40
  • @xerx593 Thank you and merry Xmas to you too! tomcat-embed-jasper is needed render JSPs to my knowledge since spring-boot-starter-tomcat doesn't have it. jakarta.servlet.jsp.jstl-api was indeed not needed and I removed it. Thanks. Commented Dec 25, 2022 at 14:05
  • 1
    Spring Boot does support using JSP in an executable WAR file. This worked fine with 2.x, but appears to be a known issue with 3.0: github.com/spring-projects/spring-boot/issues/33633 Commented Jan 4, 2023 at 14:24
  • 1
    github.com/spring-projects/spring-boot/issues/33633 , wilkinsona , answer, add -Djdk.util.jar.enableMultiRelease=false , can fix the problem, java -Djdk.util.jar.enableMultiRelease=false -jar target/demo-springboot-jsp.war Commented Jan 19, 2023 at 2:07

4 Answers 4

5

I faced exactly the same problem (java -jar myWarFile.war generate the same error stack as yours). So far I didn't find a solution, just the following workaround:

  1. Unzip the war file in a folder of your own
  2. To run the application open a command line in this folder and type the following:
java org/springframework/boot/loader/WarLauncher

Also, I made the following investigations, all in vain:

  • I checked each and every jar file in the war file and none is corrupt
  • I tried different versions of Maven, same problem
  • I was able to run the application from my development environment (Eclipse) and from the command line using the following:
mvn -o spring-boot:run 
  • I tried to recreate the war file manually by using the jar command or 7zip: same problem

There's probably something wrong in the code of one of the JAR, probably one related to Spring or Tomcat.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for sharing. In my case however this won't probably be helpful since I want to create docker image. :) The tomcat-embed-jasper together with Spring Boot 3 seemed to be the issue since I got the war working using 2.4.4.
I confirm that the problem comes from tomcat-embed-jasper. I have tried different versions of jasper and Tomcat but it does not work (sorry, I cannot add comment to your other answer or upvote your answesrs, not enough reputation :) ). I hope they will correct this problem because it makes it impossible to work with JSP pages in Spring Boot 3 and Tomcat. Also, I have not tried with Jetty.
By the way, there is an existing issue for this problem on GitHub : github.com/spring-projects/spring-boot/issues/33633
@Prospero thanks for the workaround. I see on the issue the spring team are suggesting setting a system prop as a solution (which has worked for me) : java -Djdk.util.jar.enableMultiRelease=false -jar target/demo-springboot-jsp.war
Thanks @MarkUs, it works just fine by using -Djdk.util.jar.enableMultiRelease=false
2

I ended up changing my Spring Boot version to 2.4.4 since I found a guide that was trying to do the same thing as I was but it used the 2.4.4. Now I have successfully ran the war using 'java -jar portfolio-backend.war' -command.

Here is the link: https://www.baeldung.com/spring-boot-jsp

I also tried all the things in this guide without changing versions but that didn't work. I don't remember if I tried using Spring Boot 3.0.0 with the older Tomcat version in the guide, that might be worth trying if someone is tackling with this same problem.

Changing to 2.4.4 is not optimal by any means but it works for my project and this was a learning experience if nothing else.

Changing from 3.0.0 to 2.4.4 did break things like entity validation and jstl, but adding javax.servlet jstl and javax.persistence-api fixed those issues.

Here is my final pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>fi.jonij</groupId>
    <artifactId>portfolio-backend</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>portfolio-backend</name>
    <description>portfolio-backend</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <version>9.0.44</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.31</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>5.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <finalName>portfolio-backend</finalName>
    </build>

</project>

Comments

0

Add packaging war

<packaging>war</packaging>

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>3.0.1</version>
          <relativePath/> <!-- lookup parent from repository -->    
</parent>    
<groupId>fi.jonij</groupId>    
<artifactId>portfolio-backend</artifactId>  
<packaging>war</packaging>  
<version>0.0.1-SNAPSHOT</version>    
<name>portfolio-backend</name>   

Maven build

mvn clean package

Run

cd target 
java -jar portfolio-backend-0.0.1-SNAPSHOT.war

3 Comments

I added <packaging>war</packagin> to pom.xml and built using "clean package" and portfolio-backend.war appeared to the target folder. However, I still get the exactly same error message when executing "java -jar portfolio-backend.war". Thanks for the suggestion though. :)
@Joni Jansson, I am sorry, I check my test project again, My spring-boot-starter-parent version is set 2.7.6
This is a bug, I report a issue ( github.com/spring-projects/spring-boot/issues/33633 ). Then they fix ( Repair bug in Spring Boot 3.0.5 ichal6/Follow-the-money-server#43 github.com/ichal6/Follow-the-money-server/pull/43 )
0

The only thing that worked for me was setting the system property jdk.util.jar.enableMultiRelease to false.

java -Djdk.util.jar.enableMultiRelease=false -jar my-war.war

Got the hint from here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.