wood burning stoves 2.0*
The moose likes Web Services and the fly likes More fun with JAXB, trying to implement Oasis WSN top down - errors genned Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "More fun with JAXB, trying to implement Oasis WSN top down - errors genned " Watch "More fun with JAXB, trying to implement Oasis WSN top down - errors genned " New topic

More fun with JAXB, trying to implement Oasis WSN top down - errors genned

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
Hi all (and hopefully Ivan):

I'm using wsconsume to generate artifacts for a JBoss 4.2 JAX-WS service (this is mentioned in one other post where I encountered JAXB errors)

There are JAXB errors related to the WSN Notification spec. The issue seems to be that some types are defined as QName with no parms and the generated code can't handle these.
It can't instantiate QName. If I modify the generated code to make it a String, it loads.

Here's a sample of what wsconsume gens:

protected List<QName> messageTypes;

public List<QName> getMessageTypes() {
if (messageTypes == null) {
messageTypes = new ArrayList<QName>();
return this.messageTypes;

the new ArrayList<QName>() is the problem - it causes a JAXB exception - no default constructor

And here is what AXIS2 gens:

public java.util.List getMessageTypes()

synchronized (monitor())



org.apache.xmlbeans.SimpleValue target = null;

target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(MESSAGETYPES$6);

if (target == null)


return null;


private static final javax.xml.namespace.QName MESSAGETYPES$6 = new javax.xml.namespace.QName("", "messageTypes");

So you can see AXIS2 creates the List with a QName("", "messageTypes")

and wsconsume (JAXB) does not

JAXB err

# java.lang.IllegalStateException: Cannot build JAXB context
# at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.createJAXBContext(JAXWSMetaDataBuilder.java:925)
# @XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
# this problem is related to the following location:
# at protected java.util.List org.oasis_open.docs.wsn.t_1.TopicType.messageTypes

So the problem is that the generated wsconsume stubs define messageTypes as List<QName>. If I change it to List<String> I get past the problem.
But obviously, this is not good. I want to implement the Oasis WSN spec and generate working stubs and go from there.

From the spec for this (Oasis WSN spec):

<xsd:attribute name="messageTypes">
<xsd:list itemType="xsd:QName"/>

Do I need to create JAXB binding files to somehow change the type of xsd:QName to something else? e.g. QName("", "messageTypes")
(I can pass binding files into the wsconsume process)
How can I do this?
Can I get a sample?

any help greatly appreciated.


Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Can you provide a link to the complete XML schema containing the data structure you have problems with?
I do not use Axis, but I am regardless curious to see what JAXB makes out of that schema.
I come to think of using a JAXB mapping file to map QName to String, but I will take a look and let you know.
Best wishes!

My free books and tutorials: http://www.slideshare.net/krizsan
Consider Paul's rocket mass heater.
subject: More fun with JAXB, trying to implement Oasis WSN top down - errors genned
Similar Threads
Top-Down approach: WSDL, JAX-WS and JAXB
Passing Set<java.lang.Object> and List<java.lang.Object> in Axis 2.0
Error creatin Top down web service with Eclipse Helios
Apache Axis versus JbossWS
JAXB annotation error