EclipseLink and a Riena server [message #586704] |
Mon, 09 August 2010 11:14 |
Stephan Mann Messages: 22 Registered: August 2010 |
Junior Member |
|
|
Because this question came up during a workshop last week I just wanted
to post this answer for all users to refer to. If you're running a Riena
server that uses EclipseLink as persistence API, you're likely to run
into a Hessian serialization problem. The problem will show up most
likely through an exception that looks like this:
---8<---
Jul 20, 2010 2:20:46 PM com.caucho.hessian.io.SerializerFactory
getDeserializer
WARNING: Hessian/Burlap:
'org.eclipse.persistence.indirection.IndirectList' is an unknown class
in org.eclipse.core.runtime.internal.adaptor.ContextFinder@1ee2c2c:
java.lang.ClassNotFoundException:
org.eclipse.persistence.indirection.IndirectList
---8<---
There are two solutions for this problem. The first is to introduce a
dependency to org.eclipse.persistence.core into the client, thus
providing the implementation of IndirectList.
The second, and IMHO preferable, solution is to change all annotations
of @OneToMany and @ManyToMany to use eager fetching:
@ManyToManny(fetch = FetchType.EAGER)
@OneToMany(fetch = FetchType.EAGER)
In this case, EclipseLink will use Vector as the List implementation and
you'll have no problems deserializing it.
Background/explanation:
EclipseLink uses lazy loading for all List typed fields by default. It
does that by using a persistence API specific implementation of the List
interface called IndirectList [1]. By doing this, EclipseLink does not
need to load the list before it is used.
Due to the decoupling of the Hessian serialization, the client must know
the implementation details of IndirectList to deserialize the objects.
If it doesn't, you'll see the exception above.
But since all fields need to be read (and thus loaded) to be serialized,
the advantages of lazy loading have no effect in conjunction with
serialization. So you can disable lazy loading all together (=> eager)
and remove the unnecessary dependency in your client.
hth, stephan
[1]
http://www.eclipse.org/eclipselink/api/2.0/org/eclipse/persi stence/indirection/IndirectList.html
|
|
|
Powered by
FUDForum. Page generated in 0.03484 seconds