我正在尝试从 JBoss 7.1.1 上的 Java EE 5 教程中部署 Duke's Bank 示例。我只使用(未更改)源代码和用于部署的标准 XML 配置文件,这里的部分练习是看看我如何构建我自己的基于 JSP 的项目。
我得到的异常如下:
ERROR [[jsp]] Servlet.service() for servlet jsp threw exception: java.lang.NullPointerException
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1858) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.apache.jsp.main_jsp._jspx_meth_f_005fview_005f0(main_jsp.java:99)
at org.apache.jsp.main_jsp._jspService(main_jsp.java:76)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [jbossweb-7.0.13.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [jbossweb-7.0.13.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]
我没有给出任何 JBoss 配置文件,WAR 的 WEB-INF 部分如下所示:
$ jar tvf build/lib/dukebank-web.war
0 Sat Dec 15 22:00:12 GMT 2012 META-INF/
123 Sat Dec 15 22:00:10 GMT 2012 META-INF/MANIFEST.MF
0 Sat Dec 15 22:00:12 GMT 2012 WEB-INF/
2514 Fri Dec 14 14:29:20 GMT 2012 WEB-INF/web.xml
1348 Sat Dec 15 08:19:46 GMT 2012 WEB-INF/dukesBank.tld
7245 Sat Dec 15 08:19:46 GMT 2012 WEB-INF/faces-config.xml
2153 Sat Dec 15 08:19:46 GMT 2012 WEB-INF/tutorial-template.tld
0 Sat Dec 15 22:00:12 GMT 2012 WEB-INF/classes/...
导致此问题的 JSP 文件 (main.jsp) 是:
<f:view>
<h:form>
<jsp:include page="/template/template.jsp"/>
<center>
<h3><h:outputText value="#{bundle.Welcome}"/></h3>
</center>
</h:form>
</f:view>
它包括的模板文件:
<%@ taglib uri="/WEB-INF/tutorial-template.tld" prefix="tt" %>
<%@ page errorPage="/template/errorpage.jsp" %>
<%@ include file="/template/screendefinitions.jspf" %>
<html>
<head>
<title>
<tt:insert definition="bank" parameter="title"/>
</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body bgcolor="#ffffff">
<tt:insert definition="bank" parameter="banner"/>
<tt:insert definition="bank" parameter="links"/>
</body>
</html>
我将不再处理任何文件,因为正如我在开始时所说的那样,我没有更改任何我使用过的文件。
非常感谢您的帮助,史蒂夫