-->
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.  [ 3 posts ] 
Author Message
 Post subject: NoClassDefFoundError???
PostPosted: Tue Aug 02, 2005 6:31 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.0[/b]

[b]Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="com.gloptv.smsc.Customer"
table="customer"
lazy="true"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<cache usage="nonstrict-read-write" />

<id
name="id"
column="id"
type="int"
>
<generator class="sequence">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Customer.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="name"
not-null="true"
/>

<property
name="isDeleted"
type="boolean"
update="true"
insert="true"
access="property"
column="is_deleted"
/>

<many-to-one
name="user"
class="com.gloptv.smsc.User"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="property"
column="user_id"
not-null="true"
/>

<set
name="keywords"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
order-by="name"
where="is_deleted = 'false'"
>

<key
column="customer_id"
>
</key>

<one-to-many
class="com.gloptv.smsc.Keyword"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Customer.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:postgresql 8.0[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]

Hi everyone, my problem is as follows. I have a class named Customer from which I've generated the file Customer.hbm.xml as shown above. When I tried to obtain a session as follows:

..................
Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
SessionFactory sessionFactory = configuration.buildSessionFactory();
Session session = sessionFactory.openSession();
.................

I got a 'NoClassDefFoundError', I searched and found that all my classes are here. Something very strange. After hours of debugging I found that the error comes from the server ip address. In fact the ip address of my server has been changed and in my Customer.hbm.xml file the ip address has not been changed. Consequently when hibernate searches for the following file: http://192.168.2.1/hibernate-mapping-3.0.dtd, it did not find it and throws a NoClassDefFoundError.

I think Hibernate could have thrown a clearer description of the error.

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 6:40 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
Why have you put in your .hbm the IP of you server?
If you leave the standard DTD "<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">"

If you leave as above, Hibernate searches first inside Hibernate3.jar (where there is a copy of this DTD) and won't look around the net to search for it, at least this is what I discover looking in the sources, but I know for sure that it works.

Hope this help.
Bye
Alessandro


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 6:51 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Previously I did like this and found that hibernate tries to search for the dtd on the net, that why I've change it so that it searhc for the dtd locally. (The problem is not whether the dtd is to be searched locally or externally, it's only that hibernate should throw a more obvious error.)

In fact, what I've noticed also is that when hibernate tries to read the hibernate.cfg.xml file and consequently there is a problem either in the cfg.xml or in any hbm.xml file, it throws a NoClassDefFoundError.

I think it would be more appropriate to throw the exact cause of the error, instead of just throwing NoClassDefFoundError.

thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.