-->
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.  [ 4 posts ] 
Author Message
 Post subject: ClassNotFoundException driving me crazy!! Help!
PostPosted: Tue Aug 04, 2009 8:24 pm 
Newbie

Joined: Tue Aug 04, 2009 8:16 pm
Posts: 3
Stats:
Hibernate 3.2.6
Annotations 3.4
SQL Server 2005
EA on Glassfish 2.1 with Spring 2.5.x

Essentially I want to Serialize a whole HashSet to a column in the database.

Code:
@Entity
public class A {
    @Column(name="Foos")
    @Basic
    private HashSet<Foo> fooList = new HashSet<Foo>();

    ...
}


where class Foo is nothing special, just implements Serializable.

This mapping works ok to persist, however when I try to load it I receive a ClassNotFoundException on Foo. I also tried @CollectionOfElements with the same result.

Cut down exception stack trace:

...

Caused by: org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:214)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240)
at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82)
at org.hibernate.type.SerializableType.get(SerializableType.java:39)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2101)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
at org.hibernate.loader.Loader.getRow(Loader.java:1206)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
... 25 more
Caused by: java.lang.ClassNotFoundException: Foo
at com.sun.appserv.server.util.ASURLClassLoader.loadClass(ASURLClassLoader.java:129)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at org.hibernate.util.SerializationHelper$CustomObjectInputStream.resolveClass(SerializationHelper.java:268)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashSet.readObject(HashSet.java:291)
at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:210)
... 47 more


Top
 Profile  
 
 Post subject: Re: ClassNotFoundException driving me crazy!! Help!
PostPosted: Wed Aug 05, 2009 4:36 am 
Newbie

Joined: Mon Feb 23, 2009 9:08 am
Posts: 9
Have you added the Foo class to your hibernate configurations?

Code:
<hibernate-configuration>
   <session-factory>
      <mapping class="org.hibernate.Foo"/>**
   </session-factory>
</hibernate-configuration>


** Sample package.


Top
 Profile  
 
 Post subject: Re: ClassNotFoundException driving me crazy!! Help!
PostPosted: Wed Aug 05, 2009 7:01 pm 
Newbie

Joined: Tue Aug 04, 2009 8:16 pm
Posts: 3
jjrun1 wrote:
Have you added the Foo class to your hibernate configurations?


No, as it shouldn't need to be added as it is just being Serialized within a HashSet. I tried to add it anyway just in case, but with the same result.


Top
 Profile  
 
 Post subject: Re: ClassNotFoundException driving me crazy!! Help!
PostPosted: Wed Aug 05, 2009 11:53 pm 
Newbie

Joined: Tue Aug 04, 2009 8:16 pm
Posts: 3
It looks like it is a problem with Glassfish and Grizzly classloaders. Not sure how it all connects with Hibernate, but if I put Foo.class into a jar file and throw it in the glassfish global lib directory it works.

Also, not sure why this only happens with this particular Hibernate mapping either...Something is going on, but I don't have time to investigate.


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