-->
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.  [ 13 posts ] 
Author Message
 Post subject: What cfg.configure() does :: noClassDefFoundError wrong name
PostPosted: Sat Oct 15, 2005 2:06 pm 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
Ok, here goes:
the ant script that executes the package lies in ~/cerberus/cerberus/ant/trunk/

The package (za/ac/up/cs/espresso/cerberus) itself lies in: ~/tinyos/tinyos-1.1.13/tools/java, which results in the class files being in:
~/tinyos/tinyos-1.1.13/tools/java/za/ac/up/cs/espresso/cerberus

The hibernate mapping files lies in the same directory as the class files.
The hibernate config (cfg.xml) file lies in ~/tinyos/tinyos-1.1.13/tools/java/ (thus, the root of the package).

The hibernate config file refers to the mapping files as "za/ac/up/cs/espresso/cerberus/mapFileName.hbm.xml"

When I run the package with main class being Cerberus, I get the following error:
java.lang.NoClassDefFoundError: Mote (wrong name: za/ac/up/cs/espresso/cerberus/Operator)

After some debug, I have found that this error occurs when the sessionFactory of hibernate is initialised at "
Configuration confdone = conf.configure();
if(confdone != null) {
//LAST OUTPUT IS HERE, THEN THE EXCEPTION IS THROWN
sessionFactory = confdone.buildSessionFactory();
}

Any ideas anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 15, 2005 2:55 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
is ~/tinyos/tinyos-1.1.13/tools/java/ the classpath ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 4:47 am 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
~/tinyos/tinyos-1.1.13/tools/java/ is also in the classpath. the classpath however must contain the package (za/ac/up/cs/espresso/cerberus for the mapping files to see the classes). I could paste the classpath if you'd like.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 5:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sounds to me you have a class called Mote in a file called Operator - that is not allowed in java.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 6:16 am 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
Here is a direct dump:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: Operator (wrong name: za/ac/up/cs/espresso/cerberus/Operator)
[java] at java.lang.ClassLoader.defineClass0(Native Method)

This happens as soon as the cfg.configure() method is called.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 6:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
go look up NoClassDefFoundError and learn what it means.

this is not a hibernate issue - it is either your classnames that are wrong or the code in your classes that are wrong in relation to the classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 6:34 am 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
I think the problem comes with the use of packages. Note the "wrong name" part of the error.
The wrong name exception has been checked according to
http://www.skylit.com/javamethods/appxf.html#wrongname

Also note the za/ac/up/cs/espresso/cerberus/ part of the error. Could it be possible that it is looking for the Operator class in za/ac/up/cs/espresso/cerberus/ za/ac/up/cs/espresso/cerberus/ Operator ?

The classnames are correct.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 8:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i dont know - you havent shown the mappings nor a full stacktrace as mentioned at http://www.hibernate.org/ForumMailingli ... AskForHelp

...this should be trivial for you to find out!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 8:34 am 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
I hate pasting stacktraces and long texts as these are hard to read on forums. rather the upload of files. But here are the files anyways, beginning with the MAPPING file, then the OPERATOR class, followed by the ANT target and last the EXCEPTION:
OPERATOR MAPPING FILE:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="Operator" table="OPERATOR">
<id name="operatorID" column="OPERATOR_ID" type="java.lang.Long">
<generator class="increment"/>
</id>
<property name="description" column="DESCRIPTION"/>
</class>

</hibernate-mapping>


OPERATOR CLASS:
package za.ac.up.cs.espresso.cerberus;

/**
* OO representaion of an operator
* Hibernate
* @hibernate.class
* table="OPERATOR"
*/
public class Operator
{
private String description;
private Long operatorID;

/**
* Hibernate
* Default constructor
*/
public Operator()
{}

/**
* Hibernate
* @hibernate.id
* generator-class="increment"
* column="OPERATOR_ID"
*/
public Long getOperatorID()
{
return operatorID;
}
public void setOperatorID(Long operatorID)
{
this.operatorID = operatorID;
}

/**
* Hibernate
* @hibernate.property
* column="DESCRIPTION"
*/
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
}


ANT TARGET:
target name="run.cerberus" description="Runs Cerberus Application">
<property name="cp" refid="classpath"/>
<echo message="Classpath is ${cp}"/>
<java classname="za.ac.up.cs.espresso.cerberus.Cerberus" fork="true" classpathref="classpath">
<arg value="-h"/>
</java>
</target>


OUTPUT OF ant run.cerberus

run.cerberus:
[echo] Classpath is /home/bothapn/tinyos/tinyos-1.1.13May2005cvs/tools/java:/usr/share/javacomm/lib/comm.jar:/usr/share/jdom-1.0_beta10/lib/jdom.jar:/ome/bothapn/cerberus/cerberus/final/trunk/jars/xstream-1.1.2.jar:/home/bothapn/mysql-connector-java-3.0.16-ga-bin.jar:/home/bothapn/tinyos/tinyos-1.1.13May005cvs/tools/java/jars/oalnf.jar:/home/bothapn/tinyos/tinyos-1.1.13May2005cvs/tools/java/za/ac/up/cs/espresso/cerberus/log4j.properties:/home/bothapn/tinyo/tinyos-1.1.13May2005cvs/tools/java/hibernate.cfg.xml:/home/bothapn/tinyos/tinyos-1.1.13May2005cvs/tools/java/za/ac/up/cs/espresso/cerberus:/home/bothapn/tnyos/svn/final/jars/axis.jar:/home/bothapn/tinyos/svn/final/jars/bsf.jar:/home/bothapn/tinyos/svn/final/jars/bsh.jar:/home/bothapn/tinyos/svn/final/jars/emil.jar:/home/bothapn/tinyos/svn/final/jars/hibernate3.jar:/home/bothapn/tinyos/svn/final/jars/jSMSEngine.jar:/home/bothapn/tinyos/svn/final/jars/jbossall-cient.jar:/home/bothapn/tinyos/svn/final/jars/liquidlnf.jar:/home/bothapn/tinyos/svn/final/jars/log4j-1.2.12.jar:/home/bothapn/tinyos/svn/final/jars/mysql-cnnector-java-3.0.14-production-bin.jar:/home/bothapn/tinyos/svn/final/jars/xstream-1.1.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/ant-1.6.2.jar:/home/othapn/hibernate/hibernate-3.0/lib/ant-antlr-1.6.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/ant-junit-1.6.2.jar:/home/bothapn/hibernate/hibernate-3.0/ib/ant-launcher-1.6.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/ant-swing-1.6.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/antlr-2.7.4.jar:/home/botapn/hibernate/hibernate-3.0/lib/c3p0-0.8.5.jar:/home/bothapn/hibernate/hibernate-3.0/lib/cglib-full-2.0.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/clenimports.jar:/home/bothapn/hibernate/hibernate-3.0/lib/commons-collections-2.1.1.jar:/home/bothapn/hibernate/hibernate-3.0/lib/commons-logging-1.0.4.jar:/hme/bothapn/hibernate/hibernate-3.0/lib/concurrent-1.3.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/connector.jar:/home/bothapn/hibernate/hibernate-3.0/lb/dom4j-1.5.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/ehcache-1.1.jar:/home/bothapn/hibernate/hibernate-3.0/lib/hibernate3.jar:/home/bothapn/hibernat/hibernate-3.0/lib/jaas.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jacc-1_0-fr.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jaxen-1.1-beta-4.jar:/home/othapn/hibernate/hibernate-3.0/lib/jboss-cache.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jboss-common.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jbos-jmx.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jboss-remoting.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jboss-system.jar:/home/bothapn/hibernate/hbernate-3.0/lib/jdbc2_0-stdext.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jgroups-2.2.7.jar:/home/bothapn/hibernate/hibernate-3.0/lib/jta.jar:/home/bothpn/hibernate/hibernate-3.0/lib/junit-3.8.1.jar:/home/bothapn/hibernate/hibernate-3.0/lib/log4j-1.2.9.jar:/home/bothapn/hibernate/hibernate-3.0/lib/oscache-.1.jar:/home/bothapn/hibernate/hibernate-3.0/lib/proxool-0.8.3.jar:/home/bothapn/hibernate/hibernate-3.0/lib/swarmcache-1.0rc2.jar:/home/bothapn/hibernate/ibernate-3.0/lib/versioncheck.jar:/home/bothapn/hibernate/hibernate-3.0/lib/xerces-2.6.2.jar:/home/bothapn/hibernate/hibernate-3.0/lib/xml-apis.jar
[java] log4j:WARN No appenders could be found for logger (Cerberus).
[java] log4j:WARN Please initialize the log4j system properly.
[java] DATABASE 513
[java] DATABASE 515
[java] SESSION 46
[java] SESSION 48
[java] SESSION 49
[java] Exception in thread "main" java.lang.NoClassDefFoundError: Operator (wrong name: za/ac/up/cs/espresso/cerberus/Operator)
[java] at java.lang.ClassLoader.defineClass0(Native Method)
[java] at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
[java] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
[java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
[java] at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
[java] at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
[java] at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
[java] at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:275)
[java] at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:1841)
[java] at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1827)
[java] at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1728)
[java] at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:318)
[java] at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:236)
[java] at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
[java] at org.hibernate.cfg.Configuration.add(Configuration.java:362)
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
[java] at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
[java] at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
[java] at za.ac.up.cs.espresso.cerberus.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:50)
[java] at za.ac.up.cs.espresso.cerberus.Database.initialiseMotes(Database.java:516)
[java] at za.ac.up.cs.espresso.cerberus.Cerberus.<init>(Cerberus.java:39)
[java] at za.ac.up.cs.espresso.cerberus.Cerberus.main(Cerberus.java:30)
[java] Java Result: 1


Hope this is provides some more info, although it might be a long post


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
again it is so obvious that it hurts ;)

your hbm.xml file list the class name as Operator - it should be the fully qualified classname (or at least at a package attribute to <hibernate-mapping>)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 12:04 pm 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
wow, it actually works.
did'nt know I had to put the package names in the mapping files too as they are in the same directory as the class files.
tx!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 12:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well you also put a full package name in .java files; why should that be different for hbm.xmls ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 16, 2005 12:17 pm 
Newbie

Joined: Sat Oct 15, 2005 12:46 pm
Posts: 7
very true.


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

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.