JAXB 2.1 does not unmarshal like 2.0

View: New views
5 Messages — Rating Filter:   Alert me  

JAXB 2.1 does not unmarshal like 2.0

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I upgraded from JDK 6u3 to u5. I think u3 had JAXB 2.0, and it was upgraded to 2.1 for u5. So my issue is probably a JAXB 2.0 to JAXB 2.1 issue.

The problem is that I had one List XmlElement that was mapped to any of sub-classes using something like:
[code]
class AB {
}
@XmlRootElement
class A extends AB {
}
@XmlRootElement
class B extends AB {
}
@XmlRootElement
class Compound {
 
@XmlElements({
  @XmlElement(type=a.class),
  @XmlElement(type=b.class)
})
  List<AB> getSubs() {
    // return the list..
  }
  void setSubs(List<AB> newList) {
    // set the list
  }
}
[/code]
The generated xml is something like:
[code]
<Compound p="v">
    <a p="v2"/>
    <a p="v3"/>
    <b p="v4"/>
</Compound>
[/code]

All was Okay, until the upgrade. I put a breakpoint when unmarshaling on the setList method, and the newList param to the method is an empty list. It used to be the list of AB objects a,a,b.

I tested the same code and xml again in u3, and it works.  The same build (no recompilation) from u5 was used in u3.
[Message sent by forum member 'aymanhs' (aymanhs)]

http://forums.java.net/jive/thread.jspa?messageID=266266

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: JAXB 2.1 does not unmarshal like 2.0

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

See this forum msg: http://forums.java.net/jive/message.jspa?messageID=262279#262279

and this JIRA issue: https://jaxb.dev.java.net/issues/show_bug.cgi?id=488 (please consider casting your vote for that issue).  I put an example in that issue is similar yours.  I also included one that handles the list of polymorphic elements as if they were separate lists of monomorphic(?) elements, and that fails now, too.

This seems like a very important issue to fix.
[Message sent by forum member 'dharland' (dharland)]

http://forums.java.net/jive/thread.jspa?messageID=266283

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: JAXB 2.1 does not unmarshal like 2.0

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

JAXB 2.1.7 was just released.  I still have the same trouble, but it would be helpful if you could try that version as well (just in case i think i'm using it but have made a mistake).
[Message sent by forum member 'dharland' (dharland)]

http://forums.java.net/jive/thread.jspa?messageID=274173

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: JAXB 2.1 does not unmarshal like 2.0

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I posted a work-around here: http://forums.java.net/jive/thread.jspa?threadID=41000&tstart=0
[Message sent by forum member 'dharland' (dharland)]

http://forums.java.net/jive/thread.jspa?messageID=274712

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: JAXB 2.1 does not unmarshal like 2.0

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Was this ever fixed, if so what version was it fixed in?  The java.net bug report does not include a JAXB 2.1.x version where the setters were supposed to be called once again.

I just ran into this when trying to get an application to work on glassfish.  Glassfish includes a broken version of jaxb 2.1 which is being used (instead of the working version which I packaged with my war file).  Anyone know how to control this behavior on glassfish?

There seem to be some complicated methods to control class loading on glassfish, I just want a "MAKE IT WORK" option, like the <prefer-web-inf-classes>true</prefer-web-inf-classes> option on weblogic.  Does anyone know of the analogy on glassfish?
[Message sent by forum member 'suggarglider' (jsands@...)]

http://forums.java.net/jive/thread.jspa?messageID=370933

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...