正如标题所说,我想将Spring与JSF和aslo与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 Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\app\Ayman\product\11.2.0\dbhome_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\7-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>
答案 0 :(得分:1)
问题
这不一定是JSF / Spring问题,因为它是SLF4J库不兼容问题。警告标志在那里:
首先是SLF4J警告:
SLF4J: Class path contains multiple SLF4J bindings.
然后是日志输出,显示冲突的libs的位置:
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]
然后是由于之前的2个警告而出现的context-loader侦听器错误:
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
不兼容性介于1.5.8版本的SLF4J绑定(slf4j-jdk14-1.5.8.jar
)和您的SLF4J api版本之间。 Your version of SLF4J-api (1.6 in your case) must match the version of the selected binding。
解决
您需要将SLF4J api的版本降低到1.5.8。或者将绑定版本更新为1.6