This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes hibernate exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate exception" Watch "hibernate exception" New topic
Author

hibernate exception

hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Hey guys,

I am a newbie in java arena, and I am currently working to build a simple app using hibernate, but somehow even after going through samples, i am stuck-up...

I am getting the following error after i run my app...


java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
Hibern.doPost(Hibern.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

I am using a HTML form with "submit" button to make a call to a servlet, which intern retrieves data from my oracle DB table.


here's the servlet code,






My config file is as follows,its placed under \src



My mapping file is as follows,




and Bean is my POJO,





Could anyone help me out to pull out of this meager problem...

Thanks in advance,
hemanth ..

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Moved to Object Relations Mapping & added code tags.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hi and welcome to the JavaRanch.

I'm going to assume that you deployed this to something like tomcat. In that case you probably forgot to add hibernate to the classpath.
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Hi Wouter,
Thanks for early response..

Well, yea i deployed it to TOMCAT, and i added hibernate jars to my classpath.
The jars were there in my E drive...
But even then the problem exists..
Please let me know the solution to solve this.


Thank you
Hemanth.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

yea i deployed it to TOMCAT, and i added hibernate jars to my classpath.
The jars were there in my E drive...

What "classpath" are you talking about here? Do you have the required jar files in the application lib folder deployed to Tomcat, if not you should add them there.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Vijitha,

I set CLASSPATH in the environment variables.
I have the required jars, and i added it to the application using "Add External Jars"..
I hope this is the way,

I know these are quite basic, but i need to get the hang of it..

Thank you,
Hemanth.
Waswani Naresh
Ranch Hand

Joined: May 01, 2008
Posts: 66
Hi Hemanth,

Add external jars (probably you are using eclipse) would allow you to compile your application but because this is a JEE application, you need to add your jars in the lib folder and then deploy the package into the Tomcat.

Just adding jars in the environment classpath variable would not help.

Please check the JEE web application folder structure for more details.

Regards,
Naresh Waswani


Naresh Waswani
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Hello guys,

I am getting the following error on my mapping xml.

The file cannot be validated as the XML Schema "http://www.jboss.org/dtd/hibernate/Hibernate-mapping-3.0.dtd" that is specified as describing the syntax of the file cannot be located.

Could anyone help me to solve this..

Thank u.
Hemanth.
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Hey guys ,
The above issue is solved..

Now i am getting another...

Could not parse configuration: /hibernate.cfg.xml

this is my full stack..

16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA 16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 31 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 63 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml 63 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml

Please help me out..

Thank you ,
hemanth
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
Can you post the entire stacktrace? It might throw some light on the actual issue. Also check that there are no spaces or carriage returns before the first line.
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Hi sridhar..

The following is what I got..


16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
31 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
63 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
63 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
Could not parse configuration: /hibernate.cfg.xml

Thank you
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Sridhar,

There is no space or carriage in the xml, i have made it sure that i haven't left anythin behind...
hemanth acharya
Ranch Hand

Joined: Aug 10, 2011
Posts: 51
Hey guys,

Thanks for all the help.. I could able to solve it... The problem was with DTD....

The following is what i used in my conf file..

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

and there was one more mistake in my hbm file..
<hibernate-mapping>
<class name="com.employee" table="PERSONNEL">

....
....

I had written 'class name' value as "com.employee.java"

Thank you,
Hemanth
 
jQuery in Action, 2nd edition
 
subject: hibernate exception