A M
A M

Reputation: 136

integrating jsf2.1 Spring 4

As title is saying I want to integrate Spring with JSF and aslo with Spring Security... The problem that Im having now is that I can't run the index page when i put on web.xml org.springframework.web.context.ContextLoaderListener even though I have org.springframework.web.jsf.el.SpringBeanFacesELRe solver declared in faces-config.xml. this the stack :

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

and this is 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>

Upvotes: 0

Views: 796

Answers (1)

kolossus
kolossus

Reputation: 20691

The Problem

This is not necessarily a JSF/Spring problem as it is an SLF4J library incompatibility issue. The warning signs are there:

  1. First there's the SLF4J warning:

    SLF4J: Class path contains multiple SLF4J bindings.
    
  2. Then there's the log output showing the location of the conflicting 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]
    
  3. SL4J automatically selects a binding

    Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
    
  4. Then the warning/error that breaks everything:

    SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
    
  5. Then there's the context-loader listener error that follows, as a result of the previous 2 warnings:

    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
    

The incompatibility is between the 1.5.8 version of your SLF4J binding (slf4j-jdk14-1.5.8.jar) and your version of the SLF4J api. Your version of SLF4J-api (1.6 in your case) must match the version of the selected binding.


To Solve

You need to either step down your version of the SLF4J api to 1.5.8. or update the version of your binding to 1.6

Upvotes: 1

Related Questions