[jdom-interest] Resend: Is there a JDOM 8 Document serialization problem?
Bradley S. Huffman
hip at a.cs.okstate.edu
Sun Apr 7 12:16:09 PDT 2002
Not yet, but then again I currently don't have EJB on any machines so my
testing abilities are limited.
Brad
Tom Preston writes:
> I sent this msg a while ago but got no reply. Has anyone else reproduced
> this problem?...simple steps below. Passing Document through serialization
> killing the children of the root!
>
> tcp
>
> From: Tom Preston <tpreston at amadeusboston.com>
> Content-Type: multipart/alternative;
> boundary="----_=_NextPart_001_01C1D744.F52F24A0"
> Subject: [jdom-interest] MORE ABOUT: Problem with Jdom8 - getChildren() on
> root ...
> Date: Fri, 29 Mar 2002 12:12:51 -0500
>
>
>
> There IS more to the story. We are using EJB. When we get rid of the EJB
> aspect the problem goes away. So, we find that the problem is returning a
> jdom 8 Document from EJB. Something in the marshalling process is messing
> up the document so that root.hasChildren() returns true while
> root.getChildren returns a zero sized list after ANY Document has been
> returned from ANY EJB method. Here is the trivial example for reproduction:
>
> Make an EJB which has this signature in the RemoteInterface:
>
> public Document getSimpleDoc() throws Exception, RemoteException;
>
> In the EJBean class implement the remote interface:
>
> public Document getSimpleDoc() throws Exception {
> Element theRoot = new Element("Root");
> Element levelA = new Element("A");
> Element levelB = new Element("B");
> levelB.addContent(new Element("levelB").addContent("5"));
> theRoot.addContent(levelA.addContent(levelB));
> Document doc = new Document(theRoot);
> Element root = doc.getRootElement();
> System.out.println("Inside of the EJB Method: root.hasChildren(): " +
> root.hasChildren() + " root.getChildren().size(): " +
> root.getChildren().size() );
> return doc;
> }
>
>
> Now make a trivial JSP to call the EJB getSimpleDoc() method:
>
> <%@ page import="
> javax.naming.*;
> com.mycompany.ejb.session.productdisplay.*;
> org.jdom.*;
> org.jdom.output.XMLOutputter;
> com.mycompany.utilities.*;"
> errorPage="/components/common/ErrorPage.jsp"
> %>
> <%
> Context ctx = Utils.getServerInitialContext();
> ProductDisplayHome productDisplayHome =
> (ProductDisplayHome)ctx.lookup("ProductDisplayHome");
> ProductDisplay productDisplay = productDisplayHome.create();
> Document doc = productDisplay.getSimpleDoc();
> Element root = doc.getRootElement();
> out.print("Inside of the JSP (the Caller) Method: root.hasChildren(): " +
> root.hasChildren() + " root.getChildren().size(): " +
> root.getChildren().size() );
> // XMLOutputter xo = new XMLOutputter(" ", true);
> // xo.output(doc,System.out);
>
> %>
>
> You will see that the System.out.println from WITHIN the EJB (before the
> Document gets returned -- and therefore, before it gets marshalled and
> unmarshalled) prints out:
>
> Inside of the EJB Method: root.hasChildren(): true
> root.getChildren().size(): 1
>
> But inside of the JSP when dealing with the Document that has gone thru
> serialization (marshalling and unmarshalling) you get:
>
> Inside of the JSP (the Caller) Method: root.hasChildren(): true
> root.getChildren().size(): 0
>
> For the very same Document...the only difference being that the Document was
> passed thru EJB Marshalling and Unmarshalling, you have two different
> getChildren() of root results.
>
> My theory is that something in JDOM version 8 RC has made some field
> "transient" that shouldn't be and therefore the Document object is different
> before serialization than it is after serialization.
>
> I think that this is a major problem for anyone returning Document objects
> from EJB methods (like we were).
>
> Thanks
>
> Tom Preston
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost
> .com
More information about the jdom-interest
mailing list