Skip to Content
0
Former Member
Jun 10, 2009 at 08:21 AM

JaxB returns incompatible type class

124 Views

Hi,

I want to use JaxB to parse an XML inside an EJB. I got the eclipse plugin for doing that and exchanged delivered JaxB 2.1 with the one I found in NWDS 7.10 SP7 (JaxB 2.0).

Generated Java Files show as comment: "This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0-b52-fcs..."

I get the same file structure as when I create web service stub in EJB with object factory and package info etc.

When I run that on server I get:

javax.ejb.EJBException: Exception raised from invocation of public 
de.aseaco.cf.uif.tree.xml.TreeType 
de.aseaco.cf.uif.tree.ejb.TreeHolderBean.loadTree(java.lang.String) method on bean instance 
de.aseaco.cf.uif.tree.ejb.TreeHolderBean @ 1a06a08f for bean 
uif.cf.aseaco.de/uif*annotation|uif.cf.aseaco.de~addin~tree.jar*annotation|TreeHolderBean; 
nested exception is: 
java.lang.ClassCastException: class javax.xml.bind.JAXBElement:library:jaxb20 @ 
com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 10ed7f5c @ alive 
incompatible with class 
de.aseaco.cf.uif.tree.xml.TreeType:uif.cf.aseaco.de/uif @ 
com.sap.engine.boot.loader.ResourceMultiParentClassLoader@6a5040e2 @ alive

TreeType is my generated class from JaxB, TreeHolderBean a stateless EJB calling the Unmarshaller.

This JaxBElement I find in my generated ObjectFactory:

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link TreeType }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://www.aseaco.de/tree_schema/", name = "tree")
    public JAXBElement<TreeType> createTree(TreeType value) {
        return new JAXBElement<TreeType>(_Tree_QNAME, TreeType.class, null, value);
    }

Such a statement I do not find in web service ObjectFactory... Can someone give me a hint, whats going wrong here?

I tried to create a library DC with JaxB 2.1 jars and creating again with 2.1. I also tried to add the 2.1 libs directly in a libs folder of my DC, but it looks like it always references the server package.

Thx,

Frank