File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes BEA/Weblogic and the fly likes WebLogic: @XmlJavaTypeAdapter doesn't work properly when using subclassed adapters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "WebLogic: @XmlJavaTypeAdapter doesn Watch "WebLogic: @XmlJavaTypeAdapter doesn New topic
Author

WebLogic: @XmlJavaTypeAdapter doesn't work properly when using subclassed adapters

Rob Isaacs
Greenhorn

Joined: Mar 12, 2014
Posts: 20
And yet another issue with WebLogic...


I have a number of XmlAdapter implementations. These work just fine. However, they contains a lot of shared code, so I tried to refactor most of it into an abstract super class. This compiles just fine, but WebLogic will then ignore the XmlAdapters for unmarshalling incoming request. I've put a breakpoint in the unmarshal method of the base class but that was never called.

The old (working) version:
The non-working version with base class:
With this code unmarshalling now fails. MyClass and BaseClass do not have a non-arg constructor so I get an exception about that constructor missing. If I add it, I get an exception that MyClass cannot be cast to String.

Am I doing something wrong, or is WebLogic (MOXy) unable to handle this simple case? If I use JAXB.unmarshal in a standalone program it works, so it's probably MOXy that's causing the problems.


Disclaimer: our client has specified that we should WebLogic. We can't switch to something we know better (and has fewer issues).
German Gonzalez-Morris
Ranch Hand

Joined: Nov 16, 2009
Posts: 155

which WLS version are you using ?


http://devwebcl.blogspot.com/
German Gonzalez-Morris
Ranch Hand

Joined: Nov 16, 2009
Posts: 155

If you are using 12.1.2 then probably you may want to change the default (MOXy) to Glassfish :

EclipseLink MOXy is the default data binding and JAXB provider, however you can change to Glassfish JAXB implementation.

http://docs.oracle.com/middleware/1212/wls/WSGET/jax-ws-datatypes.htm#WSGET345


Regards,

Germán
Rob Isaacs
Greenhorn

Joined: Mar 12, 2014
Posts: 20
We are using 12.1.2.1, so we will consider that. Since we're going to use JSON only we are also considering Jackson; we've already found out we can use that by creating a sub class of JacksonJsonProvider and marking it with @Provider.

However, I think I have found the cause. For MOXy to pickup the bound type or value type, that must be a generic value of the concrete class. By moving the String part to the concrete class it works:
This is a bit of a hack, and Eclipse (correctly) complains that I shouldn't use final class String as a bound.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WebLogic: @XmlJavaTypeAdapter doesn't work properly when using subclassed adapters
 
Similar Threads
Wanted: Help serializing Generic Maps!
How to Serialize Maps?
JAXB - HashMap
String to joda LocalDate fromat of "dd-MMM-yy"
How to add JAXB customization to a particular element of an xsd?