Hi,

As a follow-up to this issue, I finally fixed it by adding the list of
packages generated from the xsd schemas into a properties list for the
client so that JAXB could search this list when searching for the type.  I
don't really understand why I need to do this for this one particular
situation and not all the time but it did fix the problem for me.

Here is the code in the client call that I added:
Client client = ((XFireProxy) Proxy.getInvocationHandler(soap)).getClient();
client.setProperty(JaxbType.SEARCH_PACKAGES,
JaxbSchemaPackages.getPackageList());

JaxbSchemaPackages.getPackageList() just returns an ArrayList of strings
with all of the package names of the generated schema classes.

There is a short section showing this fix in the
http://xfire.codehaus.org/JAXB+2.0?nocache document but I did not really
understand what it meant until I looked at the code. 

Hopefully this info will help someone else that gets stuck with a similar
situation (or maybe even myself if it happens again and I forget what I did
to fix it).  :-)

Chad

-----Original Message-----
From: Chad Sapp [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 19, 2006 10:27 AM
To: [email protected]
Subject: [xfire-user] Error during JAXB marshall process with enum type
(XFire v1.2.2)

Hi,

I am getting an error marshalling an enumerated type.  Is there an open
issue with this in XFire 1.2.2?

Here is the stack trace from the exception:

org.codehaus.xfire.XFireRuntimeException: Could not invoke service..
Nested exception is org.codehaus.xfire.fault.XFireFault: Could not marshall
type.
org.codehaus.xfire.fault.XFireFault: Could not marshall type.
 at org.codehaus.xfire.jaxb2.JaxbType.writeObject(JaxbType.java:254)
 at
org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingPro
vider.java:200)
 at
org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBi
nding.java:273)
 at
org.codehaus.xfire.service.binding.DocumentBinding.writeMessage(DocumentBind
ing.java:65)
 at
org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80)
 at
org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpCh
annel.java:56)
 at
org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayReque
stEntity(CommonsHttpMessageSender.java:313)
 at
org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpM
essageSender.java:251)
 at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java
:123)
 at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
 at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
 at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
 at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
 at org.codehaus.xfire.client.Client.invoke(Client.java:335)
 at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
 at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
 at $Proxy13.testWebService(Unknown Source) Caused by:
javax.xml.bind.MarshalException
 - with linked exception:
[javax.xml.bind.JAXBException: com.sample.EnumCodeType is not known to this
context]  
 at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:295)
 at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:148)

 at org.codehaus.xfire.jaxb2.JaxbType.writeObject(JaxbType.java:249)
 ... 17 more
Caused by: javax.xml.bind.JAXBException: com.sample.EnumCodeType is not
known to this context  
 at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:223
)
 at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:238
)
 at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanI
nfoImpl.java:85)
 at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanI
nfoImpl.java:127)
 at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInf
oImpl.java:244)
 at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInf
oImpl.java:251)
 at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInf
oImpl.java:33)
 at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:461
)
 at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292)
 ... 19 more
Caused by: javax.xml.bind.JAXBException: com.sample.EnumCodeType is not
known to this context  
 at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java
:510)
 at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanI
nfoImpl.java:82)
 ... 25 more


Here is the com.sample.EnumCodeType that is generated by XFire:
-------------------------------------------------------------------
package com.sample;
import javax.xml.bind.annotation.XmlEnum;

/**
 * <p>Java class for EnumCodeType.
 *
 * <p>The following schema fragment specifies the expected content contained
within this class.
 * <p>
 * <pre>
 * &lt;simpleType name=3D"EnumCodeType">
 *   &lt;restriction base=3D"{http://www.w3.org/2001/XMLSchema}string";>
 *     &lt;enumeration value=3D"M"/>
 *     &lt;enumeration value=3D"F"/>
 *     &lt;enumeration value=3D"X"/>
 *     &lt;enumeration value=3D"N"/>
 *   &lt;/restriction>
 * &lt;/simpleType>
 * </pre>
 *
 */
@XmlEnum
public enum EnumCodeType {

    F,
    M,
    N,
    X;

    public String value() {
        return name();
    }

    public static EnumCodeType fromValue(String v) {
        return valueOf(v);
    }

}
------------------------------------------------------------------------

When I call the web service, I am passing "EnumCodeType.F" as an argument
where the EnumCodeType value is expected.  For example:

soap.testWebService(EnumCodeType.F);

Any ideas as to what I am doing wrong?

Thanks a lot!

Chad


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to