Equinox中的Jasper - 不解析jstl核心uri

时间:2009-04-03 09:54:56

标签: spring jstl osgi equinox

我目前正在使用Spring研究OSGi,并研究了Pro Spring Dynamic Modules for OSGi中的几个例子。

我的示例网络应用程序有一个控制器,如:

@Controller
public class HelloWorldController {
    private HelloWorldService helloWorldService;

    @RequestMapping(method = RequestMethod.GET)
    @ModelAttribute("helloworld")
    public HelloWorld home() {
        return this.helloWorldService.find();
    }

    // injected in - spring looks up the service from OSGi
    public void setHelloWorldService(HelloWorldService helloWorldService) {
        this.helloWorldService = helloWorldService;
    }
}

视图解析器配置为:

<bean id="viewResolver"
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" 
    value="org.springframework.web.servlet.view.JstlView"/>
  <property name="prefix" value="/jsp/" />
  <property name="suffix" value=".jsp" />
</bean>

调用网址'http://localhost:8080/helloworld-web/spring/home'会导致视图jsp/home.jsp呈现,helloworld包含单个bean:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Spring DM HelloWorld</title>
</head>
<body>
<p>Results from accessing Spring-DM service bundle:</p>
<p>Message <c:out value="${helloworld.message}" /></p>
<p>Current Time: <c:out value="${helloworld.currentTime}" /></p>
<p>Model Version: <c:out value="${helloworld.modelVersion}" /></p>
</body>
</html>

但是,我看到以下stacktrace:

org.apache.jasper.JasperException: 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
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:317)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:424)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
    org.apache.jasper.compiler.Parser.parse(Parser.java:127)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:236)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:257)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1183)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:902)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

因为这是一个部署为OSGi包的WAR,所以它的WEB-INF/lib目录是完全空的。

我的理解是,OSGi版本的jasper会在单个web-app之外寻找taglib描述符和JAR吗?

有没有人见过这个?

2 个答案:

答案 0 :(得分:2)

一定是一些微妙的捆绑版本问题。我为这本书下载了example code,它使用了略有不同版本的jasper等,现在可以使用。

Spring-DM reference州:

  

Spring-DM扩展了JSP约定,通过检测bundle类路径中定义的任何taglib(导入的包或必需的包),将标签库打包为打包为WEB-INF / lib下的jar或解压缩到WEB-INF / classes下。 )。

我做过的......

答案 1 :(得分:0)

什么包含您的MANIFEST.MF(在Import-package和/或Required包中?)

Bundle-ManifestVersion: 2
Bundle-Classpath: .,
 WEB-INF/classes
Bundle-Version: 0.0.1.SNAPSHOT
Bundle-Name: iki-admin
Import-Package: javax.servlet,
 javax.servlet.http,
 javax.servlet.resources,
 [..]
 net.sf.navigator.taglib.el,
 [..]
 org.ikiproject.lib.exception,
 [..]
 org.springframework.web.servlet.tags,
 uk.ltd.getahead.dwr
Bundle-SymbolicName: org.ikiproject.admin
Web-ContextPath: iki-admin
Application-TraceLevels: *=info,org.ikiproject.*=verbose
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.springsource.javax.servlet.jsp.jstl,
 com.springsource.org.apache.taglibs.standard,
 org.springframework.security.taglibs

你也可能在jasper&amp;之后使用OSGi的apache-tomcat版本。