-->
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.  [ 8 posts ] 
Author Message
 Post subject: Hibernate and JWS
PostPosted: Thu Sep 04, 2003 10:58 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
Our application will use JWS tecnology.
We will use Hibernate and a J2EE architecture, and we would like to keep all Hibernate stuff on the server-side.
We noticed that if we use proxy there is an error while de-serializing the object because on the client side there aren't some Hibernate classes.
At now we should put all these jar in the client too: commons-collections.jar; commons-lang.jar; hibernate2.jar; odmg.jar; cglib.jar; commons-logging.jar
In particular hibernate2.jar is quite big, and I think that most part of it is nou usefull on the client-side.
Is it possible to have a hibernate2-client.jar in the future versions?
Regards
Alessandro Rizzi


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2003 10:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
In this case you will require a remoting api, for example, CORBA, EJB, Javaspaces, JINI etc. You will not need to have (or should ever have as you have noted) any hibernate installed included with each of the clients.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 12:51 pm 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
david wrote:
In this case you will require a remoting api, for example, CORBA, EJB, Javaspaces, JINI etc. You will not need to have (or should ever have as you have noted) any hibernate installed included with each of the clients.


Sorry but I do not understand what you mean.
If you're saying that I don't need any Hibernate jar, I'm sorry to tell you that it doesn't work ... I get this exception:
9-set-2003 18.50.13 net.sf.hibernate.proxy.CGLIBLazyInitializer getProxy

GRAVE: CGLIB Enhancement failed

net.sf.cglib.CodeGenerationException: net.sf.cglib.ReflectUtils

at net.sf.cglib.CodeGenerator.defineDependancy(CodeGenerator.java:254)

at net.sf.cglib.CodeGenerator.defineResource(CodeGenerator.java:216)

at net.sf.cglib.CodeGenerator.<init>(CodeGenerator.java:102)

at net.sf.cglib.EnhancerGenerator.<init>(EnhancerGenerator.java:100)

at net.sf.cglib.Enhancer.enhanceClassHelper(Enhancer.java:224)

at net.sf.cglib.Enhancer.enhanceHelper(Enhancer.java:206)

at net.sf.cglib.Enhancer.enhance(Enhancer.java:162)

at net.sf.cglib.Enhancer.enhance(Enhancer.java:139)

at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:26)

at net.sf.hibernate.proxy.SerializableProxy.readResolve(SerializableProxy.java:36)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:896)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1645)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1830)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1756)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1636)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)

at com.evermind.server.rmi.RMIInputStream.readType(RMIInputStream.java:118)

at com.evermind.server.rmi.RMIConnection.handleMethodInvocationResponse(RMIConnection.java:1638)

at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:532)

at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:275)

at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:797)

at java.lang.Thread.run(Thread.java:536)

Caused by: net.sf.cglib.CodeGenerationException: net.sf.cglib.ReflectUtils

at net.sf.cglib.CodeGenerator.defineDependancy(CodeGenerator.java:236)

... 27 more

Caused by: java.lang.ClassNotFoundException: net.sf.cglib.ReflectUtils

... 28 more

9-set-2003 18.50.13 net.sf.hibernate.proxy.SerializableProxy readResolve

GRAVE: Exception deserializing proxy

net.sf.cglib.CodeGenerationException: net.sf.cglib.ReflectUtils

at net.sf.cglib.CodeGenerator.defineDependancy(CodeGenerator.java:254)

at net.sf.cglib.CodeGenerator.defineResource(CodeGenerator.java:216)

at net.sf.cglib.CodeGenerator.<init>(CodeGenerator.java:102)

at net.sf.cglib.EnhancerGenerator.<init>(EnhancerGenerator.java:100)

at net.sf.cglib.Enhancer.enhanceClassHelper(Enhancer.java:224)

at net.sf.cglib.Enhancer.enhanceHelper(Enhancer.java:206)

at net.sf.cglib.Enhancer.enhance(Enhancer.java:162)

at net.sf.cglib.Enhancer.enhance(Enhancer.java:139)

at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:26)

at net.sf.hibernate.proxy.SerializableProxy.readResolve(SerializableProxy.java:36)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:896)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1645)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1830)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1756)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1636)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)

at com.evermind.server.rmi.RMIInputStream.readType(RMIInputStream.java:118)

at com.evermind.server.rmi.RMIConnection.handleMethodInvocationResponse(RMIConnection.java:1638)

at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:532)

at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:275)

at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:797)

at java.lang.Thread.run(Thread.java:536)

Caused by: net.sf.cglib.CodeGenerationException: net.sf.cglib.ReflectUtils

at net.sf.cglib.CodeGenerator.defineDependancy(CodeGenerator.java:236)

... 27 more

Caused by: java.lang.ClassNotFoundException: net.sf.cglib.ReflectUtils

... 28 more

rethrown as net.sf.hibernate.HibernateException: CGLIB Enhancement failed: net.sf.cglib.ReflectUtils

at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:37)

at net.sf.hibernate.proxy.SerializableProxy.readResolve(SerializableProxy.java:36)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:896)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1645)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1830)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1756)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1636)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)

at com.evermind.server.rmi.RMIInputStream.readType(RMIInputStream.java:118)

at com.evermind.server.rmi.RMIConnection.handleMethodInvocationResponse(RMIConnection.java:1638)

at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:532)

at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:275)

at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:797)

at java.lang.Thread.run(Thread.java:536)

Caused by: net.sf.cglib.CodeGenerationException: net.sf.cglib.ReflectUtils

at net.sf.cglib.CodeGenerator.defineDependancy(CodeGenerator.java:254)

at net.sf.cglib.CodeGenerator.defineResource(CodeGenerator.java:216)

at net.sf.cglib.CodeGenerator.<init>(CodeGenerator.java:102)

at net.sf.cglib.EnhancerGenerator.<init>(EnhancerGenerator.java:100)

at net.sf.cglib.Enhancer.enhanceClassHelper(Enhancer.java:224)

at net.sf.cglib.Enhancer.enhanceHelper(Enhancer.java:206)

at net.sf.cglib.Enhancer.enhance(Enhancer.java:162)

at net.sf.cglib.Enhancer.enhance(Enhancer.java:139)

at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:26)

... 19 more

Caused by: net.sf.cglib.CodeGenerationException: net.sf.cglib.ReflectUtils

at net.sf.cglib.CodeGenerator.defineDependancy(CodeGenerator.java:236)

... 27 more

Caused by: java.lang.ClassNotFoundException: net.sf.cglib.ReflectUtils

... 28 more

Regards
Alessandro Rizzi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 8:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There are two architectures I was considering in my reply.
1) Client-Server - Where your JWS Swing client communicated with the database directly thus you will need JWS load all of the hibernate jars onto the client.

2) Multi-tier - Where your JWS Swing client talks to a remote server process (middle-tier) by a remoting API (such as CORBA, EJB etc). Thus the middle tier has the hibernate jars. In this senario only the middle tier requires the hibernate jars.

Now to complicate the issue with option 2 is proxies. This is an issue when you are using the domain model to do duties as the DTO. Proxies (or lazy loading) require the session that loaded the parent (and proxy stub) to be present to operate correctly. If it is serialised to the client then the proxy cannot lazy load the domain object resulting in an exception (as you have shown).

The solution is that you will need to completely load all your required domain objects before they are serialised to the client. Hibernate.initialise() helps with this process.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 10:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Steve,

Hibernate lets you serialize the proxies. You just need hibernate2.jar and cglib-asm.jar on the other side. It uses a writeReplace() trick.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 3:35 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
gavin wrote:
Steve,

Hibernate lets you serialize the proxies. You just need hibernate2.jar and cglib-asm.jar on the other side. It uses a writeReplace() trick.


Yes, I know I need hibernate2.jar and cglib-asm.jar ... my question was. "Is it possible to have something smaller?"
I don't think I need the whole hibernate2.jar on the client side, so if is broken in 2 (or more) little pieces, I can use on the client side only what I really need.
Regards
Alessandro Rizzi


Top
 Profile  
 
 Post subject: What about Hibernate & RMI & Javaws
PostPosted: Thu Sep 25, 2003 11:05 am 
Newbie

Joined: Thu Sep 25, 2003 11:00 am
Posts: 2
I've got a question which is very related to this topic. I'm using an RMI-server, which does all the database handling with Hibernate 1.1. The RMI-client is deployed via java webstart. Although I don't seem to have any dependencies on hibernate classes on the RMI-client, I get a classNotFoundException for cirrus.hibernate.collections.Set on the client. So with this architecture, is it necessary to have the Hibernate classes also on the client side of the RMI app (and thus deployed via javaws)?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 12:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hibernate replaces the set behind the scene so it can manage the collection, eg, identify changes for cascading operations. When using a Thick client I personnally prefer DTOs in which case you have no dependency.


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