Author |
Message
|
ytnom_led |
Posted: Thu Jul 11, 2013 5:43 am Post subject: JAXB Marshal error - prefix "xmlns" cannot be boun |
|
|
Newbie
Joined: 10 Jul 2013 Posts: 5
|
Hi All,
I am trying to use JAXB in v8.0.0.1 to generate an XML message, but the XML generated is not valid. I have manually created an XSD --> generated a message set --> generated JAXB objects --> created new objects in a JavaCompute node --> Cast the object as a JAXBElement --> marshalled the object --> validated the message in the flow (validates fine). But I find that when I validate the XML independently in Broker Toolkit (by creating a new XML file and validating it) then it is not valid as the XML has the following:
Code: |
<ns2:MyData xmlns:ns2="http://myExampleSchema/Extended" xmlns:xmlns="http://myExampleSchema/Core"> |
The error i get when validating is:
Quote: |
The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly. |
I have followed advice I found on the web and added to the package-info.java like the code below…
Code: |
@XmlSchema(
namespace = "http://myExampleSchema",
elementFormDefault = XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(
prefix = "fred",
namespaceURI = "http://myExampleSchema/Core")
})
package my.package.jaxb;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlNsForm; |
This seems to have no affect. I have also tried another solution, to create my own NamespacePrefixMapper but I get the error below:
Quote: |
Access restriction, the type NamespacePrefixMapper is not accessible due to a restriction on the required library C:\Program Files\IBM\WMBT800\jdk\jre\lib\rt.jar |
Any advice about how i can change this prefix would be great,
Thanks for your time
(Please note that i work part time so may not reply immediately) |
|
Back to top |
|
 |
ytnom_led |
Posted: Thu Jul 11, 2013 5:44 am Post subject: |
|
|
Newbie
Joined: 10 Jul 2013 Posts: 5
|
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jul 11, 2013 5:52 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Try again with Toolkit 8.0.0.2?
I don't know that there are specific APARs in this area, but it sounds like a bug.
And there are a bunch of important fixes in 8.0.0.2 compared to 8.0.0.1 anyway, so better to get on the bandwagon and put yourself in position to open a PMR. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 11, 2013 6:22 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Sounds like a defect in the product. Please do as mqjeff suggests. |
|
Back to top |
|
 |
ytnom_led |
Posted: Thu Jul 11, 2013 6:49 am Post subject: |
|
|
Newbie
Joined: 10 Jul 2013 Posts: 5
|
Thank you for your comments, I can hopefully test on v8.0.0.2 from next week, and a PMR should be on its way. I looked through the APARs but couldn't see anything related either.
In the mean time, could anyone please explain why I wouldn't be able to access the NamespacePrefixMapper?
thank you |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 11, 2013 7:56 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Did you also try the following: note the difference in the association with xmlns:
Code: |
@XmlSchema(
namespace = "http://myExampleSchema",
elementFormDefault = XmlNsForm.QUALIFIED,
@XmlNs(
prefix = "fred",
namespaceURI = "http://myExampleSchema/Core")
)
package my.package.jaxb;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlNsForm; |
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ytnom_led |
Posted: Mon Jul 15, 2013 11:41 pm Post subject: |
|
|
Newbie
Joined: 10 Jul 2013 Posts: 5
|
Here's an update:-
I have now tested on Z/OS v8.0.0.2 & Windows v8.0.0.1 with the same result. A PMR is open at the minute.
Thank you for your suggestion fjb_saper, but that code had an error when i tried it, I believe it's because XmlSchema is expecting the code below in order to know which attribute to set.
|
|
Back to top |
|
 |
ytnom_led |
Posted: Mon Jul 22, 2013 5:54 am Post subject: |
|
|
Newbie
Joined: 10 Jul 2013 Posts: 5
|
|
Back to top |
|
 |
|