views:

1211

answers:

4

I am writing a web application that runs within an embedded Jetty instance.

When I attempt to execute a JSTL statement, I receive the following exception:

org.apache.jasper.JasperException: /index.jsp(1,63) 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

I have the following jars on the classpath

  • ant-1.6.5.jar
  • ant-1.7.1.jar
  • ant-launcher-1.7.1.jar
  • core-3.1.1.jar
  • jetty-6.1.22.jar
  • jetty-util-6.1.22.jar
  • jsp-2.1-6.1.14.jar
  • jsp-api-2.1.jar
  • jstl-1.2.jar
  • servlet-api-2.5-20081211.jar
  • servlet-api-2.5-6.1.14.jar
  • standard-1.1.2.jar

My web.xml looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>  
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee h77p://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"  
    version="2.4">  
    <display-name>test</display-name>  
</web-app>

My code looks like this:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<html>  
    <body>  
        <h2>Hello World!</h2>  
        <%= new java.util.Date() %><br/>  
        ${1+2}<br/>  
        <c:out var="${5+9}"/><br/>  
    </body>  
</html>

I started my embedded Jetty server like this:

Server server = new Server(80);  
WebAppContext context = new WebAppContext("pig-1.0-SNAPSHOT.war","/");
server.addHandler(context);
server.start();

I spent the past two days experimenting with various combinations of jar files, web.xml configurations, and tag library declarations, but to no avail.

How can I get an embedded Jetty server up and running with full JSTL support?

+1  A: 
  • jstl-1.2.jar
  • standard-1.1.2.jar

This collides. Remove the standard-1.1.2.jar. You should only use it with jstl-1.1.2.jar. Since JSTL 1.2 the standard JAR has been merged into JSTL JAR.

BalusC
Good to know, thank you! However, after this change the issue persists.
fthompson
Ensure that you haven't extracted any JSTL JAR file and included under each its TLD files in the classpath or definied anything in `web.xml`. Also ensure that you haven't placed/duplicated the JSTL JAR file(s) somewhere else, e.g. in `Appserver/lib` or `JRE/lib`. To install JSTL basically all you need to do is to place the JAR file in classpath (e.g. `/WEB-INF/lib`) and declare the taglib in top of JSP file. That should be it. Really nothing more needs to be done, else it will collide somewhere.
BalusC
A: 

In your web.xml, try changing "h77p://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" to start with "http://" and see if that fixes the error.

However, that may not be the underlying cause, since I had that same error when using jetty-maven-plugin and JSTL taglib header in my JSP:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

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

I'm using an out-of-the-box Spring MVC template from SpringSource Tool Suite, so am not sure why the Maven plugin for Jetty chokes on it.

<build>
   <plugins>
      <plugin>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>jetty-maven-plugin</artifactId>
      </plugin>
   </plugins>
</build>
<repositories>
     <repository>
       <id>maven2-repository.dev.java.net</id>
       <name>Java.net Repository for Maven</name>
       <url>http://download.java.net/maven/2/&lt;/url&gt;
       <layout>default</layout>
     </repository>
</repositories>

And only javax.servlet:jstl:1.2 is listed in my POM's dependencies, since it now obsoletes taglibs:standard:1.1.2, which was a suggestion given above.

Drew
+2  A: 

Jetty 8.0, which has pushed as the default when you use jetty:run, has servlet API 3.0. As of that version of the standard, JSTL standard is supposed to be included, and these taglibs cannot be in the webapp classpath, only the standard classpath. However, 8.0.0.M0 forgot to include them.

Specifying 7.1.4.v20100610 helped for me.

bmargulies
A: 

@Drew Thanks Drew. It works.I had been googling for this and end up here.What my mistake was : I was using

                 <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>jstl</artifactId>
                     <version>1.1.2</version>
                     <scope>provided</scope>
                </dependency>

I changed it from above to

           <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
             <version>1.2</version>
             <scope>provided</scope>
        </dependency>

and it got working. Also I was using jstls dependency which I removed.

LND