<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.00.3103.1000" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>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:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>Make an EJB which
has this signature in the RemoteInterface:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002> public
Document getSimpleDoc() throws Exception, RemoteException;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>In the EJBean class
implement the remote interface:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002> public
Document getSimpleDoc() throws Exception {<BR> Element theRoot
= new Element("Root");<BR> Element levelA = new
Element("A");<BR> Element levelB = new
Element("B");<BR> levelB.addContent(new
Element("levelB").addContent("5"));<BR>
theRoot.addContent(levelA.addContent(levelB));<BR> Document
doc = new Document(theRoot);<BR>Element root =
doc.getRootElement();<BR>System.out.println("Inside of the EJB Method:
root.hasChildren(): " + root.hasChildren() + " root.getChildren().size(): "
+ root.getChildren().size() );<BR> return doc;<BR>
}<BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>Now make a trivial
JSP to call the EJB getSimpleDoc() method:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002><%@ page
import="<BR> javax.naming.*;<BR>
com.mycompany.ejb.session.productdisplay.*;<BR> org.jdom.*;<BR>
org.jdom.output.XMLOutputter;<BR>
com.mycompany.utilities.*;" <BR>
errorPage="/components/common/ErrorPage.jsp"<BR>%><BR><%<BR> Context
ctx = Utils.getServerInitialContext();<BR> ProductDisplayHome
productDisplayHome =
(ProductDisplayHome)ctx.lookup("ProductDisplayHome");<BR> ProductDisplay
productDisplay = productDisplayHome.create();<BR> Document doc =
productDisplay.getSimpleDoc();<BR>Element root =
doc.getRootElement();<BR>out.print("Inside of the JSP (the Caller) Method:
root.hasChildren(): " + root.hasChildren() + " root.getChildren().size(): "
+ root.getChildren().size() );<BR>// XMLOutputter xo = new
XMLOutputter(" ", true);<BR>//
xo.output(doc,System.out);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002><BR>%></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>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:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002> Inside
of the EJB Method: root.hasChildren(): true root.getChildren().size():
1</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>But inside of the
JSP when dealing with the Document that has gone thru serialization (marshalling
and unmarshalling) you get:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002> Inside of the
JSP (the Caller) Method: root.hasChildren(): true root.getChildren().size(): 0
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>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. </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002>I think that this is
a major problem for anyone returning Document objects from EJB methods (like we
were).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002>Thanks</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=503405916-29032002></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=503405916-29032002></SPAN></FONT><FONT
face=Arial size=2><SPAN class=503405916-29032002>Tom
Preston<BR></DIV></SPAN></FONT></BODY></HTML>