-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NoClassDefFoundError
PostPosted: Thu May 20, 2010 8:25 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
I've made an application using hibernate and I developed it on mac osx.
No I'm trying the application in Windows XP and 7. This gives some errors about the included jar files.

I had the following jars included:
    antlr-2.7.6.jar
    c3p0-0.9.1.2.jar
    commons-collections-3.1.jar
    commons-lang-2.5.jar
    commons-logging-1.1.1.jar
    dom4j-1.6.1.jar
    hibernate3.jar
    hibernate-core.jar
    javassist-3.9.0.GA.jar
    jta-1.1.jar
    log4j-1.2.15.jar
    slf4j-api-1.5.11.jar
    slf4j-log4j12-1.5.11.jar

On Windows I have already added the following files to get past some NoClassDefFoundError:
    cglib-2.2.jar
    ehcache-1.5.0.jar

Does anyone knows why these files are needed one Windows and not on Mac?

At the moment I have this error:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.core.KeyFactory
   at org.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:308)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
   at util.SessionHandler.<clinit>(SessionHandler.java:9)
   at main.RegisterMain.main(RegisterMain.java:31)
SessionHandler.java:9 contains the following:
Code:
private static SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
I have already added the CGLIB so I don't know why this error is thrown.

Edit: I have found on findjar.com that both cglib and ehcache use net.sf.cglib.core.KeyFactory.
This could cause the error, but if I remove ehcache I get this error:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
   at java.lang.Class.getConstructor0(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:262)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:184)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1497)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1041)
   at util.SessionHandler.<clinit>(SessionHandler.java:9)
   at main.RegisterMain.main(RegisterMain.java:31)
Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.CacheException
   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)
   ... 11 more
So it seems I need both, but they can't work together. Does someone has a suggestion?

Edit:
While adding and removing jars on my mac I came across the same error. This was gone when I added hibernate-core.jar. When I add this on Windows the error remains. Does someone know of a difference between mac and windows.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.