Friday 9 September 2011

Some notes about VaanNila's Spring Hibernate Integration Tutorial

Some notes about Vaanilla's Spring Hibernate Integration Tutorial
http://www.vaannila.com/spring/spring-hibernate-integration-1.html

SpringExample17 indicates the below list as necessary dependecies.

01.antlr-2.7.6
02.antlr-runtime-3.0
03.commons-collections-3.1
04.commons-dbcp
05.commons-logging-1.0.4
06.commons-pool
07.dom4j-1.6.1
08.ejb3-persistence
09.hibernate3
10.hibernate-annotations
11.hibernate-commons-annotations
12.hsqldb
13.javassist-3.4.GA
14.jstl
15.jta-1.1
16.org.springframework.asm-3.0.0.M3
17.org.springframework.beans-3.0.0.M3
18.org.springframework.context-3.0.0.M3
19.org.springframework.context.support-3.0.0.M3
20.org.springframework.core-3.0.0.M3
21.org.springframework.expression-3.0.0.M3
22.org.springframework.jdbc-3.0.0.M3
23.org.springframework.orm-3.0.0.M3
24.org.springframework.transaction-3.0.0.M3
25.org.springframework.web-3.0.0.M3
26.org.springframework.web.servlet-3.0.0.M3
27.slf4j-api-1.5.6
28.slf4j-simple-1.5.6
29.standard

I used the below list of dependecies:
Directory of C:\Users\ars\Desktop\Str_Hib_Spr\SpringExample17\WebContent\WEB-INF\lib

antlr-2.7.6.jar
antlr-runtime-3.0.jar
asm.jar
cglib-2.2.jar
commons-collections.jar
commons-dbcp.jar
commons-logging.jar
commons-pool.jar
dom4j-1.6.1.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate3.jar
hsqldb.jar
javassist-3.4.GA.jar
javax.persistence.jar
javax.servlet_2.4.0.v200706111738.jar
jstl.jar
jta-1.1.jar
org.springframework.asm-3.1.0.M2.jar
org.springframework.beans-3.1.0.M2.jar
org.springframework.context-3.1.0.M2.jar
org.springframework.context.support-3.1.0.M2.jar
org.springframework.core-3.1.0.M2.jar
org.springframework.expression-3.1.0.M2.jar
org.springframework.jdbc-3.1.0.M2.jar
org.springframework.orm-3.1.0.M2.jar
org.springframework.transaction-3.1.0.M2.jar
org.springframework.web-3.1.0.M2.jar
org.springframework.web.servlet-3.1.0.M2.jar
slf4j-api-1.6.2.jar
slf4j-simple-1.6.2.jar
standard.jar

I had to add asm.jar and cglib-2.2.jar because of the problems listed below.


exception

org.springframework.web.util.NestedServletException: Request processing failed;
nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation:
Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0];
Cannot create PoolableConnectionFactory (socket creation error);
nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (socket creation error)

root cause

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation:
Cannot open connection; uncategorized SQLException for SQL [???];
SQL state [null]; error code [0];
Cannot create PoolableConnectionFactory (socket creation error);
nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (socket creation error)

SOLUTION:
Vaanilla assumes that you know how to run HSQLDB :-)
add hs.bat :
set classpath=.\web-inf\lib\hsqldb.jar;%classpath%
java org.hsqldb.Server

OUTPUT:
C:\Users\ars\Desktop\Str_Hib_Spr\SpringExample17\WebContent>set classpath=.\web-
inf\lib\hsqldb.jar;

C:\Users\ars\Desktop\Str_Hib_Spr\SpringExample17\WebContent>java org.hsqldb.Serv
er
[Server@6ac2a132]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@6ac2a132]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@6ac2a132]: Startup sequence initiated from main() method
[Server@6ac2a132]: Loaded properties from [C:\Users\ars\Desktop\Str_Hib_Spr\Spri
ngExample17\WebContent\server.properties]
[Server@6ac2a132]: Initiating startup sequence...
[Server@6ac2a132]: Server socket opened successfully in 358 ms.
[Server@6ac2a132]: Database [index=0, id=0, db=file:test, alias=] opened sucessf
ully in 156 ms.
[Server@6ac2a132]: Startup sequence completed in 514 ms.
[Server@6ac2a132]: 2011-09-09 20:21:26.494 HSQLDB server 1.8.0 is online
[Server@6ac2a132]: To close normally, connect and execute SHUTDOWN SQL
[Server@6ac2a132]: From command line, use [Ctrl]+[C] to abort abruptly
----------------

exception
...
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
net/sf/cglib/proxy/CallbackFilter
...
SEVERE: Servlet /SpringExample17 threw load() exception
java.lang.ClassNotFoundException: net.sf.cglib.proxy.CallbackFilter

SOLUTION:
add cglib.jar
--------------------

exception

root cause

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
Could not initialize class net.sf.cglib.proxy.Enhancer

SOLUTION:
cglib depends on asm.jar:

add asm.jar
---------------------------


If there are any problems related to antlr add:
antlr-2.7.5H3

If there are still any more problems:
arsaral [at] yahoo [dot] com

Cheers.

Ali R+