[jboss-as7-dev] JBoss Modules & object serialization
Jason T. Greene
jason.greene at redhat.com
Thu Jul 26 10:06:18 EDT 2012
On 7/26/12 5:23 AM, Jeff Mesnil wrote:
> On 07/26/2012 12:12 PM, Jeff Mesnil wrote:
>> I was expecting this test to succeed. Is there a reason why I could not deserialize a class in the same context that I have
>> serialized it?
>
> sent too fast...
>
> I can see the issue only with Document instances.
>
> There are some magic with the XML APIs that I don't understand (e.g. the __redirect package of jboss-modules) and the user had
> to explicitly export the org.apache.xerces module in its EAR to workaround this issue.
> However, I don't see why this should not work straight out of the box.
This is problem C:
https://community.jboss.org/wiki/ModularSerialization
The user typically imports the JAXP api, but not the implementation (a
key part of the encapsulation/isolation principle in modularity). If you
use serialization directly yourself, serialization expects everything to
be on one big flat classpath in your classloader. The solutions in the
above doc apply.
You can either:
1. Import the implementation you are deserializing, placing it on the
"classpath" of the module (e.g. xerces)
2. Don't serialize Document and instead serialize something in your
shared structure. For example, you could write the xml content to the
stream, or you could create a DTO that contains the values your app needs.
3. Use modular serialization via jboss marshalling
Most of our frameworks use modular serialization. So if you for example
stick a Document on a SFSB, when it replicates to other servers
(clustering) it tags every class in the serialization stream with the
module it came from (in this case the implementation classes, xerces,
would include the org.apache.xerces marker). EJB remote coms do the
same, however if the client isn't modular, a pure SE client not running
on jboss modules, then they have to have xerces in their classpath (as
they would normally have to do talking to any other server).
Now regarding https://issues.jboss.org/browse/AS7-1271, if hornetq were
to implement modular serialization it would resolve the issue without
the user needing to make changes like 1 and 2. The problem is of course
getting the protocol compatibility right, but it's not insurmountable.
--
Jason T. Greene
JBoss AS Lead / EAP Platform Architect
JBoss, a division of Red Hat
More information about the jboss-as7-dev
mailing list