aspose file tools*
The moose likes Object Relational Mapping and the fly likes Session creation falied - error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Session creation falied - error" Watch "Session creation falied - error" New topic
Author

Session creation falied - error

Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Hi

I am trying to create a session in Hibernate. I am using


with all the jar in place and no other error coming. I have put this code in a servlet. The whole code goes like this.

I am getting error


HibernateUtil class is


The configuration xml file is hibernate.cfg.xml



What I am doing wrongly, please someone help me here.



Programmer Analyst || J2EE web development/design
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What does the error message say? Do you have a stack trace you can post?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
no stack trace this is what I am getting in the console -

the test string(Sys.out code that I am putting on the top of the TestHibernate servlet) followed by the error message -
Initial SessionFactory creation failed.java.lang.IncompatibleClassChangeError



Hope this helps. Please ask me for more details.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Sounds like a deployment issue. Clear down your container's temporary directories and redeploy you application.
Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
Giffy Geraldo wrote:



change the above to

for a full stack trace.


Rahul Babbar
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
ok you meant



Thanks. I am trying these options.
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Here is the stack trace.

Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Here is a link to similar problem
http://www.coderanch.com/t/218728/Object-Relational-Mapping/java/IncompatibleClassChangeError

So I tried with different options - earlier I was putting the hibernate.cfg.xml in the app folder only. Now I have moved it to classes folder. I dun know why is that? I was following a youtube video to create a hibernate project, earlier by not putting it in the classes folder.

now it seems the classChnageError is gone.

Would some one please help me understand how to deplpy these config xmls, log4j.prop files etc for hibernate application. TIA.

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


So I tried with different options - earlier I was putting the hibernate.cfg.xml in the app folder only. Now I have moved it to classes folder. I dun know why is that? I was following a youtube video to create a hibernate project, earlier by not putting it in the classes folder.

"app folder", what do you mean by that? If you are deploying a web application you need to include the Hibernate configuration file on the classpath. If you are using the default configuration this need to be at the root of your classpath. Web applications have specified folders* that are included in the classpath. If you don't use these it will be up to how you configure your servlet container's classloader to pick dependent files up.

However, an IncompatibleClassChangeError is not what I would expect if you had put hibernate.cfg.xml in the wrong place. An erro like that usually only happens as the result of hot deployment.

*(If this is something you were not aware of I would go through the servlet parts of this before trying anything more with Hibernate)
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Thanks guys for quick response.

Thanks Paul for pointing that out. However I have one more query related to the directory structure and places where you need to put the various descriptors, context files etc. If we are using Eclipse as IDE - will the package hierarchy be same for Netbeans IDE. I am not sure of this thing. But I remember one time I was not able to run the application: set up in Eclipse and running properly, in Netbeans. Please help me understand this. TIA
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

However I have one more query related to the directory structure and places where you need to put the various descriptors, context files etc. If we are using Eclipse as IDE - will the package hierarchy be same for Netbeans IDE.


Placing those descriptors, config files in standard places matters when you deploy in an application server/running as a standalone app etc.. and not with development. Different IDEs use different folder hierarchies when we create projects (web,Java projects etc...). But the IDE will package the fles in a way that can be run (and accepted) in an application server (for web projects etc..). We can even use our own hierarchies and build the output files (to be run in a server/standalone) by using build tools like Ant inside the IDEs.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session creation falied - error