Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Exception thrown: org.hibernate.Hibernate Exception

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I posted this in hibernate forum too. But they were not able to help me. Since I use IRAD 6.0, I am hoping that you will be able to help me.
This is the problem.
I am trying a simple hibernate program in my web project and it throws this error. I have put the DB2 java.zip file in the class path already. Please help me!

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a problem with the zip or jar not seen or conflicting with another zip file in the class path. Please check if there are more than one zip file of the same present. Try changing the class loading policy too.
 
Vidya Moorthy
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joe Mathew:
This is a problem with the zip or jar not seen or conflicting with another zip file in the class path.


I checked to see for conflicting zip files. But could not find that. This project worked earlier before I had reinstalled my IRAD 6.0 because of some problems.

How to change the class loader policy. I have never done that. I don't want to do something wrong and mess it up again.
Thanks in advance
Vidya
 
author and cow tipper
Posts: 5006
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On which classpath did you put the db2java.zip file? It's not good enough just to be on the classpath, but it must be in a location where the classloader of the Java component invoking the classes in the JAR file can see it.

So, where is the db2java.zip file located?

-Cameron McKenzie
 
Vidya Moorthy
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cameron
I have checked your video tutorials and they are really helpful for WSAD and IRAD users. Thanks a lot for taking the effort to put it in together.
The DB2java.zip is located in C:\Program Files\IBM\SQLLIB\java\ in my computer. When I was talking about them being in the classpath, I meant that they are in Java Build path of the project. Do you want me to edit the classpath variable or path variable in my computer too?
Thanks in advance
Vidya
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5006
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there could be a few things going on here.

I'm guessing you get that error when the application runs?

One thing you can do in your code is just create an instance of the driver class:

COM.ibm.db2.jdbc.app.DB2Driver driver = new COM.ibm.db2.jdbc.app.DB2Driver();

Or whatever the constructor is. That will tell you if you're linking to the driver file at design time.

But this may be a runtime error? Your design time environment and runtime environment are two different things.

You may actually have to package the db2java.zip file right in your applicaiton. Certainly try that to get things working. Put it in the root of the EAR or the lib of the war file if you're creating an J2EE app. Otherwise, import the jar file from the directory to bring it into the Java project.

The Hiberntate Configuration object is using this file, so when you go:

Configuration configuration = new Configuration();

it's looking for the drivers. The classpath used by WebSphere to link to support a connection pool might not be accessible to your application code at runtime.

Looks like you need to repackage.

Post back and let us know how you're doing.

-Cameron McKenzie
 
Vidya Moorthy
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cameron
I imported the jar file into WEB-INF/lib and it still threw the error.
Pardon my ignorance. Do you want me to write a separate java class to test the driver constructor like this
public class DBTest {
public static void main(String[] args){
try{
COM.ibm.db2.jdbc.app.DB2Driver driver = new COM.ibm.db2.jdbc.app.DB2Driver;**** Shows an error syntax an error on tokens, misplaced construct*********
}
catch(SQLException se){
System.out.println("Problem");
}
}

}
Thanks again for taking so much time.
Vidya
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You could check if the zip file is correct. ie, if it actually has the required package/class.
Also, now that you are packaging the zip/jar with your web app, try removing the same from your class path in development environment and see if the class is being picked up from web-inf/lib in the development environment. If not, it'll be easy in development env to put in some debugs and check what's happening.
You can also try putting some other jar in web-inf/lib, just for testing and try instantiating any class from that jar. Just to see if this also gives the same problem.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic