Skip to main content

Problem with circular relationship when using JAXWS

77 replies [Last post]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

Cool.

Let me know if you figure out what's going on inside the part of the code I pointed to you. You can get the latest JAXB RI and its corresponding source bundle from JAXB website. Glassfish comes with a version of the JAXB RI, but it might not have the version, so you might want to overwrite those with the known version of the JAXB RI, so that you know your source bundle matches with the binary you are debugging.

chillier
Offline
Joined: 2006-02-09
Points: 0

OK Kohsuke -

Actually I have another guy going on another thread who had me download Glassfish V2 b22, insisting the JAXB updates were imbedded There.

http://forums.java.net/jive/thread.jspa?forumID=56&threadID=19252&messag...

Maybe you know these guys.

So, supposedly I have the right glassfish. But I can't quite see how to placing a breakpoint on the src is going to work. I unzipped the source, loaded it as a library, placed a breakpoint, and tried to "run debug". But it loads all of Glassfish into the project as a library, and then hangs.

I have 4gig memory and dual cpu's, so I'm going to allocate Lots More to Netbeans and pray. But I don't see that NetBeans is smart enough to use My Source instead of the zip in Glassfish.... Maybe I need to re-zip my "breakpointed" source and replace in glassfish? That sounds pretty strange, too. All brilliant tips accepted with gratitude...

BR/Charles

kohsuke
Offline
Joined: 2003-06-09
Points: 0

I think you should just create a library from the JAXB RI. You'll then copy the same JAXB jars into Glassfish.

Unless you want to see the rest of Glassfish, I don't think you need to create a library for it (especially so if it's hanging.)

I wish I can get a dual CPU system with 4GB...

chillier
Offline
Joined: 2006-02-09
Points: 0

Hei Kohsuke -

No need for jealousy - my machine's probably 5-8 years old now...

I'm not working directly on this problem any longer, since it's "well defined and isolated" - but what I really hope for, is another link, this time to a new JAX-WS library, with the new JAXB built in.

I can easily override JAX-WS in our JDev/OC4J NB/Glassfish JSAAS & Oracle Appserver environments, but feel unsure if JAXB is being used with the server JAX-WS libraries (internal classpath to packaged JAXB?).

Can't "you guys" package a "JAX-WS EAx" library and post a link?

You guys are excellent...
Honest, I'm Not Kissing Up just to get you to do this... honest!

.... well, OK, I Am, but do it anyway? Legions of programmers would be eternally grateful (or use you and leave you, I can't remember which...)

BR/Charles

kohsuke
Offline
Joined: 2003-06-09
Points: 0

I'm not sure if I understand your question.

Every JAX-WS release comes with a reasonably recent JAXB releases. And if you want to replace it with even recent version of JAXB, it's just as easy as replacing the JAXB jars.

JAX-WS 2.1 just posted EA2. Is that not up-to-date enough?

tinashechipomho
Offline
Joined: 2005-01-24
Points: 0

Just a quick question:
I have two simple classes, why am i getting: A cycle is detected in the object graph exception yet I have marked my parent to be XmlTransient
[code]
@javax.xml.bind.annotation.XmlRootElement()
public class Country {

private String name;

private int id;

private String code;

@javax.xml.bind.annotation.XmlTransient()
private Continent continent;

....

@javax.xml.bind.annotation.XmlRootElement()
public class Continent {

private String name;
private int id;

private Set countries;

[/code]

lpurvis
Offline
Joined: 2005-12-05
Points: 0

Since the JAXB2 default is to use public "properties" (i.e. getter/setter methods), you probably need to set a class-level javax.xml.bind.annotation.XmlAccessorType(XmlAccessType.FIELD) annotation because you annotated the field rather than the getter/setter method.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

To be more precise, it defaults to public properties and fields. You can either use @XmlAccessorType annotation on a package, or you can also choose to put @XmlTransient on properties/fields that you don't want JAXB to bind.

jmcgarett
Offline
Joined: 2006-10-10
Points: 0

Thanks Greg and Kohsuke for your responses.

I now have a dum follow on question:

I am using netbeans to auto generate my WSDL based on annotations to EJBs. Since it is the generated code (and not code explicitly written by me) that is marshalling the java objects to/from xml, how do I set the new property JAX RI custom property OBJECT_IDENTITY_CYCLE_DETECTION on the Marshaller? I searched a fair bit on the web and I was even unable to find how to set a standard Marshaller property like JAXB_SCHEMA_LOCATION for situations where the marshalling is being done behind the scenes (i.e. the developer code never directly interacts with a Marshaller object).

Your help would much appreciated. Thanks.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

By using Marshaller.setProperty().

Maybe you are using JAXB through JAX-WS? In that case they don't let you set the marshaller properties.

jmcgarett
Offline
Joined: 2006-10-10
Points: 0

Sorry to bug you guys, but how will this approach work on the converse side where the XML needs to be converted back to a Java object? Really what I was wondering is that are there any plans for the RI to:

A. Automagically handle cyclic dependency on both Java to XML and XML to Java or

B. Is the developer expected to:

1. on Java to XML, use the newly added 'onCycleDetected' callback to setup custom XML creation and then

2. on XML to Java use the custom created XML in step 1, to deserialize appropriately and prevent duplicates in the reconstitued Java objects

I am just requesting to know which of the options A or B is being followed by the RI. If it's option A, any idea on when it will be available and how does the 'onCycleDetected' fit into that. If it's option B, are my sub-steps 1 & 2, the way to go or am I missing something.

Also will the 'gadams00' patches be applied to jaxb 2.1 only or also to the 2.0 tree also.

Thanks again for your time and effort for your assistance.

gadams00
Offline
Joined: 2006-05-08
Points: 0

I don't think there's a way to "automagically handle cyclic dependency". I suggested earlier in this thread that we use XmlId and XmlIdRef to solve the problem, but the issue with that is that the choice to use XmlId and XmlIdRef is a decision that must be made statically, since it affects the XML schema. Hence, you cannot make things serialize by containment when there is no cycle and by reference when there is a cycle. I'm afraid I'm not that much of an XML expert. Is there a way to represent object graphs with cyclical references in XML that can be expressed by a static schema?

Anyways, the way it looks like things are going is that we're going to have this CycleRecoverable interface that the marshalled bean classes can implement. In my example usage, I created a replacement object of the same class in onCycleDetected that contains only the id of the object causing the cycle (sort of a dummy reference). This obviously does create a difference in the object graph after marshalling and unmarshalling. I'm planning to use the afterUnmarshal callback to reinstantiate my object graph with cycles.

Is this how you're envisioning this feature, Kohsuke?

jeremiah
Offline
Joined: 2004-03-04
Points: 0

Has any progress been made on this? This is a show stopper level bug. I think it could be addressed if there was a way to bind the output to an xsd file. It would be rather nice to be able to include a xsd file in the Context and then limit the elements and attributes based on that schema. That way you could use different schema and produce different results.
I have code I wrote that does this using the reflection API, but I'd much rather drop it and use JAXB for instead. In trying to switch over was were I ran into this inifinate recursion error.
Thanx for any additional infor or ideas,
-jj-

zmonster
Offline
Joined: 2006-05-18
Points: 0

Yes, I too am interesting in knowing when the circular relationship bug will be fixed. In my opinion this should be of extremely high priority. JAXB is basically broken if the object model has a parent/child relationship where the child points back to the parent. This type of relationship is common place and I am very surprised to see that it is not support in JAXB 2.0.

Any word on a final release for JAXB 2.0.1, or 2.1, with hopes that this bug (and other showstoppers) will be formally fixed?

zmonster
Offline
Joined: 2006-05-18
Points: 0

Anyone? :)

Anyone know when this bug will be fixed, and more importantly, when the next maintenance release of JAXB will be shipped that includes this bug fix (i.e. 2.0.1, or 2.1)? Hopefully soon! This one is sort of a show stopper for us, and I may have to submit a fix myself (this is open source, eh)? If only there were more hours in the day. Ugh...

- Eric

zmonster
Offline
Joined: 2006-05-18
Points: 0

Hmm. Maybe I spoke to soon. Looks like there's a bug issue associated with this problem, and from the logs it looks like it may have been fixed yesterday with a 2.0.1 target. If so, thanks kohsuke! Now, just looking forward to the release of 2.0.1. :)

zmonster
Offline
Joined: 2006-05-18
Points: 0

Argh! I was under the assumption that the new version of JAXB, 2.0.1, would fix the circular relationship bug. However, it appears that the bug has not been fixed, but rather, the exception message displayed when the bug has been hit has been updated (see below). Needless to say, it's still broken, and I'm still screwed by this. Can anyone at Sun comment on when this bug will be fixed, or at least where I can start looking in the source in order to fix it myself?

[com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: com.tradecapture.liveprices.xml.livefeed.jaxb.LFExchange@3c03bb -> com.tradecapture.liveprices.xml.livefeed.jaxb.LFCommodity@3a342a -> com.tradecapture.liveprices.xml.livefeed.jaxb.LFExchange@3c03bb]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:295)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77)

tinashechipomho
Offline
Joined: 2005-01-24
Points: 0

Regarding this problem
i am now getting a useful error message
[b]
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: jaxbtesting.Parent@1aed5f9 -> jaxbtesting.Child@136a43c -> jaxbtesting.Parent@1aed5f9]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:295)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:70)

[/b]

still the problem is not fixed and I agree with most users this is a show stopper, someone need to reopen the bug.

tinashechipomho
Offline
Joined: 2005-01-24
Points: 0

Well in case you are wondering what I did, here is a simple simple and common case.

Parent.java
[code]
package jaxbtesting;
import java.util.List;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement()
public class Parent {
private String name;
private long age;
private String country;
private List children;

/** Creates a new instance of Parent */
public Parent() {
}

public Parent(String name,long age, String country) {
}

public void setChildren(List children){
this.children=children;
}
public void setName(String name){
this.name=name;
}
public void setAge(long age){
this.age = age;
}
public void setCountry(String country){
this.country=country;
}

public String getCountry(){
return country;
}
public String getName(){
return name;
}
public long getAge(){
return age;
}

public List getChildren(){
return children;
}

public void addChild(Child child){
if (children==null){
children = new ArrayList();
}
child.setParent(this);
children.add(child);
}
}
[/code]

Child.java
[code]
package jaxbtesting;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Child {

private String name;

private Parent parent;

/** Creates a new instance of Child */
public Child() {
}
public Child(String name) {
setName(name);
}

public void setName(String name){
this.name=name;
}
public void setParent(Parent parent){
this.parent=parent;
}
public String getName(){
return name;
}
public Parent getParent(){
return parent;
}
}
[/code]

and the main class
[code]
package jaxbtesting;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
public class Main {

/** Creates a new instance of Main */
public Main() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try{
System.out.println("Start JAXB Example...");
JAXBContext jc = JAXBContext.newInstance("jaxbtesting");
Marshaller m = jc.createMarshaller();
Parent parent = new Parent("Tinashe",30,"NZ");
parent.addChild(new Child("Melissa"));
m.marshal(parent,System.out);
}
catch(Exception ex){
ex.printStackTrace();
}
}

}
[/code]
with the corresponding jaxb.index
[code]
Parent
Child
[/code]

tinashechipomho
Offline
Joined: 2005-01-24
Points: 0

I manage to put a quick fix in my project, since i dont have any write access to the repository, i will simply explain what i did, it might help someone until the final fix is added.

in source class com.sun.xml.bind.v2.runtime.XMLSerializer the object is keep a CollisionCheckStack object to detect any circular references. I figured that why keep a stack
instead of keeping a set of all serialiazed objects. (i am sure it works better with you simply keep a set of hashcodes instead)
before you serialize an object check to see if its in the set if not serialize otherwise simply skip it.

so i added three public methods in this class

[code]
/**
*...
*/
public void registerBean(Object obj){
serializedObjects.add(obj);
}

/**
*...
*/
public boolean isRegistered(Object obj){
return serializedObjects.contains(obj);
}

/**
*...
*/
public void cleanUp(){
serializedObjects.clear();
}
[/code]

and i got rid of the statements (rendering the collision check stack ineffective).

[code]
cycleDetectionStack.pushNocheck(obj);
...
cycleDetectionStack.pop();
...
pushObject(obj);
..
[/code]

inside the class com.sun.xml.bind.v2.runtime.MarshellerImpl.cleanUp i added [b]serializer.cleanUp();[/b]

and inside the class [b]com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl[/b] I did the following

[code]
if (!target.isRegistered(bean)){
target.registerBean(bean);
for( Property p : properties ){
p.serializeBody(bean,target, null);
}
}
[/code]

to all the [b]serializeBody[/b] methods.

and the following test cases/classes worked

[code]
public class Parent {
private Parent parent;
private String name;
private long age;
private String country;
private List children;
.....
}

public class Child {
private String name;
private Parent parent;
}

[/code]

main
[code]
Parent parent = new Parent("Tinashe",30,"New Zealand");
Parent parent1 = new Parent("Parent1",40,"Aussie");
parent.setParent(parent1);
Child child = new Child("Melissa");
parent.addChild(child);
m.marshal(parent,System.out);
[/code]

hakin9
Offline
Joined: 2006-10-24
Points: 0

I just wanted to say that if you wish to know more about IT security, the techniques of breaking into computer as well as defence - go to http://www.en.hakin9.org/
You can also work for us - become a betatester or articles author. You are very welcome to visite our website or contact me magdalena.blaszczyk@software.com.pl

kohlert
Offline
Joined: 2003-06-16
Points: 0

We are discussing this and we will get back with you.

alimnemonic
Offline
Joined: 2006-03-10
Points: 0

Is there any new development concerning this issue...

kohlert
Offline
Joined: 2003-06-16
Points: 0

Unfortunately, this is not supported by JAX-WS but we should be giving a meaningful error message at runtime. If we are not giving a meaningful error, would you please send us the error that we are giving?

Thanks

fjean
Offline
Joined: 2004-08-25
Points: 0

Hello,

The error message says nothing about a recursive problem.

I'm sending you a part of the error message:

16:44:50,748 ERROR [STDERR] 2006-03-06 16:44:50 com.sun.xml.ws.transport.http.servlet.WSServletDelegate doPost
GRAVE: caught throwable
java.lang.StackOverflowError
at com.sun.xml.bind.v2.runtime.XMLSerializer.startElement(XMLSerializer.java:792)
at com.sun.xml.bind.v2.runtime.XMLSerializer.startElement(XMLSerializer.java:238)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:113)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfo
16:44:50,873 ERROR [STDERR] Impl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:592)

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Thanks. I filed https://jaxb.dev.java.net/issues/show_bug.cgi?id=139
so that we can fix this in JAXB.

pyanguas
Offline
Joined: 2006-03-30
Points: 0

Hello,

I have a similar problem with circular references in EJB3 entities, I hope it could be fixed too.

Basically, I have a relationship between two EJB3 entities, annotated with @OneToMany / @ManyToOne. I use @FetchType LAZY in both sides of the relation.

If I try to get one parent entity with a java client (using remote interface in a stateless ejb3 session bean), it works fine: I get only the parent entity.

But If I try to get the parent entity through a webservice (same ejb3 session bean annotated with @WebService), then I get similar StackOverflowError.

Could this be a different issue than https://jaxb.dev.java.net/issues/show_bug.cgi?id=139

Many thanks