我在Netbeans 7.4 / JDK 1.7环境中运行Tomcat 7上的简单应用程序时遇到了问题。
faces-config.xml
:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<managed-bean>
<managed-bean-name>menedzer</managed-bean-name>
<managed-bean-class>pl.helion.jeeweb.notowaniagieldowe.entity.Menedzer</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-bean>
</faces-config>
pl.helion.jeeweb.notowaniagieldowe.entity.Menedzer
:
package pl.helion.jeeweb.notowaniagieldowe.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Menedzer {
private List<Spolka> spolki;
public List<Spolka> getSpolki() {
return spolki;
}
public void setSpolki(List<Spolka> spolki) {
this.spolki = spolki;
}
public Menedzer(){
spolki = new ArrayList<Spolka>(3);
Date d = new Date();
spolki.add(new Spolka("Kocia Spółka Węglowa", "KSW", "energetyczny", 20.0, 11.1, d));
spolki.add(new Spolka("KitKompDotCom", "KKDC", "informatyczny", 90.0, 3.4, d));
spolki.add(new Spolka("Kocie Dance Studio", "KDS", "rozrywkowy", 15.0, -11.7, d));
}
}
Tomcat日志:
Using CATALINA_BASE: "c:\tomcat"
Using CATALINA_HOME: "c:\tomcat"
Using CATALINA_TMPDIR: "c:\tomcat\temp"
Using JRE_HOME: "C:\glassfish4\jdk7"
Using CLASSPATH: "c:\tomcat\bin\bootstrap.jar;c:\tomcat\bin\tomcat-juli.jar"
sty 26, 2014 11:45:20 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8.
sty 26, 2014 11:45:20 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
sty 26, 2014 11:45:21 AM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1e 11 Feb 2013)
sty 26, 2014 11:45:21 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
sty 26, 2014 11:45:21 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
sty 26, 2014 11:45:21 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1848 ms
sty 26, 2014 11:45:21 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
sty 26, 2014 11:45:21 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
sty 26, 2014 11:45:21 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\tomcat\conf\Catalina\localhost\HelloWorld.xml
sty 26, 2014 11:45:22 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\tomcat\conf\Catalina\localhost\NotowaniaGieldowe.xml
sty 26, 2014 11:45:24 AM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.2 ( 20130809-1625 https://svn.java.net/svn/mojarra~svn/tags/2.2.2@12376) for context '/NotowaniaGieldowe'
sty 26, 2014 11:45:25 AM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:760)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:349)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:663)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1642)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:758)
... 15 more
Caused by: com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:1009)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:953)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:746)
... 15 more
Caused by: java.lang.NullPointerException
at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1169)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:1000)
... 18 more
sty 26, 2014 11:45:25 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
sty 26, 2014 11:45:25 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/NotowaniaGieldowe] startup failed due to previous errors
sty 26, 2014 11:45:25 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\tomcat\conf\Catalina\localhost\rozdz_4_1.xml
sty 26, 2014 11:45:26 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\tomcat\webapps\docs
sty 26, 2014 11:45:26 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\tomcat\webapps\examples
sty 26, 2014 11:45:26 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\tomcat\webapps\host-manager
sty 26, 2014 11:45:26 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\tomcat\webapps\manager
sty 26, 2014 11:45:26 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\tomcat\webapps\ROOT
sty 26, 2014 11:45:27 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
sty 26, 2014 11:45:27 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
sty 26, 2014 11:45:27 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5265 ms
sty 26, 2014 11:45:29 AM org.apache.catalina.util.LifecycleBase stop
INFO: The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/NotowaniaGieldowe]] after stop() had already been called. The second call will be ignored.
sty 26, 2014 11:45:29 AM org.apache.catalina.startup.HostConfig deleteRedeployResources
INFO: Undeploying context [/NotowaniaGieldowe]
sty 26, 2014 11:45:29 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\tomcat\conf\Catalina\localhost\NotowaniaGieldowe.xml
sty 26, 2014 11:45:31 AM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.2 ( 20130809-1625 https://svn.java.net/svn/mojarra~svn/tags/2.2.2@12376) for context '/NotowaniaGieldowe'
sty 26, 2014 11:45:31 AM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:760)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:349)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4937)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:663)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:542)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1468)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1447)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:862)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:358)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2430)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2419)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:758)
... 46 more
Caused by: com.sun.faces.config.ConfigurationException: Unable to parse document 'jndi:/localhost/NotowaniaGieldowe/WEB-INF/faces-config.xml': null
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:1009)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:953)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:746)
... 46 more
Caused by: java.lang.NullPointerException
at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1169)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:1000)
... 49 more
sty 26, 2014 11:45:31 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
sty 26, 2014 11:45:31 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/NotowaniaGieldowe] startup failed due to previous errors
这是如何引起的?如何解决?
[编辑]:
几乎逐字节地研究后,我发现了PackMan Error,
节点<managed-bean>
未关闭,但已打开两次......
BTW。 NetBeans应该显示那种XML解析错误。
答案 0 :(得分:1)
标记<managed-bean>
未正确关闭
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<managed-bean>
<managed-bean-name>menedzer</managed-bean-name>
<managed-bean-class>pl.helion.jeeweb.notowaniagieldowe.entity.Menedzer</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>