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

JaxB returns incompatible type class



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 method on bean instance @ 1a06a08f for bean*annotation|*annotation|TreeHolderBean; 
nested exception is: 
java.lang.ClassCastException: class javax.xml.bind.JAXBElement:library:jaxb20 @ @ 10ed7f5c @ alive 
incompatible with class @ @ 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 = "", 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.