我创建了一个简单的java客户端,它根据从XSD生成的类构建XML消息,然后将其感知到Web服务。 当我从我的工作站测试它时工作正常但是当我将类加载到Oracle数据库时,我得到以下错误:
Exception in thread "Root Thread" java.lang.IllegalAccessError: cannot access superclass from class
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java)
at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java)
at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Proxy.newInstance(Proxy.java)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java)
at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java)
at java.lang.reflect.Field.declaredAnnotations(Field.java)
at java.lang.reflect.Field.getDeclaredAnnotations(Field.java)
at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java)
at com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getAllFieldAnnotations(RuntimeInlineAnnotationReader.java)
at com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getAllFieldAnnotations(RuntimeInlineAnnotationReader.java)
at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.findFieldProperties(ClassInfoImpl.java)
at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java)
我认为它可能是由于类在不同的包中引起的,所以我将所有类都移到了单个默认包但它没有帮助。 我还将所有受保护/私有字段/类替换为公共,仍然是同一个问题。
这是我认为它失败的路线:
JAXBContext context = JAXBContext.newInstance(PurchaseOrder.class);
感谢任何帮助。感谢。
PurchaseOrder类:
<code>
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;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PurchaseOrder", propOrder = {
"purchaseOptions"
})
@XmlRootElement(name = "PurchaseOrder")
public class PurchaseOrder {
@XmlElement(name = "PurchaseOptions")
public ArrayOfPurchaseOptionDescription purchaseOptions;
public ArrayOfPurchaseOptionDescription getPurchaseOptions() {
return purchaseOptions;
}
public void setPurchaseOptions(ArrayOfPurchaseOptionDescription value) {
this.purchaseOptions = value;
}
}
编辑:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfPurchaseOptionDescription", propOrder = {
"purchaseOptionDescription"
})
public class ArrayOfPurchaseOptionDescription {
@XmlElement(name = "PurchaseOptionDescription", nillable = true)
public List<PurchaseOptionDescription> purchaseOptionDescription;
public List<PurchaseOptionDescription> getPurchaseOptionDescription() {
if (purchaseOptionDescription == null) {
purchaseOptionDescription = new ArrayList<PurchaseOptionDescription>();
}
return this.purchaseOptionDescription;
}
}
答案 0 :(得分:0)
我认为你应该删除XML类型名称,如:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"purchaseOptions"
})
@XmlRootElement(name = "PurchaseOrder")
public class PurchaseOrder {
...
}