[help] embedding jetty with jsp [message #1732931] |
Mon, 23 May 2016 01:21 |
adeline pan Messages: 1 Registered: May 2016 |
Junior Member |
|
|
I wrote a small application recently, and I use jsp+springMVC and embed jetty, I wrote a java class to start jetty , it worked fine in Eclipse, but when I finished, I built a WAR, when I tried to run the war with: java -jar XXX.war , I got the following error:
C:\workspace\CCERTool\target>java -Xms512m -Xmx512m -XX:MaxPermSize=96m -jar CCE
RTool-0.0.1.war&
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=96m; support was removed in 8.0
2016-05-20 09:46:22.235:INFO::main: Logging initialized @245ms
war file path:file:/C:/workspace/CCERTool/target/CCERTool-0.0.1.war
2016-05-20 09:46:22.296:INFO:oejs.Server:main: jetty-9.2.z-SNAPSHOT
2016-05-20 09:46:27.905:WARN:oejw.WebAppContext:main: Failed startup of context
o.e.j.w.WebAppContext@50cbc42f{/,file:/C:/workspace/CCERTool/target/CCERTool-0.0
.1/,STARTING}{file:/C:/workspace/CCERTool/target/CCERTool-0.0.1.war}
........
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:68)
at com.thomsonreuters.ccertool.Launcher.startJetty(Launcher.java:83)
at com.thomsonreuters.ccertool.Launcher.main(Launcher.java:94)
Caused by:
java.lang.NoClassDefFoundError: org/apache/jasper/servlet/JspServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoade
Here is what I have done:
1. The relevant dependencies in pom.xml
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.2.13.v20150730</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.2.13.v20150730</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.2.13.v20150730</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.0</version>
</dependency>
<!-- 使用jstp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
2. The building configuration in pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<mainClass>com.thomsonreuters.ccertool.Launcher</mainClass>
<!-- <addClasspath>true</addClasspath> -->
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>main-class-placement</id>
<phase>prepare-package</phase>
<configuration>
<target>
<move todir="${project.build.directory}/${project.artifactId}-${project.version}/">
<fileset dir="${project.build.directory}/classes/">
<include name="**/*/Launcher.class" />
</fileset>
</move>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>jetty-classpath</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>org.eclipse.jetty,javax.servlet</includeGroupIds>
<excludes>META-INF/ECLIPSEF.SF,META-INF/ECLIPSEF.RSA,META-INF/eclipse.inf</excludes>
<outputDirectory>
${project.build.directory}/${project.artifactId}-${project.version}
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- to support compilation in linux -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<target>1.7</target>
<source>1.7</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
3. The war I built looking like this:
The class I used to start jetty is in the "com" folder, in the "org" and "javax" folder are the dependency the jetty needs, so do I also need to pack the "org/apache/jasper/servlet/JspServlet" in the root of the WAR, and are there any other dependency I need to run JSP in embed jetty?
Any help will be appreciated.
-
Attachment: war.png
(Size: 84.14KB, Downloaded 419 times)
|
|
|
Powered by
FUDForum. Page generated in 0.03511 seconds