SSH framework upgrade
Spring2.5.6 + Hibernate3.0.5 upgrade to Spring3.0.5 + Hibernate3.3
1. Introduction
The project uses the Struts1 + Spring2.5.6 + Hibernate3.0.5 framework, but the project needs to develop the Flex client. Spring 2.5.6 does not support integration with Flex. Therefore, we decided to upgrade Spring to version 3.0.5 and upgrade Spring, we found that Spring3.0.5 and Hibernate3.0.5 are incompatible, so we had to upgrade Hibernate to a later version 3.3.
2. Preparation
Download the Spring-3.0.5.jar and Hibernate-3.3.jar packages for the release version.
Http://search.maven.org/
A powerful jar package download website. You can find almost all the jar packages and source code you need.
3. Update process
1) Update jar related to Spring
Delete the original Spring jar package. The original jar package of the Project is
Spring. jar spring-beans-2.5.6.jar spring-context-2.5.6.jar spring-context-support-2.5.6.jar spring-core-2.5.6.jar spring-jdbc-2.5.6.jar spring-tx-2.5.6.jar spring-web-2.5.6.jar spring-webmvc-2.5.6.jar
Add Spring jar files for the new version of the project
Org. springframework. aop-3.0.5.RELEASE.jar org. springframework. asm-3.0.5.RELEASE.jar org. springframework. beans-3.0.5.RELEASE.jar org. springframework. context-3.0.5.RELEASE.jar org. springframework. context. support-3.0.5.RELEASE.jar org. springframework. core-3.0.5.RELEASE.jar org. springframework. expression-3.0.5.RELEASE.jar org. springframework. jdbc-3.0.5.RELEASE.jar org. springframework. orm-3.0.5.RELEASE.jar org. springframework. transaction-3.0.5.RELEASE.jar org. springframework. web. servlet-3.0.5.RELEASE.jar org. springframework. web. struts-3.0.5.RELEASE.jar org. springframework. web-3.0.5.RELEASE.jar
In addition, you need to add three jar files that Spring3.0 depends on.
Aop dependency
Aopalliance-1.0.jar aspectjweaver-1.5.3.jar
And a java bytecode processing class library
Javassist-3.9.0.GA.jar
2) Update the Spring STARTUP configuration in web. xml
If the original configuration is as follows:
Xml Code
SpringContextServlet Org. springframework. web. context. ContextLoaderServlet 1
To:
Xml Code
Org. springframework. web. context. ContextLoaderListener
3) Update the header of all XML configuration files of Spring.
Original applicationContext *. xml header
Xml Code
Xmlns =Http://www.springframework.org/schema/beans"
Xmlns: xsi =Http://www.w3.org/2001/XMLSchema-instance"
Xmlns: aop =Http://www.springframework.org/schema/aop"
Xmlns: tx =Http://www.springframework.org/schema/tx"Xmlns: context =Http://www.springframework.org/schema/context"Xsi: schemaLocation =Http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd
Http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
Http://www.springframework.org/schema/aop
>
To:
Xml Code
"1.0"Encoding =UTF-8"?>
Xmlns =Http://www.springframework.org/schema/beans"
Xmlns: xsi =Http://www.w3.org/2001/XMLSchema-instance"
Xmlns: aop =Http://www.springframework.org/schema/aop"
Xmlns: tx =Http://www.springframework.org/schema/tx"Xmlns: context =Http://www.springframework.org/schema/context"Xsi: schemaLocation =Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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>
That is, change all 2.5 in the applicationContext *. xml header to 3.0.
4) modify all files that inherit SimpleJdbcDaoSupport
If the project is not used, skip this step.
Original code:
Java code
Public class AbcDao extends SimpleJdbcDaoSupport {... (Omitted )}
To:
Java code
Public class AbcDao extends JdbcDaoSupport {... (Omitted )}
Note: SimpleJdbcDaoSupport and SimpleJdbcTemplate have been deprecated in version 3.1.2 because JdbcDaoSupport or NamedParameterJdbcDaoSupport has provided all of its functions, which can be replaced with JdbcDaoSupport or callback (derived from JdbcDaoSupport)
Reference address http://kimsoftware.iteye.com/blog/1554218
5)Upgrade the Hibernate Jar package
After the above transformation, the Spring Upgrade has been completed. You can run the web project and you will find the following exception:
Java. lang. NoClassDefFoundError: org/hibernate/context/CurrentSessionContext
This is because the Hibernate-3.0.5 version does not contain the CurrentSessionContext class, so we need to upgrade Hibernate to 3.3 (or other versions, I only tested 3.3)
Delete the original jar:
1. hibernate3.jar
2. hibernate-annotations.jar
Add a new version of jar:
1. hibernate3.jar (the package name is the same, but the actual version is different)
2. hibernate-annotations.jar
3. hibernate-commons-annotations.jar
4. hibernate-entitymanager.jar
5. hibernate-jpa-2.0-api-1.0.1.Final.jar
4. Run and Test
After the above process, the project no longer prompts errors. After running the web Project, the function of the tested project is basically normal and the upgrade is complete.
5. Summary
After the project is upgraded, the basic test is normal, but you do not know if there are any other unknown problems. Further Observation and testing are required.