I'm using
- Jetty 9 embedded.
- Maven
- Java 1.7
- JSTL
When I run my app in Eclipse and browse to my webpage which contains JSTL tags it works fine. When I bundle it in an executable jar and run from cmd prompt I get
org.apache.jasper.JasperException: /jsp/pcReport.jsp(4,62) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
My Dependencies
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.0.6.v20130930</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-glassfish</artifactId>
<version>2.1.v20100127</version>
</dependency>
My Plugins
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>com.pricemon.server.Main</mainClass>
<classpathPrefix>webapp/WEB-INF/lib/</classpathPrefix>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>etc/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5">
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
I've got my JSTL jar under WEB-INF/lib which is on my Manifest classpath
I just cant figure out why this works when run under eclipse but wont work when run from executable jar. I've also tried manually adding to classpath when launching with no effect
java -classpath ./jstl-1.2.jar -jar app.jar
Am I missing something obvious!?
You should use:
Instead of:
I also meet same problem but it was blown after I make that change.
You have a conflicting / duplicate artifact for JSTL.
Simplify your dependencies.
You can see that we don't use the JSTL artifact and org.mortbay.jetty provided jsp support level.
Jetty has provided a meta dependency to pull in the artifacts to support JSP on the same version of Jetty as your jetty-webapp artifact.
I've run into the same problem but found no answer recently. I had to debug glassfish code to solve it. I hope the following explanation can help others.
About dependencies, to run with JSP with glassfish you will need:
The reason why your embedded Jetty could not load core even if you have a jar of JSLT 1.2 (propably
javax.servlet.jsp.jstl.jar
from glassfish) is because of TldScanner class including in glassfish jars for JSP. To be clear this class has some static like:And it would not load TLD in the JAR because of the block in
There is no way it's gonna load your TLD if the url is "http://java.sun.com/jsp/jstl/core" and it is stored in a local jar. To make it NOT LOCAL, the application must be loaded by a class loader whose parent contains the JSTL jar. In short, you need to modify code to initialize
WebAppContext
as something like:If this does not help, I'd like to learn how you embed Jetty in you application.