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 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
<?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