Unable to initialize spring boot app using jetty:run goal

I’ve been facing a critical issue from past one week on jetty web application deployment can any one please assist me where I’m doing the wrong stuff?

Description:

  1. I’m building a Spring Boot (version:2.7.8) web application using JDK 17 as per client requirement.

  2. In order to deploy the application, I’m using Jetty server with jetty-maven-plugin artifact (version 11.0.21)

  3. I’ve gone through the below documentation pages to configure jetty-web.xml

    https://jetty.org/docs/jetty/11/operations-guide/deploy/index.html

    https://jetty.org/docs/jetty/11/programming-guide/maven-jetty/jetty-maven-plugin.html#jetty-run-goal

Now when I’m starting jetty server using clean install and jetty:run from my IDE, the server goes up but it’s not detecting any WebApplicationInitializers on class path and due to this Spring Boot application is not getting initialized.

Logs:

[INFO] — jetty-maven-plugin:11.0.21:run (default-cli) @ demo —

[INFO] Configuring Jetty for project: demo

[INFO] Classes = /home/Downloads/demo/target/classes

[INFO] Context path = /

[INFO] Tmp directory = /home/Downloads/demo/target/tmp

[INFO] web.xml file = null

[INFO] Webapp directory = /home/Downloads/demo/src/main/webapp

[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml

[INFO] Web overrides = none

[INFO] jetty-11.0.21; built: 2024-05-14T03:19:28.958Z; git: 996cd61addad9cb033e0e3eba6fa3f0fa3dc270d; jvm 17.0.11+9-Ubuntu-122.04.1

[INFO] Session workerName=node0

[INFO] Started o.e.j.m.p.MavenWebAppContext@2e1b374c{/bk,[file:///home/Downloads/demo/src/main/webapp/],AVAILABLE}{/home/Downloads/demo/target/demo-0.0.1-SNAPSHOT.war}

[INFO] Started ServerConnector@4eeab3e{HTTP/1.1, (http/1.1)}{0.0.0.0:8081}

[INFO] Started Server@161dd92a{STARTING}[11.0.21,sto=0] @2069ms

[INFO] Automatic redeployment disabled, see ‘mvn jetty:help’ for more redeployment options

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.7.8</version>
       <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <url/>
    <licenses>
       <license/>
    </licenses>
    <developers>
       <developer/>
    </developers>
    <scm>
       <connection/>
       <developerConnection/>
       <tag/>
       <url/>
    </scm>
    <properties>
       <java.version>17</java.version>
    </properties>
    <dependencies>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
          <exclusions>
             <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
             </exclusion>
             <exclusion>
                <groupId>io.dropwizard.metrics</groupId>
                <artifactId>metrics-core</artifactId>
             </exclusion>
          </exclusions>
       </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-jetty</artifactId>
          <scope>provided</scope>
       </dependency>
       <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-text</artifactId>
          <version>1.10.0</version>
       </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-actuator</artifactId>
       </dependency>
       <dependency>
          <groupId>joda-time</groupId>
          <artifactId>joda-time</artifactId>
          <version>2.5</version>
       </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-hateoas</artifactId>
       </dependency>
       <dependency>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId>
          <optional>true</optional>
       </dependency>

       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
       </dependency>
       <dependency>
          <groupId>org.hibernate.validator</groupId>
          <artifactId>hibernate-validator</artifactId>
          <version>6.1.7.Final</version>
       </dependency>
       <dependency>
          <groupId>jakarta.servlet</groupId>
          <artifactId>jakarta.servlet-api</artifactId>
          <version>6.0.0</version>
          <scope>provided</scope>
       </dependency>
       <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>4.0.1</version>
          <scope>provided</scope>
       </dependency>

    </dependencies>

    <profiles>
       <profile>
          <id>myTest</id>
          <activation>
          </activation>
          <properties>
             <deployable.artifactId>${project.artifactId}</deployable.artifactId>
             <ojdbc.scope>compile</ojdbc.scope>
          </properties>
          <build>
             <plugins>
                <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-enforcer-plugin</artifactId>
                   <version>3.5.0</version>
                   <executions>
                      <execution>
                         <id>enforce-configuration-setup</id>
                         <goals>
                            <goal>enforce</goal>
                         </goals>
                         <configuration>
                                   <rules>
                               <requireFilesExist>
                                  <files>
                                     <file>${project.basedir}/src/main/resources</file>
                                  </files>
                               </requireFilesExist>
                            </rules>
                         </configuration>
                      </execution>
                   </executions>
                </plugin>
                <plugin>
                   <groupId>org.eclipse.jetty</groupId>
                   <artifactId>jetty-maven-plugin</artifactId>
                   <!--<version>9.4.50.v20221201</version>-->
                   <version>11.0.21</version>
                   <configuration>
                      <testClassesDirectory>${project.basedir}/target/resources</testClassesDirectory>
                      <httpConnector><port>8081</port></httpConnector>
                      <contextXml>${project.build.directory}/jetty.xml</contextXml>

                   </configuration>
                </plugin>
             </plugins>
             <resources>
                <resource>
                   <directory>src/main/webapp</directory>
                   <filtering>true</filtering>
                   <targetPath>${project.build.directory}</targetPath>
                </resource>
                <resource>
                   <directory>src/main/context</directory>
                   <filtering>true</filtering>
                   <targetPath>${project.build.directory}</targetPath>
                </resource>
                <resource>
                   <directory>src/main/resources</directory>
                   <filtering>true</filtering>
                   <targetPath>${project.build.directory}/resources</targetPath>
                </resource>
             </resources>
          </build>
       </profile>
    </profiles>

    <build>
       <plugins>
          <plugin>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-maven-plugin</artifactId>
             <configuration>
                <excludes>
                   <exclude>
                      <groupId>org.projectlombok</groupId>
                      <artifactId>lombok</artifactId>
                   </exclude>
                </excludes>
             </configuration>
          </plugin>
          <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-resources-plugin</artifactId>
             <version>3.3.0</version>
             <configuration>
                <nonFilteredFileExtensions>
                   <nonFilteredFileExtension>jks</nonFilteredFileExtension>
                </nonFilteredFileExtensions>
             </configuration>
          </plugin>
          <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-war-plugin</artifactId>
             <version>3.4.0</version>
             <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                   <manifest>
                      <mainClass>com.example.demo.DemoApplication</mainClass>
                   </manifest>
                </archive>
             </configuration>
          </plugin>
       </plugins>
    </build>

</project>

Jetty.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/bk</Set>
    <Set name="war">/home/Downloads/demo/target/demo-0.0.1-SNAPSHOT.war</Set>
    <Set name="extraClasspath">/home/Downloads/demo/target/resources</Set>
</Configure>

I tried to start spring boot application by changing different jetty version compatible with JDK 17 also added web.xml to manually provide the listener class, but application initialization is not happening. I would like to initiate spring boot application by triggering jetty server.

 <listener>
     <listener-class>org.springframework.web.context.WebApplicationContext</listener-class>
</listener>

New contributor

Debarshi Saha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật