facebook

Hibernate Errors

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #220671 Reply

    Wayne Kidd
    Member

    My System:
    Eclipse 3.01
    Myeclipse 3.8.2
    C:\j2sdk1.4.2_05\
    When I started this first project on this system and configuration,
    I got the following error during test:

    testRun(edu.ucop.ers.erstest.HibernateSampleTest)
    java.lang.NoClassDefFoundError: org/dom4j/Attribute
    at edu.ucop.ers.erstest.ERSSessFact.<clinit>(ERSSessFact.java:30)
    at edu.ucop.ers.erstest.HibernateSample.run(HibernateSample.java:27)
    at edu.ucop.ers.erstest.HibernateSampleTest.testRun(HibernateSampleTest.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

    If I add the following dom4j jar from the internet 1.5.2 level, I get :

    testRun(edu.ucop.ers.erstest.HibernateSampleTest)
    java.lang.NoClassDefFoundError: org/odmg/DCollection
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at net.sf.hibernate.type.TypeFactory.set(TypeFactory.java:198)
    at net.sf.hibernate.mapping.Set.getCollectionType(Set.java:29)
    at net.sf.hibernate.mapping.Collection.getType(Collection.java:275)
    at net.sf.hibernate.cfg.Binder.bindProperty(Binder.java:443)
    at net.sf.hibernate.cfg.Binder.createProperty(Binder.java:1070)
    at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1050)
    at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:361)
    at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1243)
    at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:285)
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:333)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:990)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:946)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
    at edu.ucop.ers.erstest.ERSSessFact.currentSession(ERSSessFact.java:48)
    at edu.ucop.ers.erstest.HibernateSample.run(HibernateSample.java:27)
    at edu.ucop.ers.erstest.HibernateSampleTest.testRun(HibernateSampleTest.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

    #220673 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev, this has nothing to do with ME.

    On a side note I would say that you are missing required Hibernate libraries, ODGM for starters. If you are running offline unit tests, you likely need to add every single library in your WEB-INF/lib directory to your classpath. There are many libraries Hibernate needs especially if it is run offline, you can refer to the README inside of the /lib dir that comes with the Hibernate download for more info… but I think it should be safe to just add them all.

    #220674 Reply

    Wayne Kidd
    Member

    I thought that adding Hibernate capabilities to a project should bring in all of the needed libraries.

    #220675 Reply

    Wayne Kidd
    Member

    I did not actually do the hibernate download, I just added capability which gave me some part of hibernate but not all.

    #220676 Reply

    Riyad Kalla
    Member

    NOTE: Post was completely rewritten, please re-read

    Wayne,
    Look closer at your stack trace it looks like you are trying to run Unit tests using the Eclipse JUnit UI right? You want to make sure that all the JARs that MyEclipse added for Hibernate Capabilties are added to your Java Build Path > Libraries tab. There are quite a few (~20?) just for Hibernate alone.

    I’d like you to check that your ME install is still setup correctly and navigate to your Window > Prefs > MyEclipse > Project Capabilities > Hibernate preference screen. Do you see all the Hibernate libraries listed to the right? Were all these added to your project when you added Hibernate Capabilities?

    If you use the Navigator View can you navigate to your WebRoot/WEB-INF/lib directory, do you see all these JARs?

    If you navigate to Project Properties > Java Build Path > Libraries, do you see all those JARs added here? If not, click “Add JAR” navigate to your WebRoot/WEB-INF/lib directory and select all the JARs and hit OK.

    Now try and re-run your script, did it work?

    #220677 Reply

    Wayne Kidd
    Member

    I have added main classes and junit testcases to my j2ee project, which has the entire classpath of the web project. I can actually see the start of the session creation (hibernate is parsing the xml files properly). So, I believe the project has everything that the J2EE project has.

    Wayne

    #220678 Reply

    Riyad Kalla
    Member

    NOTE: Make sure to read my post above, we are posting at the same time to eachother

    If the above post didn’t help, can you clarify what your project setup is, and what youa re tryign to do? Then I mgiht be able to help more effectively.

    #220679 Reply

    Wayne Kidd
    Member

    I finally read your post. The libraries are not all in my project. In fact most of them are not. I do notice that the .myhibernatedata file has this line:
    addLibs2Project=false

    #220681 Reply

    Riyad Kalla
    Member

    The libraries are not all in my project. In fact most of them are not.

    Well that is ok, they just need to be in your Java Build Path in order for Hibernate to find them during the JUnit test. This entire thing is just a classpath problem, so if you can just hit the “Add External JAR” button in the Java Build Path > Libraries tab, and be sure to add all those JARs, then Hibernate will find them and everything will work.

    If that is not an option, then you might consider moving the test case classes into the project that does have all the hibernate libraries in its classpath.

    #220684 Reply

    Wayne Kidd
    Member

    I removed the hibernate nature from the .project file and re-added the hibernate capabilities. That seemed to do the trick. It would be good to have a UI for re-adding these capabilities to a project when the options were not correctly chosen.

    Wayne

    #220689 Reply

    Riyad Kalla
    Member

    I’m glad it is working now and think you have a good point, I will file your request Wayne.

    #220719 Reply

    Wayne Kidd
    Member

    Thanks.

    Wayne

Viewing 12 posts - 1 through 12 (of 12 total)
Reply To: Hibernate Errors

You must be logged in to post in the forum log in