May 9th, 2012, 08:30 AM
SessionFactory configuration problem
Hello everyone! How are you?
I'm starting with Spring and got some problems in a project I am doing here. I am using Spring 3.0.6 along with Hibernate 3.2.5 in NetBeans 7.1.
I decided to use annotation-based configuration to work with Hibernate. I find it easier than programming XML files.
During deployment, my application connects to the database and creates the tables just as expected. But when I run a test file to test the DAOs and insert a new object in the database, I receive an error message regarding the Session Factory, that prevents my Application Context of being correctly loaded.
I have sent to pastebin some of the files I think are important. Please click on the links to check their code.
Just as a reference, the code I pasted as App.java (click here to view) is the one I used to load the application context and instantiate the beans in the XML.
And, well... after running the App.java file showed above, the following log/error message appeared: click here to view.
As you can see, the main exception revealed is a bean creation exception due to and unknown method:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in URL [file:C:/Users/Isabela/Documents/MuitoBafao/Code/MuitoBafao/web/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V
Problem is, I didn't even change the SessionFactory XML code. I copied it from a book I am following and just changed the annotated packages.
I have also tried using the property "annotatedClasses" and adding all off them from muitobafao.model, one by one, on the list, but had the same result.
Can anyone please enlighten me? :/
Last edited by toffolo; May 9th, 2012 at 08:39 AM.
Reason: grammar correction :P
May 9th, 2012, 09:00 AM
Judging from the stacktrace you have an incorrect version of the asm libraries. Make sure you have a version to match compatible for the hibernate version you use.
May 9th, 2012, 09:20 AM
Hey Marten, thank you for your answer.
I thought it was strange as all the libraries were automatically included by NetBeans when I created the project. I haven't changed any of Spring or Hibernate configuration since I installed the IDE (like 45 days ago).
Anyway ... I redownloaded the whole 3.2.5.ga bundle from Hibernate repository and replaced the org.objectweb.asm library in the project libraries (as that's the one causing the error, right?), but it apparently had no effect. The exception returned stays pretty much the same.
Just as a reference, I posted the new stacktrace here. You can verify it's not different from the first one.
As Spring's asm library isn't even listed in the stacktrace, I believe that I don't need to touch it.
Any other ideas?
May 9th, 2012, 09:27 AM
Also make sure you have a proper cglib library... (In general I suggest maven to manage your dependencies).
I doubt you have classloading issues as this is a command line app.
May 9th, 2012, 09:34 AM
Well, in fact I have cglib-2.1.3 in my libraries. NetBeans also preconfigured it when setting up the project.
Below you may see a snapshot of all the libraries that are included in the project.
I'll attempt to create a new project using Maven + Spring + Hibernate to see if I get any success.
May 9th, 2012, 09:42 AM
2.1.3 is pretty old (well actually cglib is pretty old for that matter ). I suggest using the 2.2.2 version and the nodep version (that is/was the version that shipped with the spring framework < 2.5 and is also the last cglib version).
Also the snapshots get resized so it is pretty much unreadable .
Tags for this Thread