大家好:)我是JSF(2.3)和MyFaces.I的新手。我使用Eclipse。 我正在使用以下JAR:
MyFaces的-API-2.3.0.jar
MyFaces的-IMPL-2.3.0.jar
而不是Mojarra。
我的问题始终是当我启动我的tomcat服务器并运行我得到的项目时 此错误:enter image description here
我的web.xml代码:
<?xml version="1.0" encoding="UTF-8"?>
<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_3_0.xsd" version="3.0">
<display-name>myface</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>`
和我的index.xhtml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Myface Test</title>
</head>
<body>
</body>
</html>
和来自控制台的错误代码:
Apr 30, 2018 9:39:32 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:myface' did not find a matching property.
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server version: Apache Tomcat/9.0.7
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server built: Apr 3 2018 19:53:05 UTC
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server number: 9.0.7.0
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: OS Name: Windows 10
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: OS Version: 10.0
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Architecture: amd64
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Java Home: C:\Program Files\Java\jre1.8.0_161
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: JVM Version: 1.8.0_161-b12
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: JVM Vendor: Oracle Corporation
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: CATALINA_BASE: D:\Dokumente\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: CATALINA_HOME: D:\Programme\Neuer Ordner\apache-tomcat-9.0.7\apache-tomcat-9.0.7
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dcatalina.base=D:\Dokumente\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dcatalina.home=D:\Programme\Neuer Ordner\apache-tomcat-9.0.7\apache-tomcat-9.0.7
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dwtp.deploy=D:\Dokumente\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Djava.endorsed.dirs=D:\Programme\Neuer Ordner\apache-tomcat-9.0.7\apache-tomcat-9.0.7\endorsed
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dfile.encoding=Cp1252
Apr 30, 2018 9:39:32 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMATION: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_161\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_161/bin/server;C:/Program Files/Java/jre1.8.0_161/bin;C:/Program Files/Java/jre1.8.0_161/lib/amd64;C:\Program Files\ImageMagick-6.8.9-Q8;D:\ProgrammeWinAvr\bin;D:\ProgrammeWinAvr\utils\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Programme\cygwin\bin;D:\Programme\MinGW\bin;C:\Users\Beast\AppData\Local\Microsoft\WindowsApps;C:\Users\Beast\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;D:\Programme\MinGW\bin;C:\Users\Beast\AppData\Local\atom\bin;C:\Windows\System32;;.]
Apr 30, 2018 9:39:32 PM org.apache.coyote.AbstractProtocol init
INFORMATION: Initializing ProtocolHandler ["http-nio-8080"]
Apr 30, 2018 9:39:32 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMATION: Using a shared selector for servlet write/read
Apr 30, 2018 9:39:32 PM org.apache.coyote.AbstractProtocol init
INFORMATION: Initializing ProtocolHandler ["ajp-nio-8009"]
Apr 30, 2018 9:39:32 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMATION: Using a shared selector for servlet write/read
Apr 30, 2018 9:39:32 PM org.apache.catalina.startup.Catalina load
INFORMATION: Initialization processed in 469 ms
Apr 30, 2018 9:39:32 PM org.apache.catalina.core.StandardService startInternal
INFORMATION: Starting service [Catalina]
Apr 30, 2018 9:39:32 PM org.apache.catalina.core.StandardEngine startInternal
INFORMATION: Starting Servlet Engine: Apache Tomcat/9.0.7
Apr 30, 2018 9:39:34 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMATION: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Apr 30, 2018 9:39:35 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMATION: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Apr 30, 2018 9:39:35 PM org.apache.myfaces.ee.MyFacesContainerInitializer onStartup
INFORMATION: Using org.apache.myfaces.ee.MyFacesContainerInitializer
Apr 30, 2018 9:39:35 PM org.apache.myfaces.config.DefaultFacesConfigurationProvider getStandardFacesConfig
INFORMATION: Reading standard config META-INF/standard-faces-config.xml
Apr 30, 2018 9:39:35 PM org.apache.catalina.core.StandardContext listenerStart
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class [org.apache.myfaces.webapp.StartupServletContextListener]
java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl.<init>(DigesterFacesConfigUnmarshallerImpl.java:44)
at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getUnmarshaller(DefaultFacesConfigurationProvider.java:142)
at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getStandardFacesConfig(DefaultFacesConfigurationProvider.java:184)
at org.apache.myfaces.config.DefaultFacesConfigurationMerger.getFacesConfigData(DefaultFacesConfigurationMerger.java:69)
at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:603)
at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:449)
at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:70)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:181)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4602)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5066)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1292)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1121)
... 39 more
Apr 30, 2018 9:39:35 PM org.apache.catalina.core.StandardContext startInternal
SCHWERWIEGEND: One or more listeners failed to start. Full details will be found in the appropriate container log file
Apr 30, 2018 9:39:35 PM org.apache.catalina.core.StandardContext startInternal
SCHWERWIEGEND: Context [/myface] startup failed due to previous errors
Apr 30, 2018 9:39:35 PM org.apache.catalina.core.StandardContext listenerStop
SCHWERWIEGEND: Exception sending context destroyed event to listener instance of class [org.apache.myfaces.webapp.StartupServletContextListener]
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder._getFactory(FactoryFinder.java:310)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:230)
at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:169)
at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:356)
at org.apache.myfaces.webapp.AbstractFacesInitializer.destroyFaces(AbstractFacesInitializer.java:392)
at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:130)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4649)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5288)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:187)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Apr 30, 2018 9:39:35 PM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SCHWERWIEGEND: The web application [myface] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@600dfbca]) and a value of type [org.apache.myfaces.context.servlet.StartupFacesContextImpl] (value [org.apache.myfaces.context.servlet.StartupFacesContextImpl@3d1d3525]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Apr 30, 2018 9:39:35 PM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SCHWERWIEGEND: The web application [myface] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@735c49cc]) and a value of type [org.apache.myfaces.context.servlet.StartupFacesContextImpl] (value [org.apache.myfaces.context.servlet.StartupFacesContextImpl@653ddea5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Apr 30, 2018 9:39:35 PM org.apache.coyote.AbstractProtocol start
INFORMATION: Starting ProtocolHandler ["http-nio-8080"]
Apr 30, 2018 9:39:35 PM org.apache.coyote.AbstractProtocol start
INFORMATION: Starting ProtocolHandler ["ajp-nio-8009"]
Apr 30, 2018 9:39:35 PM org.apache.catalina.startup.Catalina start
INFORMATION: Server startup in 3149 ms
那我错了什么?有人有想法吗? 哦,我后来使用Myface Core来使用Myface Tomahawk。
答案 0 :(得分:0)
阅读你的筹码: 2018年4月30日下午9:39:35 org.apache.catalina.core.StandardContext listenerStart SCHWERWIEGEND:将上下文初始化事件发送到类[org.apache.myfaces.webapp.StartupServletContextListener]的侦听器实例的异常 java.lang.NoClassDefFoundError:org / apache / commons / digester / Digester
你错过了一种依赖。我建议你使用maven或其他依赖管理器和手工干扰罐进入你的应用程序。