本文介绍了在嵌入式Jetty实例上运行的JSP页面中未解析JSTL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个Web应用程序,如果我将其部署到Tomcat或Jboss的deploy文件夹中,则可以正常运行.我现在想做的就是将此应用程序嵌入到Jetty容器上.我似乎无法使其工作,因为它吐出了与JSTL标记库有关的错误.这是显示的错误:

I have a web application which works fine if i just deploy it on to the deploy folder of either Tomcat or Jboss. What i am trying to do now is to embed this application on to a Jetty container. I cant seem to get it to work as it is spitting out errors related to the JSTL tag library. Here is the error that is shown:

Problem accessing /Web/app/localTimestamp. Reason:

    /WEB-INF/views/localTimestamp.jsp(1,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

Caused by:

org.apache.jasper.JasperException: /WEB-INF/views/localTimestamp.jsp(1,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
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:172)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:431)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:240)
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:502)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:582)
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1652)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:185)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
    at org.apache.jasper.compiler.ParserController.parse(ParserController.java:145)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:212)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:575)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:485)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:537)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:271)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:98)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1157)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:927)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:575)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:485)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:519)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    at org.eclipse.jetty.server.Server.handle(Server.java:351)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:451)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:916)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:611)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
    at java.lang.Thread.run(Thread.java:619)

我不明白为什么它无法拾取jstl jar文件.这是Web应用程序的WEB-INF/lib文件夹中的jar文件

I dont understand why it is not able to pick up the jstl jar file. Here are the jar files in the WEB-INF/lib folder of the web application

   19/06/2012  14:54            62,983 activation-1.1.jar
   19/06/2012  14:53             4,467 aopalliance-1.0.jar
   19/06/2012  14:57            59,590 commons-fileupload-1.2.2.jar
   19/06/2012  14:57           163,151 commons-io-2.1.jar
   19/06/2012  14:54           207,723 commons-lang-2.1.jar
   19/06/2012  14:53            60,686 commons-logging-1.1.1.jar
   19/06/2012  14:54           104,172 jaxb-api-2.2.jar
   19/06/2012  14:54           872,831 jaxb-impl-2.2.jar
   19/06/2012  14:57           414,240 jstl-1.2.jar
   19/06/2012  14:53           367,444 log4j-1.2.14.jar
   19/06/2012  14:53            17,384 slf4j-api-1.5.2.jar
   19/06/2012  14:53             9,501 slf4j-log4j12-1.5.2.jar
   19/06/2012  14:53           331,474 spring-aop-3.1.0.RELEASE.jar
   19/06/2012  14:53            53,079 spring-asm-3.1.0.RELEASE.jar
   19/06/2012  14:53           589,253 spring-beans-3.1.0.RELEASE.jar
   19/06/2012  14:53           829,601 spring-context-3.1.0.RELEASE.jar
   19/06/2012  14:53           106,819 spring-context-support-3.1.0.RELEASE.jar
   19/06/2012  14:53           442,400 spring-core-3.1.0.RELEASE.jar
   19/06/2012  14:53           176,283 spring-expression-3.1.0.RELEASE.jar
   19/06/2012  15:04            61,379 spring-oxm-3.0.6.RELEASE.jar
   19/06/2012  14:53           246,036 spring-tx-3.1.0.RELEASE.jar
   19/06/2012  14:53           540,819 spring-web-3.1.0.RELEASE.jar
   19/06/2012  14:53           572,266 spring-webmvc-3.1.0.RELEASE.jar
   19/06/2012  14:56           493,742 spring-ws-core-2.0.3.RELEASE.jar
   19/06/2012  14:56            92,942 spring-xml-2.0.3.RELEASE.jar
   19/06/2012  14:54            23,346 stax-api-1.0-2.jar
   19/06/2012  14:56           148,522 wsdl4j-1.6.1.jar
   19/06/2012  14:54         1,229,125 xercesImpl-2.9.1.jar
   19/06/2012  14:55           109,318 xml-apis-1.0.b2.jar

这些是Jetty入门应用程序中包含的库:

And these are the libraries that are included in the Jetty starter application:

16/07/2012  17:35           117,444 javax.el-2.2.3.jar
16/07/2012  17:35            38,863 javax.el-api-2.2.4.jar
16/07/2012  17:35           545,240 javax.servlet.jsp-2.2.3.jar
16/07/2012  17:35            53,124 javax.servlet.jsp-api-2.2.1.jar
16/07/2012  14:03            21,212 jetty-continuation-8.1.0.RC5.jar
16/07/2012  14:03            93,383 jetty-http-8.1.0.RC5.jar
16/07/2012  14:03           101,433 jetty-io-8.1.0.RC5.jar
16/07/2012  14:03            86,238 jetty-security-8.1.0.RC5.jar
16/07/2012  14:03           330,266 jetty-server-8.1.0.RC5.jar
16/07/2012  14:03            95,359 jetty-servlet-8.1.0.RC5.jar
16/07/2012  14:03           268,069 jetty-util-8.1.0.RC5.jar
16/07/2012  14:03           106,926 jetty-webapp-8.1.0.RC5.jar
16/07/2012  14:03            37,919 jetty-xml-8.1.0.RC5.jar
19/06/2012  14:57           414,240 jstl-1.2.jar
19/06/2012  14:53           367,444 log4j-1.2.14.jar
17/07/2012  09:42             6,300 WebJettyServices-0.0.1-SNAPSHOT.jar
16/07/2012  14:03           210,354 servlet-api-3.0.20100224.jar
              17 File(s)      2,893,814 bytes

我认为该错误可能是由于jar文件中的冲突引起的.我尝试了以下方法,但均未成功

I think the error is probably due to a conflict in the jar files. I have tried the following with no success

  • 重建没有jstl依赖项的war文件
  • 重建了没有jstl依赖项的Jetty Starter应用程序.
  • 在没有jstl依赖项的情况下重建了两者

我现在陷入困境,因为我不知道如何进行其他测试.以下是相关的代码段.这是Jetty入门应用程序的Maven pom文件.我发现的一个大问题是,很难真正知道要使之正常工作需要哪些依赖项. search.maven.com似乎没有org.eclipse.*依赖项所需的所有jar文件.

I am now stuck as i dont know how else to test. Here are the relevant code snippets. Here is the Maven pom file for the Jetty starter application. One big problem i found is that it is very difficult to really know which dependencies are required to get this to work. search.maven.com seem to not have all the jar files required by the org.eclipse.* dependencies.

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>WebClient</artifactId>
    <groupId>com.mypackage</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <groupId>com.mypackage</groupId>
  <artifactId>WebJettyServices</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>WebJettyServices</name>
  <packaging>jar</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jetty.version>8.1.0.RC5</jetty.version>
    <log4j.version>1.2.14</log4j.version>
    <glassfish.javax.version>2.2.3</glassfish.javax.version>
    <glassfish.javax-impl.version>2.2</glassfish.javax-impl.version>
    <glassfish.javax-jstl.version>1.2.1</glassfish.javax-jstl.version>
    <glassfish.jstl.version>1.2</glassfish.jstl.version>


  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

   <!--
        <dependency>
            <groupId>org.eclipse.jetty.aggregate</groupId>
            <artifactId>jetty-all-server</artifactId>
            <version>8.1.0.RC5</version>
        </dependency>

         Jetty Webapp -->

    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
        <version>${jetty.version}</version>
    </dependency>

    <!-- JSP Support -->
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.servlet.jsp</artifactId>
        <version>${glassfish.javax.version}</version>
    </dependency>

    <!-- EL Support -->
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.el</artifactId>
        <version>${glassfish.javax.version}</version>
    </dependency>

    <!-- JSTL Support -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${glassfish.jstl.version}</version>
    </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
  </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.mypackage.jetty.WebStarter</mainClass>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

编辑

这是有问题的JSP页面

Edit

Here is the JSP page in question

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="<c:url value="/styles/btmsm.css"/>"
    type="text/css" />
<title>Local Timestamp</title>
</head>

<body>

    <div id="container" style="width: 800px">

        <div id="header" style="background-color: #EEEEBB;">
            <h1 style="margin-bottom: 0;">Local timestamp</h1>
        </div>

        <div id="content"
            style="background-color: #EEEEEE; height: 200px; width: 650px; float: left;">
            The local time is ${localTime}
        </div>
    </div>

</body>

</html>

以及web.xml文件中显示的网络应用版本

And the web app version shown in the web.xml file

<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
            http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">

如果我将war文件直接部署到Tomcat或Jboss部署文件夹中,则该应用程序确实可以工作.嵌入Jetty只是一个问题.

The application does work if i deploy the war file directly onto the Tomcat or Jboss deployment folder. It is only a problem when embedded with Jetty.

推荐答案

问题应该是您在web.xml中用web-app 2.4声明了您的应用程序,请替换为2.5或更高版本,此问题应得到解决

The problem should be that you declared your application with web-app 2.4 in your web.xml, please replace it with 2.5 or higher, this problem should be solved.

替换此:

<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
            http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">

具有:

<web-app
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="YourWebAppID"
    version="2.5">

请反馈.

这篇关于在嵌入式Jetty实例上运行的JSP页面中未解析JSTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 00:33