Struts 2 + Spring + Hibernate integration example

In this tutorial, it shows the integration between “Struts2 + Spring + Hibernate“. Make sure you check the following tutorials before continue.

  1. Struts 2 + Hibernate integration example
  2. Struts 2 + Spring integration example
  3. Struts 1.x + Spring + Hibernate integration example

See the summary of integration steps :

  1. Get all the dependency libraries (a lot).
  2. Register Spring’s ContextLoaderListener to integrate Struts 2 and Spring.
  3. Use Spring’s LocalSessionFactoryBean to integrate Spring and Hibernate.
  4. Done, all connected.

See the relationship :

Struts 2 <-- (ContextLoaderListener) --> Spring <-- (LocalSessionFactoryBean) --> Hibernate
This will be a very long tutorial with little explanation, make sure you check the above 3 articles for details explanation.

Tutorials Start…

It will going to create a customer page, with add customer and list customer function. Front end is using Struts 2 to display, Spring as the dependency injection engine, and Hibernate to doing the database operation. Let start…

1. Project structure

Project folder structure.

Struts2 Spring Hibernate Project Structure
Struts2 Spring Hibernate Project Structure

2. MySQL table script

Customer’s table script.

DROP TABLE IF EXISTS `mkyong`.`customer`;
CREATE TABLE  `mkyong`.`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;

3.Dependency libraries

This tutorials request many dependency libraries.

Struts 2…

        <!-- Struts 2 -->
        <dependency>
	    <groupId>org.apache.struts</groupId>
	    <artifactId>struts2-core</artifactId>
	    <version>2.1.8</version>
        </dependency>
	<!-- Struts 2 + Spring plugins -->
	<dependency>
            <groupId>org.apache.struts</groupId>
	    <artifactId>struts2-spring-plugin</artifactId>
	    <version>2.1.8</version>
        </dependency>

MySQL…

        <!-- MySQL database driver -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.9</version>
	</dependency>

Spring…

    <!-- Spring framework --> 
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring</artifactId>
		<version>2.5.6</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>2.5.6</version>
	</dependency>

Hibernate…

    <!-- Hibernate core -->
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate</artifactId>
		<version>3.2.7.ga</version>
	</dependency>
 
	<!-- Hibernate core library dependency start -->
	<dependency>
		<groupId>dom4j</groupId>
		<artifactId>dom4j</artifactId>
		<version>1.6.1</version>
	</dependency>
 
	<dependency>
		<groupId>commons-logging</groupId>
		<artifactId>commons-logging</artifactId>
		<version>1.1.1</version>
	</dependency>
 
	<dependency>
		<groupId>commons-collections</groupId>
		<artifactId>commons-collections</artifactId>
		<version>3.2.1</version>
	</dependency>
 
	<dependency>
		<groupId>cglib</groupId>
		<artifactId>cglib</artifactId>
		<version>2.2</version>
	</dependency>
	<!-- Hibernate core library dependency end -->
 
	<!-- Hibernate query library dependency start -->
	<dependency>
		<groupId>antlr</groupId>
		<artifactId>antlr</artifactId>
		<version>2.7.7</version>
	</dependency>
	<!-- Hibernate query library dependency end -->

4. Hibernate…

Only the model and mapping files are required, because Spring will handle the Hibernate configuration.

Customer.java – Create a class for customer table.

package com.mkyong.customer.model;
 
import java.util.Date;
 
public class Customer implements java.io.Serializable {
 
	private Long customerId;
	private String name;
	private String address;
	private Date createdDate;
 
	//getter and setter methods
}

Customer.hbm.xml – Hibernate mapping file for customer.

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 20 Julai 2010 11:40:18 AM by Hibernate Tools 3.2.5.Beta -->
<hibernate-mapping>
    <class name="com.mkyong.customer.model.Customer" 
		table="customer" catalog="mkyong">
        <id name="customerId" type="java.lang.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>

5. Struts 2…

Implements the Bo and DAO design pattern. All the Bo and DAO will be DI by Spring in the Spring bean configuration file. In the DAO, make it extends Spring’s HibernateDaoSupport to integrate Spring and Hibernate integration.

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> listCustomer();
 
}

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;
	//DI via Spring
	public void setCustomerDAO(CustomerDAO customerDAO) {
		this.customerDAO = customerDAO;
	}
 
	//call DAO to save customer
	public void addCustomer(Customer customer){
		customerDAO.addCustomer(customer);
	}
 
	//call DAO to return customers
	public List<Customer> listCustomer(){
		return customerDAO.listCustomer();
	}
}

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> listCustomer();	
 
}

CustomerDAOImpl.java

package com.mkyong.customer.dao.impl;
 
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.mkyong.customer.dao.CustomerDAO;
import com.mkyong.customer.model.Customer;
 
public class CustomerDAOImpl extends HibernateDaoSupport 
    implements CustomerDAO{
 
	//add the customer
	public void addCustomer(Customer customer){
		getHibernateTemplate().save(customer);
	}
 
	//return all the customers in list
	public List<Customer> listCustomer(){
		return getHibernateTemplate().find("from Customer");		
	}
 
}

CustomerAction.java – The Struts2 action is no longer need to extends the ActionSupport, Spring will handle it.

package com.mkyong.customer.action;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import com.mkyong.customer.bo.CustomerBo;
import com.mkyong.customer.model.Customer;
import com.opensymphony.xwork2.ModelDriven;
 
public class CustomerAction implements ModelDriven{
 
	Customer customer = new Customer();
	List<Customer> customerList = new ArrayList<Customer>();
 
	CustomerBo customerBo;
	//DI via Spring
	public void setCustomerBo(CustomerBo customerBo) {
		this.customerBo = customerBo;
	}
 
	public Object getModel() {
		return customer;
	}
 
	public List<Customer> getCustomerList() {
		return customerList;
	}
 
	public void setCustomerList(List<Customer> customerList) {
		this.customerList = customerList;
	}
 
	//save customer
	public String addCustomer() throws Exception{
 
		//save it
		customer.setCreatedDate(new Date());
		customerBo.addCustomer(customer);
 
		//reload the customer list
		customerList = null;
		customerList = customerBo.listCustomer();
 
		return "success";
 
	}
 
	//list all customers
	public String listCustomer() throws Exception{
 
		customerList = customerBo.listCustomer();
 
		return "success";
 
	}
 
}

6. Spring…

Almost all the configuration is done here, at all, Spring is specialized in integration work :).

CustomerBean.xml – Declare the Spring’s beans : Action, BO and DAO.

<?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="customerAction" class="com.mkyong.customer.action.CustomerAction">
		<property name="customerBo" ref="customerBo" />	
	</bean>
 
	<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>

database.properties – Declare the database details.

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mkyong
jdbc.username=root
jdbc.password=password

DataSource.xml – Create a datasource bean.

<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/properties/database.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>

HibernateSessionFactory.xml – Create a sessionFactory bean to integrate Spring and Hibernate.

<?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>

SpringBeans.xml – Create a core Spring’s bean configuration file, act as the central bean management.

<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="config/spring/DataSource.xml"/>
	<import resource="config/spring/HibernateSessionFactory.xml"/>
 
	<!-- Beans Declaration -->
	<import resource="com/mkyong/customer/spring/CustomerBean.xml"/>
 
</beans>

7. JSP page

JSP page to display the element with Struts 2 tags.

customer.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
</head>
 
<body>
<h1>Struts 2 + Spring + Hibernate integration example</h1>
 
<h2>Add Customer</h2>
<s:form action="addCustomerAction" >
  <s:textfield name="name" label="Name" value="" />
  <s:textarea name="address" label="Address" value="" cols="50" rows="5" />
  <s:submit />
</s:form>
 
<h2>All Customers</h2>
 
<s:if test="customerList.size() > 0">
<table border="1px" cellpadding="8px">
	<tr>
		<th>Customer Id</th>
		<th>Name</th>
		<th>Address</th>
		<th>Created Date</th>
	</tr>
	<s:iterator value="customerList" status="userStatus">
		<tr>
			<td><s:property value="customerId" /></td>
			<td><s:property value="name" /></td>
			<td><s:property value="address" /></td>
			<td><s:date name="createdDate" format="dd/MM/yyyy" /></td>
		</tr>
	</s:iterator>
</table>
</s:if>
<br/>
<br/>
 
</body>
</html>

8. struts.xml

Link it all ~

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
 
<struts>
 	<constant name="struts.devMode" value="true" />
 
	<package name="default" namespace="/" extends="struts-default">
 
		<action name="addCustomerAction" 
			class="customerAction" method="addCustomer" >
		    <result name="success">pages/customer.jsp</result>
		</action>
 
		<action name="listCustomerAction"
			class="customerAction" method="listCustomer" >
		    <result name="success">pages/customer.jsp</result>
		</action>
 
	</package>
 
</struts>

9. Struts 2 + Spring

To integrate Struts 2 and Spring, just register the ContextLoaderListener listener class, define a “contextConfigLocation” parameter to ask Spring container to parse the “SpringBeans.xml” instead of the default “applicationContext.xml“.

web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
 
<web-app>
  <display-name>Struts 2 Web Application</display-name>
 
  <filter>
	<filter-name>struts2</filter-name>
	<filter-class>
	  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
	</filter-class>
  </filter>
 
  <filter-mapping>
	<filter-name>struts2</filter-name>
	<url-pattern>/*</url-pattern>
  </filter-mapping>
 
  <context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/classes/SpringBeans.xml</param-value>
  </context-param>
 
  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
 
</web-app>

10. Demo

Test it : http://localhost:8080/Struts2Example/listCustomerAction.action

Struts2 Spring Hibernate Example
Struts2 Spring Hibernate Example

Reference

  1. Struts 2 + Hibernate integration example
  2. Struts 2 + Spring integration example
  3. Struts 2 + Hibernate example with Full Hibernate Plugin
  4. Struts 1.x + Spring + Hibernate integration example
Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Pingback: read more()

  • Pingback: cheap car insurance()

  • Pingback: water ionizer loans()

  • Pingback: pay per day loans plan()

  • Pingback: pay per day loan plans()

  • Pingback: Google()

  • Pingback: water ionizer()

  • Pingback: electrician salary range()

  • Pingback: electrical licensing requirements()

  • Pingback: house blue()

  • Pingback: zak?ad szklarski piotrk√≥w trybunalski()

  • Pingback: alkaline water brands()

  • Pingback: a locksmith naples florida()

  • Pingback: journeyman electrical jobs()

  • Pingback: water ionizer()

  • Pingback: car parking()

  • Pingback: water ionizer()

  • Pingback: alkaline water machine()

  • Pingback: sms laan nu()

  • Pingback: parking()

  • Pingback: youporn()

  • Pingback: lan penge nu 18 ar()

  • Pingback: lan penge nu uden sikkerhed()

  • Pingback: DIRECTV channels()

  • Pingback: get satellite tv()

  • Pingback: watch movies online()

  • Pingback: weight loss()

  • Pingback: Blue Coaster33()

  • vicky

    Can you provide me the working code sample with latest version of struts ,spring and hibernate combination?

    appreciate your quick response.

    Thanks in advance.

  • tareq

    Dear mkyong,

    It’s a good work, but I am facing a issue when I am starting Apache Tomcat from Netbeans, please see below error message from Apache Tomcat Log:

    Oct 9, 2013 5:14:57 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    Oct 9, 2013 5:14:59 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 ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/classes/config/spring/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:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    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)
    … 23 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)
    … 36 more
    Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V
    at net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:47)
    at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
    at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
    at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
    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)
    … 41 more
    Oct 9, 2013 5:14:59 PM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext

    Can you please let me know the fix of this issue.

    Info: I have already resolved following issue “Missing artifact javax.transaction:jta:jar:1.0.1B” which I was getting at the time of building maven project.

    Thank you.

    -Tareq

  • Patty

    I am getting an error : Missing artifact javax.transaction:jta:jar:1.0.1B – do you know how can I resolve this. I just changed the versions to include latest libraries and made a progress only upto creating the pom.xml

  • Pingback: Missing artifact javax.transaction:jta:jar:1.0.1B | BlogoSfera()

  • Puneet Pant

    Some Jars can not be distributed even by:
    http://www.ibiblio.org/maven2
    So download it from Oracle/sun and install with options
    -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar

  • Bob

    Could you provide the list of jar files please?

    I did download your source code but can not run correctly because of build path:(
    Thanks very much !

  • Thanh

    If I use sql instead of mysql, how can i change the hibernate.properties?

    Thanks!

  • Albano

    As usual a good example but, there is a behaviour that scares me: if you refresh the page, the last submitted values are inserted again.

  • Huynh Thanh Toan

    Although I follow your step but I can not run it
    .
    Please help me !!!
    .
    Thankss !!!

  • http://sns.huangyidong.com/?L=blogs.blog&article=420 xl twin mattress topper

    Attractive section of content. I just stumbled upon your site
    and in accession capital to assert that I acquire actually enjoyed account your blog posts.
    Anyway I will be subscribing to your feeds and even I achievement you
    access consistently quickly.

  • http://wiki.jpmoz.net/%E5%88%A9%E7%94%A8%E8%80%85:RuthTrout Sadye

    I was suggested this website by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem.
    You are incredible! Thanks!

  • marius

    Hi,
    Can this project be used with annotations in spring and hibernate or do I have to change dependencies ?
    Tks,
    Mariu

  • Tran Van Dung

    Hi,

    I’m integrated tiles 2 into Struts2 + Spring + Hibernate project. However it doesn’t work.

    Please help me.

    Thanks

  • http://none El Houcine

    Hi,

    It’s a good work, but I want to create the project structure by myself on eclipse, so I want to know all steps that you are followed to create the project structure.

    Thanks,

  • y

    [ERROR] Failed to execute goal on project Struts2Example: Could not resolve dependencies for project
    com.mkyong.common:Struts2Example:war:com.mkyong.common: Failure to find javax.transaction:jta:jar:1
    .0.1B in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not
    be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

    [ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a g
    oal in the format : or :[:
    ]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, g
    enerate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-
    sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test,
    prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, ins
    tall, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
    org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. Yo
    u must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, ini
    tialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-
    classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resource
    s, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integra
    tion-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, s
    ite, post-site, site-deploy.
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:104)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

    If you are literate in Chinese, please reply to Chinese, thank you.

  • Hamza

    Hi,

    if you want to use both files. hbm and annotated classes, how to make when creating “session factory” to use the “AnnotationSessionFactoryBean” and “LocalSessionFactoryBean”.

    Tks