正如标题所说,我想将Spring与JSF以及Spring Security集成在一起…我现在的问题是,我不能运行索引页时,我把web.xml org.springframework.web.context.ContextLoaderListener尽管我在faces-config.xml中声明了org.springframework.web.jsf.el.SpringBeanFacesELRe解析器。这是堆栈:
mai 11, 2014 5:03:55 PM org.apache.catalina.core.AprLifecycleListener init
Infos: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:Program FilesJavajre7bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;D:appAymanproduct11.2.0dbhome_1bin;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Files7-Zip;.
mai 11, 2014 5:03:55 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
Avertissement: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:monProjet' did not find a matching property.
mai 11, 2014 5:03:55 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["http-bio-5050"]
mai 11, 2014 5:03:55 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["ajp-bio-8009"]
mai 11, 2014 5:03:55 PM org.apache.catalina.startup.Catalina load
Infos: Initialization processed in 361 ms
mai 11, 2014 5:03:55 PM org.apache.catalina.core.StandardService startInternal
Infos: Démarrage du service Catalina
mai 11, 2014 5:03:55 PM org.apache.catalina.core.StandardEngine startInternal
Infos: Starting Servlet Engine: Apache Tomcat/7.0.53
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Ayman/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/monProjet/WEB-INF/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Ayman/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/monProjet/WEB-INF/lib/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
mai 11, 2014 5:03:59 PM org.apache.catalina.core.ApplicationContext log
Infos: Initializing Spring root WebApplicationContext
mai 11, 2014 5:03:59 PM org.apache.catalina.core.StandardContext listenerStart
Grave: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
java.lang.AbstractMethodError: org.slf4j.impl.JDK14LoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:194)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
mai 11, 2014 5:03:59 PM com.sun.faces.config.ConfigureListener contextInitialized
Infos: Initialisation de Mojarra 2.2.2 ( 20130809-1625 https://svn.java.net/svn/mojarra~svn/tags/2.2.2@12376) pour le contexte «/monProjet»
mai 11, 2014 5:03:59 PM com.sun.faces.spi.InjectionProviderFactory createInstance
Infos: JSF1048 : Présence d’annotations PostConstruct/PreDestroy Les méthodes de beans gérés marquées avec ces annotations auront des annotations dites traitées.
mai 11, 2014 5:03:59 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
Infos: Running on PrimeFaces 3.5
mai 11, 2014 5:03:59 PM org.apache.catalina.core.StandardContext startInternal
Grave: Error listenerStart
mai 11, 2014 5:04:00 PM org.apache.catalina.core.StandardContext startInternal
Grave: Erreur de démarrage du contexte [/monProjet] suite aux erreurs précédentes
mai 11, 2014 5:04:00 PM org.apache.catalina.core.ApplicationContext log
Infos: Closing Spring root WebApplicationContext
mai 11, 2014 5:04:00 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["http-bio-5050"]
mai 11, 2014 5:04:00 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-bio-8009"]
mai 11, 2014 5:04:00 PM org.apache.catalina.startup.Catalina start
Infos: Server startup in 4527 ms
这是web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<description>generated-servlet</description>
<servlet-name>Final Servlet</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- JSF Mapping -->
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
问题
这不一定是JSF/Spring的问题,因为它是一个SLF4J库不兼容的问题。警告标志在那里:
-
首先是SLF4J警告:
SLF4J: Class path contains multiple SLF4J bindings.
-
然后是显示冲突库位置的日志输出:
SLF4J: Found binding in [jar:file:/C:/Users/Ayman/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/monProjet/WEB-INF/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/Ayman/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/monProjet/WEB-INF/lib/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
-
SL4J自动选择绑定
Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
-
然后是破坏一切的警告/错误:
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
-
接下来是上下文加载器侦听器错误,这是前面两个警告的结果:
Grave: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener java.lang.AbstractMethodError: org.slf4j.impl.JDK14LoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
SLF4J绑定(slf4j-jdk14-1.5.8.jar
)的1.5.8版本与SLF4J api的版本之间存在不兼容性。您的SLF4J-api版本(在您的示例中为1.6)必须与所选绑定的版本匹配。
解决
您需要将SLF4J api的版本降级到1.5.8。或者将绑定版本更新为1.6