JSF 2.0 + Spring + Hibernate integration example
Here’s a long article to show you how to integrate JSF 2.0, Spring and Hibernate together. At the end of the article, you will create a page which display a list of the existing customer from database and a “add customer” function to allow user to add a new customer into database.
P.S In this example, we are using MySQL database and deploy to Tomcat 6 web container.
1. Project Structure
Directory structure of this example


2. Table Script
Create a customer table and insert 2 dummy records.
DROP TABLE IF EXISTS `mkyongdb`.`customer`; CREATE TABLE `mkyongdb`.`customer` ( `CUSTOMER_ID` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `NAME` VARCHAR(45) NOT NULL, `ADDRESS` VARCHAR(255) NOT NULL, `CREATED_DATE` datetime NOT NULL, PRIMARY KEY (`CUSTOMER_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; INSERT INTO mkyongdb.customer(customer_id, name, address, created_date) VALUES(1, 'mkyong1', 'address1', now()); INSERT INTO mkyongdb.customer(customer_id, name, address, created_date) VALUES(2, 'mkyong2', 'address2', now());
3. Hibernate Stuff
A model class and Hibernate mapping file for customer table.
File : Customer.java
package com.mkyong.customer.model; import java.util.Date; public class Customer{ public long customerId; public String name; public String address; public Date createdDate; //getter and setter methods }
File : Customer.hbm.xml
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.mkyong.customer.model.Customer" table="customer" catalog="mkyongdb"> <id name="customerId" type="long"> <column name="CUSTOMER_ID" /> <generator class="identity" /> </id> <property name="name" type="string"> <column name="NAME" length="45" not-null="true" /> </property> <property name="address" type="string"> <column name="ADDRESS" not-null="true" /> </property> <property name="createdDate" type="timestamp"> <column name="CREATED_DATE" length="19" not-null="true" /> </property> </class> </hibernate-mapping>
4. Spring Stuff
Spring’s BO and DAO classes for business logic and database interaction.
File : CustomerBo.java
package com.mkyong.customer.bo; import java.util.List; import com.mkyong.customer.model.Customer; public interface CustomerBo{ void addCustomer(Customer customer); List<Customer> findAllCustomer(); }
File : CustomerBoImpl.java
package com.mkyong.customer.bo.impl; import java.util.List; import com.mkyong.customer.bo.CustomerBo; import com.mkyong.customer.dao.CustomerDao; import com.mkyong.customer.model.Customer; public class CustomerBoImpl implements CustomerBo{ CustomerDao customerDao; public void setCustomerDao(CustomerDao customerDao) { this.customerDao = customerDao; } public void addCustomer(Customer customer){ customerDao.addCustomer(customer); } public List<Customer> findAllCustomer(){ return customerDao.findAllCustomer(); } }
File : CustomerDao.java
package com.mkyong.customer.dao; import java.util.List; import com.mkyong.customer.model.Customer; public interface CustomerDao{ void addCustomer(Customer customer); List<Customer> findAllCustomer(); }
File : CustomerDaoImpl.java
package com.mkyong.customer.dao.impl; import java.util.Date; import java.util.List; import com.mkyong.customer.dao.CustomerDao; import com.mkyong.customer.model.Customer; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao{ public void addCustomer(Customer customer){ customer.setCreatedDate(new Date()); getHibernateTemplate().save(customer); } public List<Customer> findAllCustomer(){ return getHibernateTemplate().find("from Customer"); } }
File : CustomerBean.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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-2.5.xsd"> <bean id="customerBo" class="com.mkyong.customer.bo.impl.CustomerBoImpl" > <property name="customerDao" ref="customerDao" /> </bean> <bean id="customerDao" class="com.mkyong.customer.dao.impl.CustomerDaoImpl" > <property name="sessionFactory" ref="sessionFactory" /> </bean> </beans>
5. Spring + Database
Configure database detail in Spring.
File : db.properties
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/mkyongdb jdbc.username=root jdbc.password=password
File : DataSource.xml
<beans xmlns="http://www.springframework.org/schema/beans" 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-2.5.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>WEB-INF/classes/config/database/db.properties</value> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> </beans>
6. Spring + Hibernate
Integrate Hibernate and Spring via LocalSessionFactoryBean.
File : HibernateSessionFactory.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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-2.5.xsd"> <!-- Hibernate session factory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource"/> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>com/mkyong/customer/hibernate/Customer.hbm.xml</value> </list> </property> </bean> </beans>
7. JSF 2.0
JSF managed bean to call Spring’s BO to add or get customer’s records from database.
File : CustomerBean.java
package com.mkyong; import java.io.Serializable; import java.util.List; import com.mkyong.customer.bo.CustomerBo; import com.mkyong.customer.model.Customer; public class CustomerBean implements Serializable{ //DI via Spring CustomerBo customerBo; public String name; public String address; //getter and setter methods public void setCustomerBo(CustomerBo customerBo) { this.customerBo = customerBo; } //get all customer data from database public List<Customer> getCustomerList(){ return customerBo.findAllCustomer(); } //add a new customer data into database public String addCustomer(){ Customer cust = new Customer(); cust.setName(getName()); cust.setAddress(getAddress()); customerBo.addCustomer(cust); clearForm(); return ""; } //clear form values private void clearForm(){ setName(""); setAddress(""); } }
A JSF page to display existing customer records via h:dataTable and a few text components to allow user to insert new customer record into database.
File : default.xhtml
<?xml version="1.0" encoding="UTF-8"?> <!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:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" > <h:head> <h:outputStylesheet library="css" name="table-style.css" /> </h:head> <h:body> <h1>JSF 2.0 + Spring + Hibernate Example</h1> <h:dataTable value="#{customer.getCustomerList()}" var="c" styleClass="order-table" headerClass="order-table-header" rowClasses="order-table-odd-row,order-table-even-row" > <h:column> <f:facet name="header"> Customer ID </f:facet> #{c.customerId} </h:column> <h:column> <f:facet name="header"> Name </f:facet> #{c.name} </h:column> <h:column> <f:facet name="header"> Address </f:facet> #{c.address} </h:column> <h:column> <f:facet name="header"> Created Date </f:facet> #{c.createdDate} </h:column> </h:dataTable> <h2>Add New Customer</h2> <h:form> <h:panelGrid columns="3"> Name : <h:inputText id="name" value="#{customer.name}" size="20" required="true" label="Name" > </h:inputText> <h:message for="name" style="color:red" /> Address : <h:inputTextarea id="address" value="#{customer.address}" cols="30" rows="10" required="true" label="Address" > </h:inputTextarea> <h:message for="address" style="color:red" /> </h:panelGrid> <h:commandButton value="Submit" action="#{customer.addCustomer()}" /> </h:form> </h:body> </html>
8. JSF 2.0 + Spring
Integrate JSF 2.0 with Spring, see detail explanation here – JSF 2.0 + Spring integration example
File : applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans" 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-2.5.xsd"> <!-- Database Configuration --> <import resource="classes/config/spring/beans/DataSource.xml"/> <import resource="classes/config/spring/beans/HibernateSessionFactory.xml"/> <!-- Beans Declaration --> <import resource="classes/com/mkyong/customer/spring/CustomerBean.xml"/> </beans>
File : faces-config.xml
<?xml version="1.0" encoding="UTF-8"?> <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> </application> <managed-bean> <managed-bean-name>customer</managed-bean-name> <managed-bean-class>com.mkyong.CustomerBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>customerBo</property-name> <value>#{customerBo}</value> </managed-property> </managed-bean> </faces-config>
File : 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>JavaServerFaces</display-name> <!-- Add Support for Spring --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> <!-- Change to "Production" when you are ready to deploy --> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <!-- Welcome page --> <welcome-file-list> <welcome-file>faces/default.xhtml</welcome-file> </welcome-file-list> <!-- JSF mapping --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Map these files with JSF --> <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>*.jsf</url-pattern> </servlet-mapping> <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> </web-app>
9. Demo
Run it, fill in the customer data and click on the “submit” button.



When I follow this tutorial and I call Dao in @PostConstruct i get
org.hibernate.HibernateException: No Session found for current thread
Do you know how to solve it?
In this line i am getting the compilation error:
<h:dataTable value="#{customer.getCustomerList()}" var="c"
Below is the error:
Multiple annotations found at this line:
- Syntax error in EL
- Expression must be a value expression but is a method
expression
MkYong can you please help to resolve this.
Below is the Error I am getting in
<h:dataTable value="#{customer.getCustomerList()}" var="c"
Multiple annotations found at this line:
- Syntax error in EL
- Expression must be a value expression but is a method
expression
Hi,
this example doesn’t work in Eclipse.
javax.servlet.ServletException: Servlet.init() for servlet Faces Servlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:800)
javax.faces.FactoryFinder.getFactory(FactoryFinder.java:302)
javax.faces.webapp.FacesServlet.init(FacesServlet.java:186)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
Can you help me how create a new Project, please?
1. File -> New -> Dynamic Web Project
Project name: JavaServerFaces
Target runtime: Apache Tomcat v. 7.0
Dynamic web module version: 3.0
Configuration: JavaServer Faces v2.0 Project
2. Which user libraries I must add? jsf-api-2.1.0-b003.jar?
Thank you
Hi,
It’s possible create an example like this one but with Hibernate Annotations? Thank’s.
Regards,
Miguel Machado
Hi friends,
can someone help me in setting up the projects . I downloaded the zip file from here and now i dont know what to do . how to use maven . and how to get dependency. I am new to maven and want to use this project for learning .I want end to end step by step process for setting up the project and run it.
Thanks
Jitendra
Hi friends,
can someone help me in setting up the projects . I downloaded the zip file from here and now i dont know what to do . how to use maven . and how to get dependency. I am new to maven and want to use this project for learning . Kindly tell me step by step process for setting up the project and run it.
Thanks
Jitendra
Thank u so much for this wonderful tutorial… Really helpful..
I recieved following error message.
Initializing…
deploy?DEFAULT=/home/manish/NetBeansProjects/JavaServerFaces/target/JavaServerFaces&name=com.mkyong.common_JavaServerFaces_war_1.0-SNAPSHOT&contextroot=/JavaServerFaces&force=true failed on GlassFish Server 3.1.2
Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/classes/config/spring/beans/HibernateSessionFactory.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException. Please see server.log for more details.
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
How can i fix this pblm?
Thank you very very much. Your web site is excellent
Hi!!.. thanks for this great tutorial, works like a charm.. just one question, when I start tomcat i get this error:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.mkyong.customer.bo.impl.CustomerBoImpl
The demo still works, but i’m just curious about the exception, and if will affect on my project using your code.
Hello,
I have finally managed to make it work.
I have a question though, I find loading of the page( select query) and insertion of records to database is quite slow, much slow than plain JDBC. What could be the reason for this? Any settings needs to be changed?
Thanks
Hi
I am following this article and I am stuck at this point
<h:dataTable value="#{customer.getCustomerList()}"
Expression must be a value expression but is a method expression
I have added jsp-api-2.1.jar and el-impl-2.2.jar in WEB-IF/lib folder, unfortunately I couldn't resolve the issue. How can I resolve this?
Thanks
Stupid question but we will creat a new JFS Project for beginning ? Please reply soon.
I mean, I don’t know how to create the project structure for jsf+spring+hibernate using maven. coz there are a lot of archetype in maven. For example, I used
mvn archetype:generate that give me a list of archetypes and I don’t know what to use.
Thank you.
No no. I dont reply for your question. I want to ask if I use eclipse to follow this example so Should I create a JSF Project or something else to do it?
How to create that project structure please?
I got this error:”file name references to “faces/default.xhtml” that does not exist in web content”. How to solve it ? Thanks!!!
In DataSource.xml, why line 9 is “WEB-INF/classes/config/database/db.properties” ?
I had import the maven project with a lots of errors, i resolved them but now i have this insurmountable problem for me:
Can u help this wretch boy?
Post your last error caused by.
i got “The import org.springframework.orm cannot be resolved” error on below file
package com.mkyong.customer.dao.impl;
import java.util.Date;
import java.util.List;
import com.mkyong.customer.dao.CustomerDao;
import com.mkyong.customer.model.Customer;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class CustomerDaoImpl extends
HibernateDaoSupport implements CustomerDao{
public void addCustomer(Customer customer){
customer.setCreatedDate(new Date());
getHibernateTemplate().save(customer);
}
public List findAllCustomer(){
return getHibernateTemplate().find(“from Customer”);
}
}
Your suggetions are excellent
Also this is not working.Why?
May I know “what” is not working?
Thank you for the example!
Have you tried the Spring 3 and JSF together without web.xml? I have tried the Spring 3 mvc based on annotation and api without web.xml. Do you think it is possible to put Spring and JSF together without web.xml?
no body want to help me to resolve the problem of the
java.lang.NullPointerException
at Beans.CustomerBean.getCustomer_list(CustomerBean.java:107)/
i’m very sadddd :((((((((((((((((( .
anyway thank u for all .
you must writing Beans.CustomerBean.Customer_list
Don’t be sad nobody knows how to solve it because it DOESN’T WORK FOR ANYONE .
@Transactional(readOnly = true)
I am getting null pointer exception in getHibernateTemplate(). Please help me to solve
Thanks
hi mkyong,
i am getting below error during run your above code.
javax.faces.view.facelets.TagAttributeException: /index.xhtml @20,8 value=”#{Customer.getCustomerList()}” Error Parsing: #{Customer.getCustomerList()}
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:401)
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:351)
at com.sun.faces.facelets.tag.jsf.ComponentRule$ValueExpressionMetadata.applyMetadata(ComponentRule.java:107)
at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:81)
at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:129)
at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:102)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.setAttributes(BehaviorsAddingComponentHandlerWrapper.java:115)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.doNewComponentActions(ComponentTagHandlerDelegateImpl.java:402)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:159)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:55)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:188)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:769)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:410)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:128)
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:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.el.ELException: Error Parsing: #{Customer.getCustomerList()}
at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:125)
at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:146)
at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:190)
at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:385)
… 36 more
Caused by: org.apache.el.parser.ParseException: Encountered “getCustomerList(” at line 1, column 12.
Was expecting:
…
at org.apache.el.parser.ELParser.generateParseException(ELParser.java:2129)
at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2009)
at org.apache.el.parser.ELParser.DotSuffix(ELParser.java:1076)
at org.apache.el.parser.ELParser.ValueSuffix(ELParser.java:1053)
at org.apache.el.parser.ELParser.Value(ELParser.java:997)
at org.apache.el.parser.ELParser.Unary(ELParser.java:967)
at org.apache.el.parser.ELParser.Multiplication(ELParser.java:730)
at org.apache.el.parser.ELParser.Math(ELParser.java:650)
at org.apache.el.parser.ELParser.Compare(ELParser.java:462)
at org.apache.el.parser.ELParser.Equality(ELParser.java:356)
at org.apache.el.parser.ELParser.And(ELParser.java:300)
at org.apache.el.parser.ELParser.Or(ELParser.java:244)
at org.apache.el.parser.ELParser.Choice(ELParser.java:198)
at org.apache.el.parser.ELParser.Expression(ELParser.java:190)
at org.apache.el.parser.ELParser.DeferredExpression(ELParser.java:128)
at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:56)
at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:93)
… 40 more
please helpppppppppppppppppppppppppppp ,realy i need help ,im waiting for your answers,thank u so much:)
Hi sara,
I think the error was cosed by writing the name of methode getCustomerList(),you must write the name of attribute or the name of list wich you want viewing in the table,i’m sorry if i’m writing english bad :p i’m just trying help you
Please use Tomcat 7 or JBoss 6. Support for El 2.2
I am having this problem:
HTTP Status 404 – /JavaServerFaces/faces/default.xhtml
type Status report
message /JavaServerFaces/faces/default.xhtml
description The requested resource (/JavaServerFaces/faces/default.xhtml) is not available.
Can someone help me ?
verify your web.xml whether the default.xhtml is there with faces of not. also verify your folder structure is exactly same as mentioned above or not.This kind of exception is common and the solution is only this thing.
I am getting the following error:
what could be wrong..????
SEVERE: Context initialization failed
java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlBeanDefinitionReader.setEnvironment(Lorg/springframework/core/env/Environment;)V
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87)
Just a question:
Which tools did you use to create all those files.
For my JSE I always just use IntelliJ and do everything in IntelliJ. But for JEE projects I have less experience especially since I always took the shortest path to a running application.
I see that a lot of files contain very similar information. The table script, the hibernate java file, the hibernate xml, the spring java and xml files. So that got me wondering, what is the most professional way to create these files, are all of them just typed out manually, or are developers supposed to generate these files with some kind of command line tool?
Eclipse IDE is my favor tool.
The hierarchy of the type CustomerDaoImpl is inconsistent.. what does it means?
Thanks in advance;)
Hi Ian,
Verify your class path settings [ ie., required jar files are configured properly
or not...]
Hello,
Thank you for the article. It has helped a lot to understand how Spring works. I am still new to this and I do not know whether I need to take control myself over DB transactions. Is transaction management already provided by Spring automatically?
hi
i got this error in my console for simple hibernate
Exception in thread “main” java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.()V from class org.hibernate.cache.EhCacheProvider
at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:124)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:180)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at CD.DBHandler.main(DBHandler.java:46)
please help me if you can
thanks
hi
i got this error in my simple hibernate
can u help me on this error ?
thanks
Hi Mkyoung ,
Need little help , can you describe us the flow control . means starting from web.xml to default.xhtml . which java class comes when ,one by one and when it read which xml file so we can understand it completely
Hi!
I downloaded an example from the site, but it does not work:
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/classes/config/spring/beans/HibernateSessionFactory.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:433)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:231)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
… 39 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
… 52 more
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type
at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
at net.sf.cglib.core.KeyFactory.(KeyFactory.java:66)
at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:188)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:128)
at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:78)
… 57 more
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
… 65 more
Jun 21, 2012 11:01:46 AM 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 ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/classes/config/spring/beans/HibernateSessionFactory.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:433)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:231)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
… 39 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
… 52 more
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type
at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
at net.sf.cglib.core.KeyFactory.(KeyFactory.java:66)
at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:188)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:128)
at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:78)
… 57 more
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
… 65 more
Help me =(
if u have problem – change version hibernate in pom.xml
my pom.xml
org.springframework
spring-webmvc
${org.springframework-version}
org.springframework
spring-orm
${org.springframework-version}
org.hibernate
hibernate-core
3.3.2.GA
org.hibernate
hibernate-annotations
3.3.1.GA
org.hibernate
hibernate-commons-annotations
3.3.0.ga
all pom file
http://paste.ubuntu.com/1004787/
nothing improvement.the same exception is coming again…
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/classes/config/spring/beans/HibernateSessionFactory.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]………..
one of those tutorial which does not function
Hello, i have this error:
18-may-2012 11:37:20 org.apache.catalina.startup.Bootstrap initClassLoaders
GRAVE: Class loader creation threw exception
java.io.IOException: El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:201)
at org.apache.catalina.startup.Bootstrap.createClassLoader(Bootstrap.java:174)
at org.apache.catalina.startup.Bootstrap.initClassLoaders(Bootstrap.java:92)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:207)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:391)
Se trataba de un error al configurar el Tomcat 6.0.
Hi Gaya,
I have the exact same error. If you solved it, please could you help me out.
I get this error message on tomcat 6.0.14:
SEVERE: Context initialization failed
Hi
Can any one help me out with this example.
I am new to spring.
i am using this in Eclipse IDE.
i just import this application to my IDE. Where i need to create the db table.
Can any one help me out clearly with this example.
I am really thankfull if any one help me this.
i am using tomcat 7.0.3
eagerly waiting for the responce.
Please menction the things what i have to do step by step.
:)
can you help mee please :( this code dosnt work
What doesn’t work?
Thank you so much for this example.
In this example you are adding one type of Objects to the data base which is Customer,
but if you have many objects which extends from one object ?
Example :
I have pilot, first officier, second officier, hostess, steward etc ..
which extends from CrewMember.
and I need to add them to my data base.
How would be the project structure in this case ?
Thank you.
I compiled the pom.xml using the command mvn compile but I am getting this error:
[ERROR] Failed to execute goal on project JavaServerFaces: Could not resolve dependencies for project com.mkyong.common:JavaServerFaces:war:1.0-SNAPSHOT: The following artifacts could not be resolved: org.springframework:spring:jar:2.5.6, org.hibernate:hibernate:jar:3.2.7.ga: Could not transfer artifact org.springframework:spring:jar:2.5.6 from/to central (http://repo1.maven.org/maven2): No response received after 60000 -> [Help 1]
Please help!
Thank you.
and now it works fine !! o_O
Sorry for the disturb ^^
I have a peoblem with #{customer.getCustomerList()} this is th error:
The function getCustomerList must be used with a prefix when a default namespace is not specified
Thank you so much for this tutorial about javaEE.
i have this error :
[ .......
mars 06, 2012 9:42:42 PM org.apache.catalina.core.StandardContext listenerStart
Grave: Erreur lors de la configuration de la classe d'écoute de l'application (application listener) org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
.........
mars 06, 2012 9:42:42 PM org.apache.catalina.core.StandardContext listenerStart
Grave: Erreur lors de la configuration de la classe d'écoute de l'application (application listener) org.springframework.web.context.request.RequestContextListener
java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
......
]
please i need your help .
i add those file jar : WEB-INF/lib : spring.jar and Mysql-connector-java .jar
Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/classes/config/spring/beans/HibernateSessionFactory.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
I found the reason: change Customer.hbm.xml:
<id name="customerId" type="long">to
<id name="customerId" type="java.lang.Long">,
<property name="name" type="string">to
<property name="name" type="java.lang.String">,
<property name="address" type="string">to
<property name="address" type="java.lang.String">Hello ranyut,
Please, could say me if you changed timestamp in createdDate too.
In other words,
change –> timestamp to java.lang.Timestamp
Thanks in advance,
Jose Ramon
I made the change, you recommended and still the same stacktrace…
I am using JDK SUN 1.7 instead of 1.6
To fix this error:
SEVERE: Error Rendering View[/index.xhtml]
javax.el.ELException: /index.xhtml @21,8 value=”#{customer.getCustomerList()}”:
Change customer to Customer in default.xhtml line 16:
value=”#{Customer.getCustomerList()}”
Do not change customer to Customer in default.xhtml line 16:(But will solve your problem. But it can not fetch your rows from database because in faces.config customerBean is defined as customer . )
It’s a BUG with eclipse :
Bug 352491 – [JSF2.0] EL 2.2 – syntax error with a method expression
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352491
Just do one thing remove List word from the default.xhtml and from that bean class also . It will fix your el bug issue
i am getting below error during run your above code.
SEVERE: Error Rendering View[/index.xhtml]
javax.el.ELException: /index.xhtml @21,8 value=”#{customer.getCustomerList()}”: java.lang.NullPointerException
java.lang.NullPointerException
at com.mkyong.CustomerBean.getCustomerList(CustomerBean.java:39)
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)
does’nt matter with the xhtml error.
You can still deploy and see the result
Hi mkyong
i am new to spring ,i have created an dynamic web project by using your example jsf+spring+hibernate ,i have followed the project structure same as in your example.but when i am running my example i am getting this exception.please help me
to get out this problem .
SEVERE: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [classes/config/spring/beans/DataSource.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [jndi:/localhost/Spring-Jsf/WEB-INF/classes/config/spring/beans/DataSource.xml]; nested exception is java.io.FileNotFoundException
Pls help, in tomcat6.0 print this error:
change to:
You need to add the following dependency pom.xml
javassist
javassist
3.12.1.GA
Then maybe u get another error related with ASM. I found the answer here:
(http://stackoverflow.com/questions/2432471/error-java-lang-nosuchmethoderror-org-objectweb-asm-classwriter-initiv)
I had the same error when initializing Spring on startup, using some different library versions, but everything worked when I got my versions in this order in the classpath (the other libraries in the cp were not important):
asm-3.1.jar
cglib-nodep-2.1_3.jar
asm-attrs-1.5.3.jar