Adding Spring and Hibernate Capabilities
In this section we will add Spring and Hibernate Capabilities to our web application. So for this, we will have to add the spring and hibernate libraries and configuration files to the web application.
So, to integrate Hibernate and Spring frameworks with JSF framework we will have to make some changes and copy jar files related with the individual frameworks.
Steps to integrate:
Adding Servlets Library
Since we are using ant build tool to compile the application, it is necessary
to make servlets api library available to ant build tool for compiling the java code.
We are
adding Servlets library to the project.
- Create a directory named libext under web-inf
directory of your application.
- Copy servletapi.jar from common\lib directory of your Tomcat into libext directory.
Adding Hibernate Libraries
Now we will download hibernate libraries and add it to the project.
- Download hibernate-3.2.4.sp1.zip or latest version from
http://www.hibernate.org/6.html.
We have downloaded hibernate-3.2.4.sp1.zip for this tutorial.
- Unzip the file.
- Copy all the jar files from hibernate-3.2.4.sp1\hibernate-3.2\lib into
lib directory of your application. (The directories hibernate-3.2.4.sp1\hibernate-3.2
may be different in your case depending on the downloaded version).
- Copy hibernate3.jar from hibernate-3.2.4.sp1\hibernate-3.2 into lib directory of your application.
Adding Spring Libraries
Our application uses spring to manage the beans, so we have to add the
spring capabilities to the application.
- Download spring-framework-2.0.5-with-dependencies.zip from
http://www.springframework.org/download.
- Extract the file.
- Copy spring.jar from spring-framework-2.0.5-with-dependencies\spring-framework-2.0.5\dist directory into lib directory of your application.
Finally here is the list of jar files in our application's lib directory:
HibernateMyfaces\WEB-INF\lib ant-1.6.5.jar ant-antlr-1.6.5.jar ant-junit-1.6.5.jar ant-launcher-1.6.5.jar ant-swing-1.6.5.jar antlr-2.7.6.jar asm-attrs.jar asm.jar c3p0-0.9.1.jar cglib-2.1.3.jar checkstyle-all.jar cleanimports.jar commons-beanutils-1.7.0.jar commons-codec-1.3.jar commons-collections-2.1.1.jar commons-collections-3.1.jar commons-digester-1.6.jar commons-el-1.0.jar commons-fileupload-1.0.jar commons-lang-2.1.jar commons-logging-1.0.4.jar commons-validator-1.3.1.jar concurrent-1.3.2.jar connector.jar dom4j-1.6.1.jar ehcache-1.2.3.jar hibernate3.jar jaas.jar jacc-1_0-fr.jar javassist.jar jaxen-1.1-beta-7.jar jboss-cache.jar jboss-common.jar jboss-jmx.jar jboss-system.jar jdbc2_0-stdext.jar jgroups-2.2.8.jar jstl-1.1.0.jar jta.jar junit-3.8.1.jar log4j-1.2.11.jar myfaces-api-1.1.5.jar myfaces-impl-1.1.5.jar mysql-connector-java-3.0.16-ga-bin.jar mysql-connector-java-3.1.6-bin.jar oro-2.0.8.jar oscache-2.1.jar proxool-0.8.3.jar spring.jar swarmcache-1.0rc2.jar syndiag2.jar tomahawk-1.1.6.jar versioncheck.jar xerces-2.6.2.jar xml-apis.jar |
Now all the libraries are available with us in our application, we will now create database and tables in MySQL to use in our application.