Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rob Isaacs
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which WLS version are you using ?
 
German Gonzalez-Morris
Ranch Hand
Posts: 263
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic