Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] # Unable to initiate spring boot application using Jetty 11.0.21

Hi All,

Could you please assist me where I'm doing the wrong thing?
I tried with both the jetty:run and jetty:run-war

Screenshot from 2024-07-09 11-18-55.png


[INFO] --- jetty-maven-plugin:11.0.21:run (default-cli) @ demo ---
[INFO] Configuring Jetty for project: demo
[INFO] Classes = /home/baku/Downloads/demo/target/classes
[INFO] Context path = /
[INFO] Tmp directory = /home/baku/Downloads/demo/target/tmp
[INFO] web.xml file = file:///home/baku/Downloads/demo/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /home/baku/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
[WARNING] Failed startup of context o.e.j.m.p.MavenWebAppContext@2e1b374c{/bk,[file:///home/baku/Downloads/demo/src/main/webapp/],UNAVAILABLE}{/home/baku/Downloads/demo/target/demo-0.0.1-SNAPSHOT.war}
java.lang.IllegalStateException: STARTING
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop (AbstractLifeCycle.java:128)
    at org.eclipse.jetty.servlet.ListenerHolder.doStart (ListenerHolder.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:382)
    at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1305)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:902)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart (ServletContextHandler.java:306)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:533)
    at org.eclipse.jetty.maven.plugin.MavenWebAppContext.doStart (MavenWebAppContext.java:294)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:171)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:121)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:89)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:171)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:121)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:89)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:171)
    at org.eclipse.jetty.server.Server.start (Server.java:470)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:89)
    at org.eclipse.jetty.server.Server.doStart (Server.java:415)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.maven.plugin.JettyEmbedder.doStart (JettyEmbedder.java:224)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.startJettyEmbedded (JettyRunMojo.java:97)
    at org.eclipse.jetty.maven.plugin.AbstractWebAppMojo.startJetty (AbstractWebAppMojo.java:441)
    at org.eclipse.jetty.maven.plugin.AbstractWebAppMojo.execute (AbstractWebAppMojo.java:419)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:85)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:299)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:963)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:296)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:199)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[INFO] Started ServerConnector@637c840d{HTTP/1.1, (http/1.1)}{0.0.0.0:8081}
[INFO] Started Server@161dd92a{STARTING}[11.0.21,sto=0] @2084ms
[INFO] Automatic redeployment disabled, see 'mvn jetty:help' for more redeployment options


On Mon, Jul 8, 2024 at 4:53 PM Debarshi Saha <debarshi.89@xxxxxxxxx> wrote:
Hi Jan,

Thanks for the reply, I tried the way you suggested but it ended with the same result. As per documentation for jetty:run-war goal, I made a small change in pom under configuration tag to locate the war.

Screenshot from 2024-07-08 16-51-56.png

Regards,
debarshi

On Mon, Jul 8, 2024 at 1:08 PM Jan Bartel via jetty-dev <jetty-dev@xxxxxxxxxxx> wrote:

Hi,

Firstly, you're referencing the jetty-12 documentation, but your pom.xml and the title of your email says you're using jetty-11. The correct link to the jetty 11 documentation is here: https://jetty.org/docs/jetty/11/programming-guide/maven-jetty/jetty-maven-plugin.html. It's important to follow the correct documentation for the release you are using.

As I understand it, spring boot creates an executable war file that can embed jetty, whereas running your webapp with jetty maven plugin inverts that relationship - an external jetty instance will run your war file. If your war file is pre-built, as your jetty.xml seems to imply, then you should:

a) check that it contains the required spring jars in WEB-INF/lib
b) run using the jetty:run-war goal (as you have pre-assembled your webapp)

Jan



On Mon, 8 Jul 2024 at 17:20, Debarshi Saha via jetty-dev <jetty-dev@xxxxxxxxxxx> wrote:
Hi Team,

Hope you are all doing well.

I'm here with one issue which I'm not able to fix from the past few days. It will be very helpful if I get assistance on this.

Issue Description:
  1. I've created one spring boot project (version 2.7.8) using JDK 17 and used maven jetty plugin and WAR plugin along with jetty dependency and excluded tomcat.
  2. I'm using maven jetty:run goal in order to initiate jetty using contextXML and provided the required configuration as instructed in jetty official page

  3. When I start jetty, the container is getting started however it is not initiating spring boot application. However when I'm using java -jar <WAR file absolute path>, the application get started in the embedded jetty server.

Could  you please help me with this?



[INFO] <<< jetty:11.0.21:run (default-cli) < test-compile @ demo <<<
[INFO]
[INFO]
[INFO] --- jetty:11.0.21:run (default-cli) @ demo ---
[INFO] Configuring Jetty for project: demo
[INFO] Classes = /home/baku/Downloads/demo/target/classes
[INFO] Context path = /
[INFO] Tmp directory = /home/baku/Downloads/demo/target/tmp
[INFO] web.xml file = null
[INFO] Webapp directory = /home/baku/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@6629643d{/,[file:///home/baku/Downloads/demo/src/main/webapp/],AVAILABLE}{/home/baku/Downloads/demo/src/main/webapp/demo-0.0.1-SNAPSHOT.war}
[INFO] Started ServerConnector@674184d{HTTP/1.1, (http/1.1)}{0.0.0.0:8081}
[INFO] Started Server@64f4f12{STARTING}[11.0.21,sto=0] @2711ms
[INFO] Automatic redeployment disabled, see 'mvn jetty:help' for more redeployment options


--
Regards,

Debarshi Saha
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-dev


--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD

_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-dev


--
Regards,

Debarshi Saha


--
Regards,

Debarshi Saha
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>com.example.demo.DemoApplication</param-value>
    </context-param>

    <listener>
        <!-- <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>-->
         <listener-class>org.springframework.web.context.WebApplicationContext</listener-class>
    </listener>

    <!--<filter>
        <filter-name>metricFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>metricFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>-->

    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!--<init-param>
            <param-name>contextAttribute</param-name>
            <param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
        </init-param>-->
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

</web-app>
<?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>
							<!--<webApp>
								<war>
									/home/baku/Downloads/demo/target/demo-0.0.1-SNAPSHOT.war
							    </war>
							</webApp>-->
						</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>

Back to the top