Reputation: 83
Application migration to 12c and jaxb is not working on it
The application is currently on Weblogic 10 and consumes some webservices. We post the XML directly to the webservice using HttpURLConnection. Before posting we marshal the request and after receiving the response we unmarshall them
The app needs to be migrated on 12c and when we tested the app on 12c , it was not working the same. The request that was sent to the webservice had a difference.Please see below the schema, java classes and marshalled request
Refund.xsd
----------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:avis="http://www.avis.com/XMLSchema" elementFormDefault="unqualified">
<xsd:element name="RefundRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Request" avis:usage="ups"/>
<xsd:element ref="DeliveryNumber" avis:usage="ups"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<!-- Request and DeliveryNumber attributes her -->
Generated the Refund.java and related classes using Eclipse-->Generate--> JAxB classes. am behind a firewall and in teh JAXB wizard it did ask me for a proxy. I didnt provide any poxy. Generted class
Refund.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "",propOrder = {
"request",
"barCodeDeliveryNumber"
})
@XmlRootElement(name = "TrackRequest")
public class RefundRequest{
@XmlElement(name = "Request", required = true)
protected Request request;
@XmlElement(name = "DeliveryNumber", required = true)
protected String deliveryNumber;
/**
* Gets the value of the request property.
*
* @return
* possible object is
* {@link Request }
*
*/
public Request getRequest() {
return request;
}
/**
* Sets the value of the request property.
*
* @param value
* allowed object is
* {@link Request }
*
*/
public void setRequest(Request value) {
this.request = value;
}
/**
* Gets the value of the DeliveryNumber property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDeliveryNumber() {
return barCodeDeliveryNumber;
}
/**
* Sets the value of the barCodeDeliveryNumber property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDeliveryNumber(String value) {
this.barCodeDeliveryNumber = value;
}
Am marshalling the object to XML(see below) and passing it to the web service . Web service returns "XML not well formed"
javax.annotation_1.0.jar
javax.annotation_1.1.jar
javax.persistence_1.0.0.0_1-0.jar
javax.persistence_1.0.1.0_1-0.jar
javax.xml.bind_2.0.jar
javax.xml.bind_2.1.1.jar
jaxb-api.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
jsr181-api.jar
jsr250-api.jar
Weblogic 12c using jrockit160_29
private static Marshaller mreqinfo;
JAXBContext jxcreq =JAXBContext.newInstance(RefundRequest.class.getPackage().getName());
mreqinfo=jxcreq.createMarshaller();
mreqinfo.marshall(refundRequestObj)
Looking at the logs , i could see the teh following marshalled request on weblogic 12c. There is an xmlns:ns0="" which i think is creating the problem
**Marshalled Request - not working one when tried in weblogic 12c jrockit160_29 .**
Need to get rid of the xmlns:ns0=""
<?xml version="1.0" encoding="UTF-8"?>
<RefundRequest xmlns:ns0="">
<Request>
<TransactionReference>
<CustomerContext>YILE00010208201120.04.08.4|11/22/2013 12:28:31:085</CustomerContext>
</TransactionReference>
<RequestAction>Refund</RequestAction>
</Request>
<DeliveryNumber>974869</DeliveryNumber>
</RefundRequest>
***Marshalled Request in Weblogic 10 (existing working version in weblogic 10 jrockit160_29
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RefundRequest>
<Request>
<TransactionReference>
<CustomerContext>YILE00010208201120.04.08.4|11/22/2013 12:28:31:085</CustomerContext>
</TransactionReference>
<RequestAction>Refund</RequestAction>
</Request>
<DeliveryNumber>974869</DeliveryNumber>
</RefundRequest>
Upvotes: 4
Views: 8501
Reputation: 107
Had the same problem: JAXB placing prefixes like < ns0:TagName>. Solved by adding prefer-application-resources to weblogic-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
<prefer-application-resources>
<resource-name>META-INF/services/javax.xml.bind.*</resource-name>
</prefer-application-resources>
</weblogic-application>
Upvotes: 0
Reputation: 51
To fix this issue, you can add your own jaxb jars (jaxb-core.jar, jaxb-impl.jar) by overriding the jaxb jars in Weblogic 12c. You can do this by placing your own jaxb jars into your war, under WEB-INF/lib and configure the weblogic.xml by using the prefer-web-inf-classes element tag. Then place the weblogic.xml under WEB-INF directory of your war
prefer-web-inf-classes Element
The weblogic.xml Web application deployment descriptor contains a element (a sub-element of the element). By default, this element is set to False. Setting this element to True subverts the classloader delegation model so that class definitions from the Web application are loaded in preference to class definitions in higher-level classloaders. This allows a Web application to use its own version of a third-party class, which might also be part of WebLogic Server.
Refer to this link for more details http://docs.oracle.com/cd/E13222_01/wls/docs90/programming/classloading.html
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.</wls:weblogic-version>
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
<wls:container-descriptor>
<wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
</wls:container-descriptor>
<wls:context-root>your_context_root_name</wls:context-root>
Upvotes: 0
Reputation: 149037
In WebLogic 12.1.1 which you are using EclipseLink JAXB (MOXy) is used as the default JAXB (JSR-222) provider (see: http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb-provider-in.html). The issue that you are hitting is due to a bug that has since been fixed in the EclipseLink 2.3.3 release (current release is EclipseLink 2.5.1).
Below is a link with instructions on using a newer version of EclipseLink in WebLogic:
If you are an Oracle Support customer then you can communicate with them to request an official patch for this issue.
Upvotes: 1