我遇到了以下技术堆栈的非常奇怪的问题:
Weblogic 12c JDK 1.7 Axis2 1.5.2集成了JAXB
活动:将项目从Weblogic 10.3.6升级到12.1.1,包括JDK从1.6升级到1.7
问题描述:在创建OM元素时,JAXB在子对象下放置子对象的对象ID而不是参数值。这个问题只出现在JDK 1.7中,因为它在JDK 1.6中完美运行
Request.java
import java.math.BigInteger;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{http://w3.org.com/spec/prd/services/2011/02}NumberOfNotes"/>
* <element ref="{http://w3.org.com/spec/prd/services/2011/02}NoteData"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"NumberOfNotes",
"NoteData"
})
@XmlRootElement(name = "Request")
public class Request {
@XmlElement(required = true)
@XmlSchemaType(name = "nonNegativeInteger")
protected BigInteger NumberOfNotes;
@XmlElement(name = "NoteData", required = true)
protected NoteData NoteData;
/**
* Gets the value of the NumberOfNotes property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getNumberOfNotes() {
return NumberOfNotes;
}
/**
* Sets the value of the NumberOfNotes property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setNumberOfNotes(BigInteger value) {
this.NumberOfNotes = value;
}
/**
* Gets the value of the NoteData property.
*
* @return
* possible object is
* {@link NoteData }
*
*/
public NoteData getNoteData() {
return NoteData;
}
/**
* Sets the value of the NoteData property.
*
* @param value
* allowed object is
* {@link NoteData }
*
*/
public void setNoteData(NoteData value) {
this.NoteData = value;
}
}
NoteData.java
package com.org.w3.spec.prd.services._2011._02;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="NoteDataDetails" maxOccurs="50" minOccurs="0">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{http://w3.org.com/spec/prd/services/2011/02}numberOfNoteLines"/>
* <sequence>
* <element ref="{http://w3.org.com/spec/prd/services/2011/02}NoteLineText" maxOccurs="10" minOccurs="0"/>
* </sequence>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"NoteDataDetails"
})
@XmlRootElement(name = "NoteData")
public class NoteData {
protected List<NoteData.NoteDataDetails> NoteDataDetails;
/**
* Gets the value of the NoteDataDetails property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the NoteDataDetails property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getNoteDataDetails().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link NoteData.NoteDataDetails }
*
*
*/
public List<NoteData.NoteDataDetails> getNoteDataDetails() {
if (NoteDataDetails == null) {
NoteDataDetails = new ArrayList<NoteData.NoteDataDetails>();
}
return this.NoteDataDetails;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{http://w3.org.com/spec/prd/services/2011/02}numberOfNoteLines"/>
* <sequence>
* <element ref="{http://w3.org.com/spec/prd/services/2011/02}NoteLineText" maxOccurs="10" minOccurs="0"/>
* </sequence>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"numberOfNoteLines",
"NoteLineText"
})
public static class NoteDataDetails {
@XmlElement(required = true)
protected BigInteger numberOfNoteLines;
@XmlElement(required = true)
protected List<NoteLineText> NoteLineText;
/**
* Gets the value of the numberOfNoteLines property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getNumberOfNoteLines() {
return numberOfNoteLines;
}
/**
* Sets the value of the numberOfNoteLines property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setNumberOfNoteLines(BigInteger value) {
this.numberOfNoteLines = value;
}
/**
* Gets the value of the NoteLineText property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the NoteLineText property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getNoteLineText().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link NoteLineText }
*
*
*/
public List<NoteLineText> getNoteLineText() {
if (NoteLineText == null) {
NoteLineText = new ArrayList<NoteLineText>();
}
return this.NoteLineText;
}
}
}
NoteLoneText.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Line">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <maxLength value="50"/>
* <whiteSpace value="collapse"/>
* </restriction>
* </simpleType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"line"
})
@XmlRootElement(name = "NoteLineText")
public class NoteLineText {
@XmlElement(name = "Line", required = true)
protected String line;
/**
* Gets the value of the line property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLine() {
return line;
}
/**
* Sets the value of the line property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLine(String value) {
this.line = value;
}
}
SendNoteStub.java
private org.apache.axiom.om.OMElement toOM(com.org.w3.spec.prd.services._2011._02.prdAddNoteRes param, boolean optimizeContent)
throws org.apache.axis2.AxisFault {
try {
javax.xml.bind.JAXBContext context = wsContext;
javax.xml.bind.Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
org.apache.axiom.om.OMFactory factory = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
JaxbRIDataSource source = new JaxbRIDataSource( com.org.w3.spec.prd.services._2011._02.prdAddNoteRes.class,
param,
marshaller,
"http://w3.org.com/spec/prd/services/2011/02",
"AddNoteRes");
org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace("http://w3.org.com/spec/prd/services/2011/02",
null);
return factory.createOMElement(source, "prdAddNoteRes", namespace);
} catch (javax.xml.bind.JAXBException bex){
throw org.apache.axis2.AxisFault.makeFault(bex);
}
}
生成的XML:
<PrdAddLoanNoteReq xmlns="http://w3.org.com/spec/Prd/services/2011/02"><transactionId>BZNSQT</transactionId><numberOfLoanNotes>1</numberOfLoanNotes><LoanNoteData><loanNoteDataDetails><numberOfLoanNoteLines>3</numberOfLoanNoteLines><loanNoteLineText>com.org.w3.spec.Prd.services._2011._02.LoanNoteLineText@1182716</loanNoteLineText><loanNoteLineText>com.org.w3.spec.Prd.services._2011._02.LoanNoteLineText@58ae15e9</loanNoteLineText><loanNoteLineText>com.org.w3.spec.Prd.services._2011._02.LoanNoteLineText@d20a17b</loanNoteLineText></loanNoteDataDetails></LoanNoteData></PrdAddLoanNoteReq>
生成的XML中的问题是在LoanNoteLineText标记下,JAXB正在放置Object ID而不是参数Line的值。
对此方面的任何帮助表示高度赞赏。
非常感谢。
答案 0 :(得分:1)
由于加载了错误的JAXB实现,因此发生此问题。更新Weblogic Start-up Arguments解决了这个问题。