2016-08-09 34 views
1
zugreifen

Ich habe einen einfachen Java-Client erstellt, der XML-Nachricht basiert auf Klassen erstellt von XSD erstellt und dann sens es für den Web-Service. Es funktioniert gut, wenn ich es von meinem Arbeitsplatz testen, aber wenn ich Klassen zu Oracle-Datenbank zu laden erhalte ich folgende Fehlermeldung:kann nicht auf Superklasse von Klasse

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) 

Ich dachte, dass es von Klassen verursacht werden könnte, in verschiedenen Paketen sind, so dann zog ich alle Klassen zu den einzelnen Standard-Paket, aber es hat nicht geholfen. Ich habe auch alle geschützten/privaten Felder/Klassen durch öffentliche, immer noch das gleiche Problem ersetzt.

Das ist die Linie, wo ich denke, dass es fehlschlägt:

JAXBContext context = JAXBContext.newInstance(PurchaseOrder.class); 

jede Hilfe dankbar. Vielen Dank.

PurchaseOrder Klasse:

<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; 
    } 
} 

EDIT:

@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

Bitte geben Sie den Code der Klasse 'PurchaseOrder.class'. –

+0

Ich habe meinen Beitrag mit PurchaseOrder Klasse –

Antwort

0

Ich glaube, Sie shoud den XML-Typnamen wie entfernen:

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "", propOrder = { 
    "purchaseOptions" 
}) 
@XmlRootElement(name = "PurchaseOrder") 
public class PurchaseOrder { 
... 
} 
+0

aktualisiert. Danke Mickael. Die PurchaseOrder-Klasse verweist auf eine andere Klasse wie ArrayOfPurchaseOptionDescription (die in meinem Post hinzugefügt wurde), die dann auf die PurchaseOptionDescription-Klasse verweist. Es gibt viele andere Klassen, auf die verwiesen wird. Alle haben eine XMLType-Annotation mit name = class name. Denken Sie, ich sollte XMLType-Namensannotation in allen Klassen entfernen? Nicht sicher, wie das XMLType-Namensattribut mit der Fehlermeldung zusammenhängt, die ich erhalte. –