JavaScript Page Flip Improving performance of a jsf App using page caching
Feb 05

I spent almost 2 days putting these three together to generate a test application. The beauty about this app is it dose not have any xml configuration file except of course the applicationcontext.xml for spring. And in that file also there is just the datasource defined. I thought of putting it down here in order to save somebody stumbling with the same some time.

What Does the app do?

well its just a test application. It shows how to wire everything together just using the annotations. and it also shows the Ajax functionality and the templating functionality of JSF 2.0. and it also inserts some test entity into the Database

Lets get directly dirty with the code

Lets start with the applicationContext.xml file ..

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource"
        p:driverClassName="${jdbc.driverClass}" p:password="${jdbc.password}" p:url="${jdbc.url}"
        p:username="${jdbc.username}"> </bean>
    <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
        id="sessionFactory" p:dataSource-ref="dataSource">

        <property name="annotatedClasses">
            <list>
                <value>com.test.car.Car</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value> hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.show_sql=${jdbc.showSql} </value>
        </property>
    </bean>

    <bean class="org.springframework.orm.hibernate3.HibernateTransactionManager"
        id="transactionManager" p:sessionFactory-ref="sessionFactory"/>
    <bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        id="entityManagerFactory" lazy-init="false" p:dataSource-ref="dataSource">
        <property name="persistenceUnitName" value="testsource"/>
    </bean>

    <!-- Activates annotation-based bean configuration -->
    <context:annotation-config/>

    <!-- needed is for @Configurable -->
    <context:component-scan base-package="com.test"/>
    <tx:annotation-driven/>

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:jdbc.properties"/>
    </bean>
</beans>

As you see all you have done is defined your datasource and wired it with entityManagerFactory which will be used by hibernate. All the connection properties are comming from the file jdbc.properties which is looked up from the classpath so it has to be placed inside the classes directory within WEB-INF.  The next thing to do is to add the persistance.xml in META-INF folder which looks like this

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="testsource" transaction-type="RESOURCE_LOCAL">
    	<provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <!--
             | The SQL dialect to use for this data source, use MySQL InnoDB as
             | we only use InnoDB tables for the entity beans.
             +-->
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
            <!--
             | Specify the second level query cache for hibernate.
             +-->
            <!--
             | Enable query caching availability.
             +-->
            <!-- <property name="hibernate.cache.use_query_cache" value="true"/> -->

        </properties>
    </persistence-unit>
</persistence>

As you must have noticed here we only declare the persistence-unit name which is used by spring.
And the last xml file is the faces-config.xml. i know i said just one configuration :P . here we dont define any beans or navaigation rules here we just have our resource bundle and the reslover for faces beans.

<?xml version="1.0"?>
<faces-config 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-facesconfig_2_0.xsd"
              version="2.0">
  <application>
  	<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    <resource-bundle>
      <base-name>com.test.messages</base-name>
      <var>msgs</var>
    </resource-bundle>
  </application>
</faces-config>

so now its all configured. Lets start with the entity class. It looks like this

@Entity
@Table(name="user")
public class Car implements Serializable{

@Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 private Long id;
@NotEmpty
 @Length(min=1,max=30)
 private String carName;

next is the DAOimpl class

@Repository
public class CarDaoImpl implements CarDao{

 private EntityManager entityManagerFactory;

 @PersistenceContext
 void setEntityManager(EntityManager entityManager) {
 this.entityManagerFactory = entityManager;
 }

 public void addCar(Car car){

 this.entityManagerFactory.persist(car);

}

The @Repository annotation is yet another stereotype that was introduced in Spring 2.0 itself. This annotation is used to indicate that a class functions as a repository.

then we have the spring service classes

@Service
public class CarServiceImpl implements CarService{

 private final CarDao carDao;

 @Inject
 CarServiceImpl(CarDao carDao) {
 this.carDao = carDao;
 } ...

and finally the backing bean

@ManagedBean("car")
@Scope("session")
public class CarSession {
 private Car car;

 public Car getCar() {
 return car;
 } ..

we use annotations for defining managed beans which otherwise would have been declared in ur config file so this significantly reduces your XML, but you can get rid of virtually all of it with JSF 2 through either annotations, as I’m doing for managed beans, or with convention, as is the case for JSF 2’s simplified navigation handling.
so now we have everything in palce .. the only files left are the xhtml files

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   template="/template/masterLayout.xhtml">

  <ui:define name="menuLeft">
    <!-- <ui:include src="/sections/login/menuLeft.xhtml"/>-->
  </ui:define>

  <ui:define name="content">
     <ui:include src="/sections/welcome.xhtml"/>
  </ui:define>

</ui:composition>

and the file sections/welcome.xhtml looks like this.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:util="http://java.sun.com/jsf/composite/components/util">

	<h:form id="form" prependId="false" >
    <h:panelGrid>
    <h:outputText value="#{i18n.prefs_country}"/>
            <h:selectOneListbox id="company" value="#{car.company}" size="1">
              <f:selectItems value="#{facesSupport.carModels}"/>
              <f:ajax render="model"/>
            </h:selectOneListbox>
            <h:outputText value="#{i18n.prefs_region}"/>
            <h:selectOneListbox id="model" value="#{car.model}" style="width: 180px;" size="1">
              <f:selectItems value="#{car.modelOptions}"/>
            </h:selectOneListbox>
     </h:panelGrid>
     <h:commandButton id="loginButton" value="save" action="#{car.saveCar}"/>
</h:form></html>

as you see how ajax is used to render the model drop box when ever the company box is changed.

the last thing left is the web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  version="2.5"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

	<context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/web-application-config.xml </param-value>
  </context-param>

  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <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>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>

  <session-config>
    <session-timeout>500000</session-timeout>
  </session-config>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

</web-app>

Thats it .. everything is in place. soon i will zip my test application and upload it so that its easier to go through the code..

Well if there are any questions or suggestions feel free to leave a comment

Finally got some time to create a sample application .. you can download it from here have also included spring security 3.0 into it .. so enjoy ;) ..u can just change from .zip to .war and deploy the application ..but before that dont forget to change the properties file inside /WEB-INF/config add your database connection details there... if there are any questions just write a comment ... and ya .. the source is included inside the war file ... the war file has been tested with tomcat 6 just place it on webapps .. and point ur browser to http://localhost:8080/sample/index.html ..

71 Responses to “JSF 2.0,Spring 3.0.0 and Hibernate 3.3.2GA Putting them all togeather with minimal xml configuration!”

  1. wafa says:

    hello,
    would you post the code source of your application please?
    thx

  2. Mike says:

    Hi there

    Thanks for the example code. I’ve been looking for a small sample application like yours to get started. Can you upload the whole project so it’s a little easier to follow? Would be great!

    Thanks!

  3. octaviox says:

    I also spent a lot of time trying to set up a test application using these technologies and finally, I gave in. It will be great if you add the source code in order to take a better look at it.

    thanks

  4. slawko says:

    Hi great article. I tried to follow your code and I wrote similar application but I cannot join BackingBean with Spring Bean. All injected references in Backing bean were null … Any advice ?

    Regards

  5. DeckerEgo says:

    Fantastic post! Personally haven’t been able to get things to work yet – I’m sure it’s an issue on this side of the keyboard. Looking forward to source when you get the time!

    Again, awesome stuff!

  6. manu says:

    hi,
    great post !!!
    where can i find the code source of your application please?
    thx

  7. karim says:

    Hello,
    You’re Doing a Really Great Job,
    would you post the code source of your application please?
    thank you.

  8. admin says:

    sorry guys last couple of weeks were very busy .. this week as soon as i get some time i will upload the source code ..

  9. hechteka says:

    Looks greate did you have time to zip the code yet? I’m curiouse to see your service call since my services are decoupled from the frontend.

  10. admin says:

    ahh sorry .. totally forget .. will surely upload it this weekend ..

  11. admin says:

    hi guys .. finally uploaded the sample .. u can the source is included inside the war file .. and as i wrote ..have also included spring security 3.0 ..

  12. Yves Charron says:

    Hi,
    I’m trying to run your sample application and I’m getting the following excetion:
    EVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name ’sample’ found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: java.lang.IllegalArgumentException: No persistence unit with name ’sample’ found
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainPersistenceUnitInfo(DefaultPersistenceUnitManager.java:379)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.determinePersistenceUnitInfo(LocalContainerEntityManagerFactoryBean.java:244)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:196)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
    … 27 more

    Any idea?

    Thanks,
    Yves

  13. admin says:

    persistence unit with name ’sample’ is defined in the file persistence.xml which should be present in the classpath .. in the sample.war file which i have provided, its in /WEB-INF/classes/META-INF/persistence.xml so its inside the classpath .. strange that you are getting this exception .. which server you running it on ? ..

    i tried it with tomcat-6.0.14 and tomcat-6.0.24 works with both of them

  14. Yves Charron says:

    Hi,
    Thanks for the reply. Your sample application your find when deployed directly in tomcat. My problem is that I build a eclipse project with your source and when I was deploying it was not copying the META-INF and content under the classpath. I added the following to the entityManager defination

    Now, I’m getting a weird error about problem scan jar in classpath…. Anyway, if you have change would ming building an eclipse project base on your sample app?

    Thanks a lot,
    Yves

  15. admin says:

    unpack the war file and import it in eclipse as a java project .. adjust the source path .. and write a build.xml to regenerate a war file .. and that should be it .. as the source folder (src) is inside the war everything should be fine ..

  16. kwame says:

    Nice tutorial thank you. But I would like to have the sample relative to the car management sample you treated in the tutorial instead. The sample you have posted is relative of a login user sample.
    Please can you post the exact case you treat on this web site?
    Best regards,
    Kwame

  17. admin says:

    hi, You can change the sample according to ur needs.. changing the code to include the stuff i have mentioned shouldnt be that difficult .. but still if i get time i will surely include the car sample as well ..

    Cheers!

  18. Carson says:

    Hi, great post! Did you have any trouble with your hibernate beans persisting in the view? With JSF 1.2 and Hibernate there were work arounds which required either the open session in view servlet filter, spring interceptor or the incorporation of seam (something I’d rather not do since it’s still building out support for JSF 2.0).

  19. admin says:

    Thanks .. no i dint encounter any problems with the persistence .. all u have to do is inject entitymanager in the DAO beans .. and to the methods which persists add the annotation @Transactional(readOnly = false, propagation = Propagation.REQUIRED) u can change this according to your needs there are many other attributes available for this transactional annotation…. in the next project am going to use jboss seam with EJB .. once am done with that will also write a post about it ;)

  20. Andrei says:

    Hi there, tried to deploy it but realized that I don’t have the database…

    Tried to deploy it anyway and told me:
    SEVERE: Context [/sample] startup failed due to previous errors
    13.08.2010 00:58:51 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
    SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web ap
    plication was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

    Anyway, you talk about applicationContext.xml file. But there is no such a file in the project.
    But there is a file named: web-application-config.xml

    Can you help?
    Thanks.

  21. Markus says:

    Hi,

    i would like to ask you if you can post the zipped example from above (not the sample app with Spring Security).

    Thx, Markus

  22. admin says:

    Hello Markus,

    The sample which i have provided has the same logic which i have described here ..

    Where exactly are u facing a problem ?

  23. admin says:

    hello Andrei,

    Sorry for the confusion. yes the file web-application-config.xml is the applicationContext.xml which i have mentioned here .. and about the database u just need one table user with the fields username and password ..

  24. admin says:

    may be its useful for someone who encounters the same problem

    —————————————————————

    It worked perfectly \o/
    Thanks a lot

    ;)

    ——————————————————————————
    2010/9/15 imran pariyani

    hello,

    change

    action=”add” TO action=”add?faces-redirect=true”

    ———————————————————————————————
    On Wed, Sep 15, 2010 at 2:31 PM, Raquel Arnold Rodrigues wrote:

    Hi,

    I saw your blog about the integration the spring and jsf, I am starting to move with both so I did one integration, but I have problem with URL, Can you help me?
    By anyway I describe my problem under:
    I have a page list.jsf and add.jsf.. When I click in the button to Add a element the page Add.jsf is called but the url continues with /list.jsf and when I add the element the page go back to list but the url changes to /add.jsf ¬¬
    I am using JSF 2.0, spring 3.0.1
    my controller:

    @Controller
    @Scope(”session”)
    public class ControllerTrip implements Serializable{

    public void add(ActionEvent e) {
    this.trip = (Trip) e.getComponent().getAttributes().get(”trip”);
    }

    my page list.jsf:




    ..

    Have you have a idea to solve my problem?

    Regards
    Raquel

  25. Vince says:

    Very nice post! I’m a newbie to Spring Security 3. I’m going to use JSF 2 + JPA + Spring Security 3 + MySql + Tomcat in my projects.
    Can you please post a tutorial on how to integrate JSF 2 + Spring Security 3?
    Or someone knows any step-by-step tutorials on how to integrate JSF 2 + Spring Security 3 + Tomcat out there, please give the links.

    Thank you.

  26. admin says:

    Hi Vince .. the sample which i have provided also contains Spring Security 3 .. download it and have a look at the security.xml file ..

  27. mark bellion says:

    Just wondering, can CarDaoImpl and CarServiceImpl not be the same class, with CarServiceImpl implementing the EntityManager itself, similar to the way EJB/JPA just has the Session Bean implement the EntityManager then access the Entity bean?

  28. Ben says:

    Error after error after error after error and still after 3 days it does not work.
    I finally gave up after downloading a total of 35 different JARs from Spring, Hibernate, Common and god knows where else and still at starting up Tomcat I was getting errors!

    Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean lang.NoClassDefFoundError: javax/persistence/Entity

    This was the final error I got before deciding that clearly the developers of Hibernate and Spring have no intention of ever expecting you to actually get round to developing anything with their products, rather they would prefer you to dedicate your time to just getting them working!

    Why is it everytime I find one of these examples of Spring or Hibernate I find myself spending days just trying to get the thing orking, when all I need to develop using JSF2.0 and EJB3.1 is the jsf-api.jar and javaee.jar and away I go.

  29. Ben says:

    Well got as far as this error now:-

    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: error trying to scan : file:/C:/Servers/Tomcat%207.0/webapps/sample/WEB-INF/classes/
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4323)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4780)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:557)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1124)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1047)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:542)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:355)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:313)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:293)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:996)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
    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:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
    Caused by: java.lang.RuntimeException: error trying to scan : file:/C:/Servers/Tomcat%207.0/webapps/sample/WEB-INF/classes/
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:635)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:350)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
    … 44 more
    Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\Servers\Tomcat%207.0\webapps\sample\WEB-INF\classes (The system cannot find the path specified)
    at org.jboss.util.file.JarArchiveBrowser.(JarArchiveBrowser.java:40)
    at org.jboss.util.file.ArchiveBrowser.getBrowser(ArchiveBrowser.java:37)
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:626)
    … 50 more
    Caused by: java.io.FileNotFoundException: C:\Servers\Tomcat%207.0\webapps\sample\WEB-INF\classes (The system cannot find the path specified)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.(Unknown Source)
    at java.util.zip.ZipFile.(Unknown Source)
    at org.jboss.util.file.JarArchiveBrowser.(JarArchiveBrowser.java:35)
    … 52 more

  30. Ben says:

    Wow!

    It doesn’t like Tomcat being under the folder “Tomcat 7.0″, moved it to “Tomcat7″ and it started up!

  31. admin says:

    @mark

    Yeah they both can actually be in one class .. the main purpose of differentiating them is to keep those to layers separated .. but yeah you can have the logic in one class ..

  32. admin says:

    Hi Ben,

    Glad that it finally works for you ;)

    its not good to have whitespaces in the the tomcat path .. so not good to have the folder names with whitespaces ..

    and about the first error you figured it out but for someone with the same error
    lang.NoClassDefFoundError: javax/persistence/Entity

    its coz of missing jboss-client jar .. or the ejb-persistence.jar if you using jboss .. so either one of them ..

  33. Mos says:

    Same here got the same problem running in tomcat 6 or 7. Sir can you email me the solution or correct project. thanks and more power.

  34. admin says:

    @mos

    What error are you getting .. can you paste the stacktrace here ..

  35. Mos says:

    Here’s the error.

    Oct 2, 2010 6:49:13 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: 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\jre6\bin;.;C:\WINDOWS.0\Sun\Java\bin;C:\WINDOWS.0\system32;C:\WINDOWS.0;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS.0\system32;C:\WINDOWS.0;C:\WINDOWS.0\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\GNU\GnuPG\pub;C:\Program Files\TortoiseGit\bin;C:\Program Files\Java\jdk1.6.0_18\bin;;
    Oct 2, 2010 6:49:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ’source’ to ‘org.eclipse.jst.jee.server:jsf-spring-sample’ did not find a matching property.
    Oct 2, 2010 6:49:14 PM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Oct 2, 2010 6:49:14 PM org.apache.coyote.ajp.AjpProtocol init
    INFO: Initializing Coyote AJP/1.3 on ajp-8009
    Oct 2, 2010 6:49:14 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 2182 ms
    Oct 2, 2010 6:49:14 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Oct 2, 2010 6:49:14 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
    Oct 2, 2010 6:49:15 PM org.apache.catalina.startup.TaglibUriRule body
    INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
    Oct 2, 2010 6:49:16 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
    log4j:WARN Please initialize the log4j system properly.
    Oct 2, 2010 6:49:17 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: error trying to scan : file:/C:/My%20Projects/JAVA/BDO%20Projects/GPG%20Online%20Project/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jsf-spring-sample/WEB-INF/classes/
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4323)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4780)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
    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:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
    Caused by: java.lang.RuntimeException: error trying to scan : file:/C:/My%20Projects/JAVA/BDO%20Projects/GPG%20Online%20Project/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jsf-spring-sample/WEB-INF/classes/
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:635)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:350)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
    … 32 more
    Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\My%20Projects\JAVA\BDO%20Projects\GPG%20Online%20Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jsf-spring-sample\WEB-INF\classes (The system cannot find the path specified)
    at org.jboss.util.file.JarArchiveBrowser.(JarArchiveBrowser.java:40)
    at org.jboss.util.file.ArchiveBrowser.getBrowser(ArchiveBrowser.java:37)
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:626)
    … 38 more
    Caused by: java.io.FileNotFoundException: C:\My%20Projects\JAVA\BDO%20Projects\GPG%20Online%20Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jsf-spring-sample\WEB-INF\classes (The system cannot find the path specified)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.(Unknown Source)
    at java.util.zip.ZipFile.(Unknown Source)
    at org.jboss.util.file.JarArchiveBrowser.(JarArchiveBrowser.java:35)
    … 40 more
    Oct 2, 2010 6:49:17 PM com.sun.faces.config.ConfigureListener contextInitialized
    INFO: Initializing Mojarra 2.0.2 (FCS b10) for context ‘/jsf-spring-sample’
    Oct 2, 2010 6:49:18 PM com.sun.faces.spi.InjectionProviderFactory createInstance
    INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
    Oct 2, 2010 6:49:18 PM com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor
    INFO: Monitoring jndi:/localhost/jsf-spring-sample/WEB-INF/faces-config.xml for modifications
    Oct 2, 2010 6:49:18 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Oct 2, 2010 6:49:18 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/jsf-spring-sample] startup failed due to previous errors
    Oct 2, 2010 6:49:18 PM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Oct 2, 2010 6:49:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
    SEVERE: The web application [/jsf-spring-sample] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

    THANKS for the reply.

  36. admin says:

    Hi mos,

    As the error suggests Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\My%20Projects\JAVA\BDO%20Projects\GPG%20Online%20Project\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jsf-spring-sample\WEB-INF\classes (The system cannot find the path specified)

    ITs not able to find the classes folder .. may be its coz of the white spaces in your folder name .. though am not sure .. if i were you i would place a fresh copy of tomcat under home directory (or c:/ if under windows) and just put the sample provided inside the webapps .. thats will surely start the tomcat container without any error ..

  37. Ben says:

    Cheers for this, this has been really good for helping me get started with my project which will be using JSF/Spring/Hibernate(JPA).
    I have a couple of queries about the JPA though which I’m hoping you can answer…

    Basically when I have an entity bean containing values from my DB.Table.Column, say User.users.firstname is set to “Harry”.

    1: How do I refresh the value in my Entity bean if the data in the table changes, at the moment if I change the value to say “Dave” and refresh my screen, I still see “Harry”. I have tried EM.clear(), EM.refresh(Class.class) & EM.flush() but none of them worked.

    2: Is there an easy way to check to see if the data in the table has changed since I got my bean, so that if another user(2) has updated some details, then I can throw a message to my user(1) telling them that the data they have is no longer the latest. Im guessing for this I’m going to need some king of timestamp in the table for last_updated or something and check that the value in for last_updated in the Entity is the same as the value in the table.

    Cheers for the great example!

    Ben

  38. admin says:

    Hi ben,
    Regarding the first question .. i follow this solution .. when i am doing a persist (Inserting a new entity) i do
    this.entityManager.persist(entity);
    this.entityManager.flush();
    this.entityManager.refresh(entity);

    this will insert the entity and will replace it with the one which was added and it will also have the primary key ID if the entity has it ..

    But when i am doing a update i just call

    return this.entityManager.merge(entity);
    the merge method will return the entity with the changes .. you cant do this for persisting an object as it wont give the the newly created id which is the primary key (thats my understanding .. i can also be wrong on that ..)

    about the second question .. you will have to have some versioning column in your table .. i usually use dateupdated as versioning column. there are annotations for that you can have here i use the @Version annotation.

  39. Ben says:

    Cheers for that, I think I was on a slightly wrong wavelength with the refreshing of the entity bean, I hadn’t picked up on the @Cache annotation, it was caching (obviously) the data. It would refresh in fact but only after two minutes. Removing that annotation gave me the results I was expecting.

    One final question (Hopefully) is it possible to remove the slightly annoying Interface from this app? I mean each Service implements an Interface which is injected into the Controller, is there a way to inject the Service class directly? In EJB3.1 they have removed the need for Interfaces, now you can just do @EJB YourClass yourClass;

    Cheers

    Again, great example!

  40. admin says:

    if you have cache annotation then when ever you call merge or persist the entity is also refreshed in the cache .. that is done when the transaction is flushed .. so when you call flush and refresh that should fetch you the latest version ..

    You can remove the interface then in the controller you can directly inject the service class ..
    e.g

    @Service
    public class TestServiceImpl{

    @Inject
    InjectTectServiceImpl(final TestServiceImpl serviceImpl) {

  41. Ben says:

    Injecting the class doesn’t work, get the following:-

    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean
    Unsatisfied dependency expressed through constructor argument with index 0
    No matching bean of type [TestServiceImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [TestServiceImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

  42. Wiktor says:

    Hi,

    great post! I was looking everywhere some test-project like this one. You have put zip file of this project, but as I see when I unzip this file then this project can’t be imported to eclipse. Eclipse just says that there is no project when I try import throught “Existing project into workspace”. Could you just get eclipse project?

    Best regard,
    Wiktor

  43. Raj says:

    Hi,

    This is a very good and useful article. It is really helping to start up the application development.

    Thank you very much and keep it up this kind of good work.

    Regards,
    Raj

  44. Luis says:

    cannot access javax.annotation.ManagedBean
    bad class file: /Users/Gabo/Downloads/sample/WEB-INF/lib/javax.annotation-3.0.jar(javax/annotation/ManagedBean.class)
    class file has wrong version 50.0, should be 49.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

    :’(

    ideas??

  45. Luis says:

    how to set classpath for:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/web-application-config.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name ’sample’ found

  46. Uche says:

    After I Have followed your steps,I can get the application to persist entities to the database.Secondly and unfortunately am not getting any error. my jar files(libraries) are complete.am using Tomcat 6.0.

  47. Ashish says:

    hi,
    can the above sample example be executed on JBoss As server ?
    i m desperately running this application on jboss but not successfull ?
    so can u help me out with this !!!!!

  48. Ashish says:

    Hi,

    can u please help me out with the above question ?
    one more thing i have observed in ur sample application which contains a wrong entry for url-patterns which is *.html but it should be *.xhtml as i have resolved the same.

    after every pros n cons applied i m started the application on running mode but still getting some weird error as follows :

    javax.faces.application.ViewExpiredException: viewId:/index.xhtml – View /index.xhtml could not be restored.
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:212)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:344)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:110)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:98)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:95)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:79)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:55)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:36)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:106)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:110)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:150)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

    Anybody has resolved this problem then plz do let me know ….

    Ashish

  49. Ashish says:

    can u please post ur code for com.pariyani.dao.impl.SpringCustomJdbcDaoImpl class

    Thanks In Advance
    Ashish

  50. woodwind says:

    I’m sorry that I got below error when click the “Login” button.

    “JSF1027: [/sample] The ELResolvers for JSF were not registered with the JSP container.”

    Any suggestion ?

Leave a Reply

preload preload preload