JAXB ClassCastException

Hi
Hope someone can help here
[EDIT] Xjc compiles cpu.xsd perfectly fine[EDIT]
I'm trying to unmarshal an xml document and i get the following error (When running in Netbeans:
init:
deps-jar:
compile:
run:
java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to generated.CPU
        at jaxbtest.Main.main(Main.java:24)
BUILD SUCCESSFUL (total time: 0 seconds)The following are my source documents:
cpu.xml
<?xml version="1.0" encoding="UTF-8"?>
<cpu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="cpu.xsd">
     <numcores>4</numcores>
     <registers>32</registers>
</cpu>cpu.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <xsd:element name="cpu" type="CPU"/>
     <xsd:complexType name="CPU">
          <xsd:sequence>
               <xsd:element name="numcores" type="xsd:int"/>
               <xsd:element name="registers" type="xsd:int"/>
          </xsd:sequence>
     </xsd:complexType>
</xsd:schema>Main.java
package jaxbtest;
import generated.*;
import javax.xml.bind.*;
import java.io.*;
public class Main
     public static void main(String[] args)
          try
               JAXBContext jc = JAXBContext.newInstance("generated");
               Unmarshaller u = jc.createUnmarshaller();
               CPU cpu = (CPU) u.unmarshal(new File("cpu.xml"));
               System.out.println(cpu.getRegisters());
          catch (Exception e)
               e.printStackTrace();
}ObjectFactory.java (Created by xjc)
package generated;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
@XmlRegistry
public class ObjectFactory {
    private final static QName _Cpu_QNAME = new QName("", "cpu");
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated
    public ObjectFactory() {
     * Create an instance of {@link CPU }
    public CPU createCPU() {
        return new CPU();
     * Create an instance of {@link JAXBElement }{@code <}{@link CPU }{@code >}}
    @XmlElementDecl(namespace = "", name = "cpu")
    public JAXBElement<CPU> createCpu(CPU value) {
        return new JAXBElement<CPU>(_Cpu_QNAME, CPU.class, null, value);
}CPU.java (Also created by xjc)
package generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CPU", propOrder = {
    "numcores",
    "registers"
public class CPU {
    protected int numcores;
    protected int registers;
     * Gets the value of the numcores property.
    public int getNumcores() {
        return numcores;
     * Sets the value of the numcores property.
    public void setNumcores(int value) {
        this.numcores = value;
     * Gets the value of the registers property.
    public int getRegisters() {
        return registers;
     * Sets the value of the registers property.
    public void setRegisters(int value) {
        this.registers = value;
}Am I doing anything wrong? Can anyone please help?
Thanks very much.
bish

HI,
I was looking for good solution to this problem, better than this one.
Your solution is just temporary, I do not want to cast twice. So after own research I found out that this error
is caused when JAXB cannot find main type. It will happen if main tag has type declared outside this tag:
<xs:element name="egzam">
        <xs:unique name="egzamId">
            <xs:selector xpath="." />
            <xs:field xpath="@id" />
        </xs:unique>
    </xs:element>
    <xs:complexType name="egzam">
        <xs:sequence minOccurs="1" maxOccurs="unbounded">
            <xs:element name="question" type="egzamQuestion">
                <xs:unique name="questionId">
                    <xs:selector xpath="." />
                    <xs:field xpath="@id" />
                </xs:unique>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="id" type="xs:string" use="required" />
    </xs:complexType>If we do not define external type in main tag, classCastException dissapear:
<xs:element name="egzam">
        <xs:complexType>
            <xs:sequence minOccurs="1" maxOccurs="unbounded">
                <xs:element name="question" type="egzamQuestion">
                    <xs:unique name="questionId">
                        <xs:selector xpath="." />
                        <xs:field xpath="@id" />
                    </xs:unique>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:string" use="required" />
        </xs:complexType>
        <xs:unique name="egzamId">
            <xs:selector xpath="." />
            <xs:field xpath="@id" />
        </xs:unique>
    </xs:element>Edited by: maciekcom on Nov 1, 2008 2:24 PM

Similar Messages

  • JAXB : ClassCastException while using generated java objects

    Hi,
    I am using JAXB for unmarshalling my xml to set of java objects. It is working but when i use one child object and cast it i am getting ClassCastException.
    java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to com.xyz.base.EmployeeType
    My XSD
    ======
    <xsd:complexType name="EmployeeType">
    </xsd:complexType>
    <xsd:complexType name="EmployeeList">
         <xsd:sequence>
              <xsd:element name="Employee" type="base:EmployeeType" maxOccurs="unbounded"/>
         </xsd:sequence>
    </xsd:complexType>
    JAXB Binding
    ==========
    In Binding i am direct schema compiler to use ArrayList for EmployeeList.. as i want to use this as ArrayList.
    <jxb:bindings node="//xs:complexType[@name='EmployeeList']">
              <jxb:class ref="java.util.ArrayList"/>
    </jxb:bindings>
    Everything works well but when i extract element from EmployeeList (i.e. ArrayList) and try to type cast it to EmployeeType, getting following exception:
    java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to com.xyz.base.EmployeeType
    so at the time of unmarshalling how jaxb will know about the type of child element and use accordingly.
    Any help would be greatly appreciated.

    Hi,
    Could you try outputting the class type of the object you are trying to cast?
    Check the class of the object. Say use object.class.getName().
    I used jaxb quite a long time ago but I believe it resolves the classes correctly.

  • Toplink JAXB - ClassCastException after redeploy in OC4J

    Hi,
    I'm experiencing an issue casting an unmarshalled object after the application is being redeployed in the container.
    I'm trying to unmarshall an xml that I retrieve as a resource from the classloader (the xml is also in the jar)
    The ClassCastException is being thrown at the point where I try to cast the unmarshalled object. A sysout on the unmarshalled object prints a classtype that I expect, so my first impression is that the cast fails due the ClassLoader used by the JAXBContext (?) So I've tried to create the JAXBContext with the ClassLoader parameter using the class' classloader directly and the contextClassLoader, both unsuccessfull.
    The problem solves after I restart the OC4J container, but for convenience, I would like to solve this without having to restart, if possible.
    Has anyone experienced this problem, or know a solution?
    Thx!
    Bert
    Below, some example code and the console output on the server.
    Code:
    /* create the jaxb context */
    JAXBContext context = JAXBContext.newInstance(
              "be.cm.apps.tpb.common.helper",
         Thread.currentThread().getContextClassLoader());
    if (LOGGER.isDebugEnabled()) {
         LOGGER.debug("JAXBContext=" + context);
    /* create unmarshaller */
    Unmarshaller unmarshaller = context.createUnmarshaller();
    if (LOGGER.isDebugEnabled()) {
         LOGGER.debug("Unmarshaller=" + unmarshaller);
    /* open refac-config.xml as inputstream */
    URL url = Thread.currentThread().getContextClassLoader().getResource(CONFIGURATION);
    if (LOGGER.isDebugEnabled()) {
         LOGGER.debug("url: " + url);
    /* unmarshall the configuration */
    Object unmarshalledObject = unmarshaller.unmarshal(url);
    if (LOGGER.isDebugEnabled()) {
         LOGGER.debug("unmarshalled object: " + unmarshalledObject);
    * THROWS CLASSCASTEXCEPTION AFTER REDEPLOY
    configurationDefinition = (ConfigurationDefinition) unmarshalledObject;
    if (LOGGER.isDebugEnabled()) {
         LOGGER.debug("<- initialize()");
    Output:
    |DEBUG|JAXBContext=oracle.toplink.ox.jaxb.JAXBContext@675f26|º@#
    |DEBUG|Unmarshaller=oracle.toplink.ox.jaxb.JAXBUnmarshaller@97dadf|º@#
    |DEBUG|url: code-source:/C:/java/101310/j2ee/home/applications/tpb/tpb-online-1.0.0.jar!/refac-config.xml|º@#
    |DEBUG|unmarshalled object: be.cm.apps.tpb.common.helper.ConfigurationDefinition@8f310f|º@#
    |ERROR|Unable to create BusinessFacade instance named be.cm.apps.tpb.business.facade.SendingManager|
    Caused by: java.lang.ClassCastException: be.cm.apps.tpb.common.helper.ConfigurationDefinition
    at be.cm.apps.tpb.common.helper.ConfigHelper.initialize(ConfigHelper.java:93)
    ... 83 more

    Hello Bert,
    This is a known issue and there is a patch that is available from Oracle Support. When you contact support please indicate whether you are using TopLink 10.1.3 or 10.1.3.1. Also you can refer Oracle Support to me and I can help them find the correct patch.
    -Blaise

  • Jaxb ClassCastException in IdentifiableObject

    Hi all. I'm using JWSDP 1.5; i have a w3 schema and i'm using Jaxb for Marshalling and Unmarshalling.
    Well i have this error when i try to Marshall:
    DefaultValidationEventHandler: [ERROR]: java.lang.ClassCastException
         Location:  obj: it.eng.utility.pec.jaxb.impl.PersonaImpl@1a918d5
    18:23:55,534 ERROR [Main] errore
    java.lang.ClassCastException
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.reportError(SAXMarshaller.java:436)
         at it.eng.utility.pec.jaxb.impl.runtime.Util.handlePrintConversionException(Util.java:47)
         at it.eng.utility.pec.jaxb.impl.PersonaTypeImpl.serializeAttributes(PersonaTypeImpl.java:186)
         at it.eng.utility.pec.jaxb.impl.PersonaImpl.serializeBody(PersonaImpl.java:41)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.DestinatarioTypeImpl.serializeBody(DestinatarioTypeImpl.java:153)
         at it.eng.utility.pec.jaxb.impl.DestinatarioImpl.serializeBody(DestinatarioImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.DestinazioneTypeImpl.serializeBody(DestinazioneTypeImpl.java:77)
         at it.eng.utility.pec.jaxb.impl.DestinazioneImpl.serializeBody(DestinazioneImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.IntestazioneTypeImpl.serializeBody(IntestazioneTypeImpl.java:219)
         at it.eng.utility.pec.jaxb.impl.IntestazioneImpl.serializeBody(IntestazioneImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.SegnaturaTypeImpl.serializeBody(SegnaturaTypeImpl.java:74)
         at it.eng.utility.pec.jaxb.impl.SegnaturaImpl.serializeBody(SegnaturaImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:171)
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:144)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:73)
         at test.Main.main(Main.java:455)
    --------------- linked to ------------------
    javax.xml.bind.MarshalException
    - with linked exception:
    [java.lang.ClassCastException]
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:176)
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:144)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:73)
         at test.Main.main(Main.java:455)I have this schema:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <!--xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/-->
         <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
         <xsd:element name="Segnatura">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Intestazione"/>
                        <xsd:element ref="Riferimenti" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Descrizione"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Intestazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="OraRegistrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Origine"/>
                        <xsd:element ref="Destinazione" maxOccurs="unbounded"/>
                        <xsd:element ref="PerConoscenza" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Risposta" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Riservato" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="InterventoOperatore" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="RiferimentoDocumentiCartacei" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="RiferimentiTelematici" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Identificatore">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione"/>
                        <xsd:element ref="CodiceAOO"/>
                        <xsd:element ref="NumeroRegistrazione"/>
                        <xsd:element ref="DataRegistrazione"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="CodiceAmministrazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="CodiceAOO" type="xsd:string">
         </xsd:element>
         <xsd:element name="NumeroRegistrazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="DataRegistrazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="PrimaRegistrazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="OraRegistrazione">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="tempo" default="locale">
                                  <xsd:simpleType>
                                       <xsd:restriction base="xsd:string">
                                            <xsd:enumeration value="locale"/>
                                            <xsd:enumeration value="rupa"/>
                                            <xsd:enumeration value="NMTOKEN"/>
                                       </xsd:restriction>
                                  </xsd:simpleType>
                             </xsd:attribute>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Origine">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                        <xsd:element ref="Mittente"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Destinazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                        <xsd:element ref="Destinatario" minOccurs="0" maxOccurs="unbounded"/>
                   </xsd:sequence>
                   <xsd:attribute name="confermaRicezione" default="no">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="si"/>
                                  <xsd:enumeration value="no"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="PerConoscenza">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                        <xsd:element ref="Destinatario" minOccurs="0" maxOccurs="unbounded"/>
                   </xsd:sequence>
                   <xsd:attribute name="confermaRicezione" default="no">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="si"/>
                                  <xsd:enumeration value="no"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Risposta">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="IndirizzoTelematico">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="tipo" default="smtp">
                                  <xsd:simpleType>
                                       <xsd:restriction base="xsd:string">
                                            <xsd:enumeration value="smtp"/>
                                            <xsd:enumeration value="uri"/>
                                            <xsd:enumeration value="NMTOKEN"/>
                                       </xsd:restriction>
                                  </xsd:simpleType>
                             </xsd:attribute>
                             <xsd:attribute name="note" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="InterventoOperatore" type="xsd:string">
         </xsd:element>
         <xsd:element name="Riservato" type="xsd:string">
         </xsd:element>
         <xsd:element name="RiferimentoDocumentiCartacei">
              <xsd:complexType/>
         </xsd:element>
         <xsd:element name="RiferimentiTelematici">
              <xsd:complexType/>
         </xsd:element>
         <xsd:element name="Oggetto" type="xsd:string">
         </xsd:element>
         <xsd:element name="Classifica">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="CodiceAOO" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Denominazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Livello" maxOccurs="unbounded"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Denominazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="Livello">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="nome" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Identificativo" type="xsd:string">
         </xsd:element>
         <xsd:element name="Note" type="xsd:string">
         </xsd:element>
         <xsd:element name="Mittente">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Amministrazione"/>
                        <xsd:element ref="AOO"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Destinatario">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:sequence>
                                  <xsd:element ref="Amministrazione"/>
                                  <xsd:element ref="AOO" minOccurs="0" maxOccurs="1"/>
                             </xsd:sequence>
                             <xsd:sequence>
                                  <xsd:element ref="Denominazione"/>
                                  <xsd:element ref="Persona" minOccurs="0" maxOccurs="unbounded"/>
                             </xsd:sequence>
                             <xsd:element ref="Persona" maxOccurs="unbounded"/>
                        </xsd:choice>
                        <xsd:element ref="IndirizzoTelematico" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Telefono" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Fax" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="IndirizzoPostale" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Amministrazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="CodiceAmministrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:choice>
                             <xsd:element ref="UnitaOrganizzativa"/>
                             <xsd:sequence>
                                  <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                       <xsd:element ref="Ruolo"/>
                                       <xsd:element ref="Persona"/>
                                  </xsd:choice>
                                  <xsd:element ref="IndirizzoPostale"/>
                                  <xsd:element ref="IndirizzoTelematico" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Telefono" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Fax" minOccurs="0" maxOccurs="unbounded"/>
                             </xsd:sequence>
                        </xsd:choice>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="UnitaOrganizzativa">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                        <xsd:choice>
                             <xsd:element ref="UnitaOrganizzativa"/>
                             <xsd:sequence>
                                  <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                       <xsd:element ref="Ruolo"/>
                                       <xsd:element ref="Persona"/>
                                  </xsd:choice>
                                  <xsd:element ref="IndirizzoPostale"/>
                                  <xsd:element ref="IndirizzoTelematico" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Telefono" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Fax" minOccurs="0" maxOccurs="unbounded"/>
                             </xsd:sequence>
                        </xsd:choice>
                   </xsd:sequence>
                   <xsd:attribute name="tipo" default="permanente">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="permanente"/>
                                  <xsd:enumeration value="temporanea"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="AOO">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="CodiceAOO" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Ruolo">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Persona" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Persona">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:element ref="Denominazione"/>
                             <xsd:sequence>
                                  <xsd:element ref="Nome" minOccurs="0" maxOccurs="1"/>
                                  <xsd:element ref="Cognome"/>
                                  <xsd:element ref="Titolo" minOccurs="0" maxOccurs="1"/>
                                  <xsd:element ref="CodiceFiscale" minOccurs="0" maxOccurs="1"/>
                             </xsd:sequence>
                        </xsd:choice>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Nome" type="xsd:string">
         </xsd:element>
         <xsd:element name="Cognome" type="xsd:string">
         </xsd:element>
         <xsd:element name="Titolo" type="xsd:string">
         </xsd:element>
         <xsd:element name="CodiceFiscale" type="xsd:string">
         </xsd:element>
         <xsd:element name="IndirizzoPostale">
              <xsd:complexType>
                   <xsd:choice>
                        <xsd:element ref="Denominazione"/>
                        <xsd:sequence>
                             <xsd:element ref="Toponimo"/>
                             <xsd:element ref="Civico"/>
                             <xsd:element ref="CAP"/>
                             <xsd:element ref="Comune"/>
                             <xsd:element ref="Provincia"/>
                             <xsd:element ref="Nazione" minOccurs="0" maxOccurs="1"/>
                        </xsd:sequence>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Toponimo">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="dug" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Civico" type="xsd:string">
         </xsd:element>
         <xsd:element name="CAP" type="xsd:string">
         </xsd:element>
         <xsd:element name="Comune">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="codiceISTAT" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Provincia" type="xsd:string">
         </xsd:element>
         <xsd:element name="Nazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="Telefono">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="note" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Fax">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="note" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Riferimenti">
              <xsd:complexType>
                   <xsd:choice maxOccurs="unbounded">
                        <xsd:element ref="Messaggio"/>
                        <xsd:element ref="ContestoProcedurale"/>
                        <xsd:element ref="Procedimento"/>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Messaggio">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:element ref="Identificatore"/>
                             <xsd:element ref="DescrizioneMessaggio"/>
                        </xsd:choice>
                        <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="DescrizioneMessaggio" type="xsd:string">
         </xsd:element>
         <xsd:element name="ContestoProcedurale">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione"/>
                        <xsd:element ref="CodiceAOO"/>
                        <xsd:element ref="Identificativo"/>
                        <xsd:element ref="TipoContestoProcedurale" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="DataAvvio" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TipoContestoProcedurale" type="xsd:string">
         </xsd:element>
         <xsd:element name="DataAvvio" type="xsd:string">
         </xsd:element>
         <xsd:element name="Procedimento">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione"/>
                        <xsd:element ref="CodiceAOO"/>
                        <xsd:element ref="Identificativo"/>
                        <xsd:element ref="TipoProcedimento" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Responsabile" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="DataAvvio" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="DataTermine" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TipoProcedimento" type="xsd:string">
         </xsd:element>
         <xsd:element name="Responsabile">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Persona"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="DataTermine" type="xsd:string">
         </xsd:element>
         <xsd:element name="Descrizione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:element ref="Documento"/>
                             <xsd:element ref="TestoDelMessaggio"/>
                        </xsd:choice>
                        <xsd:element ref="Allegati" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Documento">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:sequence minOccurs="0" maxOccurs="1">
                             <xsd:element ref="CollocazioneTelematica"/>
                             <xsd:element ref="Impronta" minOccurs="0" maxOccurs="1"/>
                        </xsd:sequence>
                        <xsd:element ref="TitoloDocumento" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="TipoDocumento" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="NumeroPagine" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
                   <xsd:attribute name="nome" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoMIME" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoRiferimento" default="MIME">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="MIME"/>
                                  <xsd:enumeration value="telematico"/>
                                  <xsd:enumeration value="cartaceo"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TitoloDocumento" type="xsd:string">
         </xsd:element>
         <xsd:element name="TipoDocumento" type="xsd:string">
         </xsd:element>
         <xsd:element name="NumeroPagine" type="xsd:string">
         </xsd:element>
         <xsd:element name="CollocazioneTelematica" type="xsd:string">
         </xsd:element>
         <xsd:element name="Impronta">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="algoritmo" type="xsd:string" fixed="SHA-1"/>
                             <xsd:attribute name="codifica" type="xsd:string" fixed="base64"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TestoDelMessaggio">
              <xsd:complexType>
                   <xsd:attribute name="id" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoMIME" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoRiferimento" type="xsd:NMTOKEN" fixed="MIME"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Allegati">
              <xsd:complexType>
                   <xsd:choice maxOccurs="unbounded">
                        <xsd:element ref="Documento"/>
                        <xsd:element ref="Fascicolo"/>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Fascicolo">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="CodiceAOO" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                        <xsd:choice maxOccurs="unbounded">
                             <xsd:element ref="Documento"/>
                             <xsd:element ref="Fascicolo"/>
                        </xsd:choice>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="ConfermaRicezione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="MessaggioRicevuto"/>
                        <xsd:element ref="Riferimenti" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Descrizione" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="MessaggioRicevuto">
              <xsd:complexType>
                   <xsd:choice>
                        <xsd:sequence>
                             <xsd:element ref="Identificatore"/>
                             <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                        </xsd:sequence>
                        <xsd:element ref="DescrizioneMessaggio"/>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="AggiornamentoConferma">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="MessaggioRicevuto"/>
                        <xsd:element ref="Riferimenti" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Descrizione" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="NotificaEccezione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="MessaggioRicevuto"/>
                        <xsd:element ref="Motivo"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Motivo" type="xsd:string">
         </xsd:element>
         <xsd:element name="AnnullamentoProtocollazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="Motivo"/>
                        <xsd:element ref="Provvedimento"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Provvedimento" type="xsd:string">
         </xsd:element>
    </xsd:schema>By debugging the Jaxb-generated classes i have seen that i have this error in this piece of code:
    context.text(context.onIDREF(((com.sun.xml.bind.marshaller.IdentifiableObject)((java.lang.Object) _Rife))), "Rife");I don't know why and i'm not able to find the IdentifiableObject javaDoc.
    Can anybody help me?
    Thanks

    Hi all. I'm using JWSDP 1.5; i have a w3 schema and i'm using Jaxb for Marshalling and Unmarshalling.
    Well i have this error when i try to Marshall:
    DefaultValidationEventHandler: [ERROR]: java.lang.ClassCastException
         Location:  obj: it.eng.utility.pec.jaxb.impl.PersonaImpl@1a918d5
    18:23:55,534 ERROR [Main] errore
    java.lang.ClassCastException
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.reportError(SAXMarshaller.java:436)
         at it.eng.utility.pec.jaxb.impl.runtime.Util.handlePrintConversionException(Util.java:47)
         at it.eng.utility.pec.jaxb.impl.PersonaTypeImpl.serializeAttributes(PersonaTypeImpl.java:186)
         at it.eng.utility.pec.jaxb.impl.PersonaImpl.serializeBody(PersonaImpl.java:41)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.DestinatarioTypeImpl.serializeBody(DestinatarioTypeImpl.java:153)
         at it.eng.utility.pec.jaxb.impl.DestinatarioImpl.serializeBody(DestinatarioImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.DestinazioneTypeImpl.serializeBody(DestinazioneTypeImpl.java:77)
         at it.eng.utility.pec.jaxb.impl.DestinazioneImpl.serializeBody(DestinazioneImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.IntestazioneTypeImpl.serializeBody(IntestazioneTypeImpl.java:219)
         at it.eng.utility.pec.jaxb.impl.IntestazioneImpl.serializeBody(IntestazioneImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.SegnaturaTypeImpl.serializeBody(SegnaturaTypeImpl.java:74)
         at it.eng.utility.pec.jaxb.impl.SegnaturaImpl.serializeBody(SegnaturaImpl.java:43)
         at it.eng.utility.pec.jaxb.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:171)
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:144)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:73)
         at test.Main.main(Main.java:455)
    --------------- linked to ------------------
    javax.xml.bind.MarshalException
    - with linked exception:
    [java.lang.ClassCastException]
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:176)
         at it.eng.utility.pec.jaxb.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:144)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:73)
         at test.Main.main(Main.java:455)I have this schema:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <!--xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/-->
         <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
         <xsd:element name="Segnatura">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Intestazione"/>
                        <xsd:element ref="Riferimenti" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Descrizione"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Intestazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="OraRegistrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Origine"/>
                        <xsd:element ref="Destinazione" maxOccurs="unbounded"/>
                        <xsd:element ref="PerConoscenza" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Risposta" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Riservato" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="InterventoOperatore" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="RiferimentoDocumentiCartacei" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="RiferimentiTelematici" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Identificatore">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione"/>
                        <xsd:element ref="CodiceAOO"/>
                        <xsd:element ref="NumeroRegistrazione"/>
                        <xsd:element ref="DataRegistrazione"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="CodiceAmministrazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="CodiceAOO" type="xsd:string">
         </xsd:element>
         <xsd:element name="NumeroRegistrazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="DataRegistrazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="PrimaRegistrazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="OraRegistrazione">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="tempo" default="locale">
                                  <xsd:simpleType>
                                       <xsd:restriction base="xsd:string">
                                            <xsd:enumeration value="locale"/>
                                            <xsd:enumeration value="rupa"/>
                                            <xsd:enumeration value="NMTOKEN"/>
                                       </xsd:restriction>
                                  </xsd:simpleType>
                             </xsd:attribute>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Origine">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                        <xsd:element ref="Mittente"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Destinazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                        <xsd:element ref="Destinatario" minOccurs="0" maxOccurs="unbounded"/>
                   </xsd:sequence>
                   <xsd:attribute name="confermaRicezione" default="no">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="si"/>
                                  <xsd:enumeration value="no"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="PerConoscenza">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                        <xsd:element ref="Destinatario" minOccurs="0" maxOccurs="unbounded"/>
                   </xsd:sequence>
                   <xsd:attribute name="confermaRicezione" default="no">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="si"/>
                                  <xsd:enumeration value="no"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Risposta">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="IndirizzoTelematico"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="IndirizzoTelematico">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="tipo" default="smtp">
                                  <xsd:simpleType>
                                       <xsd:restriction base="xsd:string">
                                            <xsd:enumeration value="smtp"/>
                                            <xsd:enumeration value="uri"/>
                                            <xsd:enumeration value="NMTOKEN"/>
                                       </xsd:restriction>
                                  </xsd:simpleType>
                             </xsd:attribute>
                             <xsd:attribute name="note" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="InterventoOperatore" type="xsd:string">
         </xsd:element>
         <xsd:element name="Riservato" type="xsd:string">
         </xsd:element>
         <xsd:element name="RiferimentoDocumentiCartacei">
              <xsd:complexType/>
         </xsd:element>
         <xsd:element name="RiferimentiTelematici">
              <xsd:complexType/>
         </xsd:element>
         <xsd:element name="Oggetto" type="xsd:string">
         </xsd:element>
         <xsd:element name="Classifica">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="CodiceAOO" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Denominazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Livello" maxOccurs="unbounded"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Denominazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="Livello">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="nome" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Identificativo" type="xsd:string">
         </xsd:element>
         <xsd:element name="Note" type="xsd:string">
         </xsd:element>
         <xsd:element name="Mittente">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Amministrazione"/>
                        <xsd:element ref="AOO"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Destinatario">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:sequence>
                                  <xsd:element ref="Amministrazione"/>
                                  <xsd:element ref="AOO" minOccurs="0" maxOccurs="1"/>
                             </xsd:sequence>
                             <xsd:sequence>
                                  <xsd:element ref="Denominazione"/>
                                  <xsd:element ref="Persona" minOccurs="0" maxOccurs="unbounded"/>
                             </xsd:sequence>
                             <xsd:element ref="Persona" maxOccurs="unbounded"/>
                        </xsd:choice>
                        <xsd:element ref="IndirizzoTelematico" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Telefono" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Fax" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="IndirizzoPostale" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Amministrazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="CodiceAmministrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:choice>
                             <xsd:element ref="UnitaOrganizzativa"/>
                             <xsd:sequence>
                                  <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                       <xsd:element ref="Ruolo"/>
                                       <xsd:element ref="Persona"/>
                                  </xsd:choice>
                                  <xsd:element ref="IndirizzoPostale"/>
                                  <xsd:element ref="IndirizzoTelematico" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Telefono" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Fax" minOccurs="0" maxOccurs="unbounded"/>
                             </xsd:sequence>
                        </xsd:choice>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="UnitaOrganizzativa">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                        <xsd:choice>
                             <xsd:element ref="UnitaOrganizzativa"/>
                             <xsd:sequence>
                                  <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                       <xsd:element ref="Ruolo"/>
                                       <xsd:element ref="Persona"/>
                                  </xsd:choice>
                                  <xsd:element ref="IndirizzoPostale"/>
                                  <xsd:element ref="IndirizzoTelematico" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Telefono" minOccurs="0" maxOccurs="unbounded"/>
                                  <xsd:element ref="Fax" minOccurs="0" maxOccurs="unbounded"/>
                             </xsd:sequence>
                        </xsd:choice>
                   </xsd:sequence>
                   <xsd:attribute name="tipo" default="permanente">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="permanente"/>
                                  <xsd:enumeration value="temporanea"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="AOO">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="CodiceAOO" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Ruolo">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Denominazione"/>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Persona" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Persona">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:element ref="Denominazione"/>
                             <xsd:sequence>
                                  <xsd:element ref="Nome" minOccurs="0" maxOccurs="1"/>
                                  <xsd:element ref="Cognome"/>
                                  <xsd:element ref="Titolo" minOccurs="0" maxOccurs="1"/>
                                  <xsd:element ref="CodiceFiscale" minOccurs="0" maxOccurs="1"/>
                             </xsd:sequence>
                        </xsd:choice>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Nome" type="xsd:string">
         </xsd:element>
         <xsd:element name="Cognome" type="xsd:string">
         </xsd:element>
         <xsd:element name="Titolo" type="xsd:string">
         </xsd:element>
         <xsd:element name="CodiceFiscale" type="xsd:string">
         </xsd:element>
         <xsd:element name="IndirizzoPostale">
              <xsd:complexType>
                   <xsd:choice>
                        <xsd:element ref="Denominazione"/>
                        <xsd:sequence>
                             <xsd:element ref="Toponimo"/>
                             <xsd:element ref="Civico"/>
                             <xsd:element ref="CAP"/>
                             <xsd:element ref="Comune"/>
                             <xsd:element ref="Provincia"/>
                             <xsd:element ref="Nazione" minOccurs="0" maxOccurs="1"/>
                        </xsd:sequence>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Toponimo">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="dug" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Civico" type="xsd:string">
         </xsd:element>
         <xsd:element name="CAP" type="xsd:string">
         </xsd:element>
         <xsd:element name="Comune">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="codiceISTAT" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Provincia" type="xsd:string">
         </xsd:element>
         <xsd:element name="Nazione" type="xsd:string">
         </xsd:element>
         <xsd:element name="Telefono">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="note" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Fax">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="note" type="xsd:string" use="optional"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Riferimenti">
              <xsd:complexType>
                   <xsd:choice maxOccurs="unbounded">
                        <xsd:element ref="Messaggio"/>
                        <xsd:element ref="ContestoProcedurale"/>
                        <xsd:element ref="Procedimento"/>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Messaggio">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:element ref="Identificatore"/>
                             <xsd:element ref="DescrizioneMessaggio"/>
                        </xsd:choice>
                        <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="DescrizioneMessaggio" type="xsd:string">
         </xsd:element>
         <xsd:element name="ContestoProcedurale">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione"/>
                        <xsd:element ref="CodiceAOO"/>
                        <xsd:element ref="Identificativo"/>
                        <xsd:element ref="TipoContestoProcedurale" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="DataAvvio" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TipoContestoProcedurale" type="xsd:string">
         </xsd:element>
         <xsd:element name="DataAvvio" type="xsd:string">
         </xsd:element>
         <xsd:element name="Procedimento">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione"/>
                        <xsd:element ref="CodiceAOO"/>
                        <xsd:element ref="Identificativo"/>
                        <xsd:element ref="TipoProcedimento" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Responsabile" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="DataAvvio" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="DataTermine" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TipoProcedimento" type="xsd:string">
         </xsd:element>
         <xsd:element name="Responsabile">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Persona"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="DataTermine" type="xsd:string">
         </xsd:element>
         <xsd:element name="Descrizione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:choice>
                             <xsd:element ref="Documento"/>
                             <xsd:element ref="TestoDelMessaggio"/>
                        </xsd:choice>
                        <xsd:element ref="Allegati" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Documento">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:sequence minOccurs="0" maxOccurs="1">
                             <xsd:element ref="CollocazioneTelematica"/>
                             <xsd:element ref="Impronta" minOccurs="0" maxOccurs="1"/>
                        </xsd:sequence>
                        <xsd:element ref="TitoloDocumento" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="TipoDocumento" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="NumeroPagine" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
                   <xsd:attribute name="nome" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoMIME" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoRiferimento" default="MIME">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:enumeration value="MIME"/>
                                  <xsd:enumeration value="telematico"/>
                                  <xsd:enumeration value="cartaceo"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:attribute>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TitoloDocumento" type="xsd:string">
         </xsd:element>
         <xsd:element name="TipoDocumento" type="xsd:string">
         </xsd:element>
         <xsd:element name="NumeroPagine" type="xsd:string">
         </xsd:element>
         <xsd:element name="CollocazioneTelematica" type="xsd:string">
         </xsd:element>
         <xsd:element name="Impronta">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                             <xsd:attribute name="algoritmo" type="xsd:string" fixed="SHA-1"/>
                             <xsd:attribute name="codifica" type="xsd:string" fixed="base64"/>
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="TestoDelMessaggio">
              <xsd:complexType>
                   <xsd:attribute name="id" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoMIME" type="xsd:string" use="optional"/>
                   <xsd:attribute name="tipoRiferimento" type="xsd:NMTOKEN" fixed="MIME"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Allegati">
              <xsd:complexType>
                   <xsd:choice maxOccurs="unbounded">
                        <xsd:element ref="Documento"/>
                        <xsd:element ref="Fascicolo"/>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Fascicolo">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="CodiceAmministrazione" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="CodiceAOO" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Oggetto" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Identificativo" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Classifica" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element ref="Note" minOccurs="0" maxOccurs="1"/>
                        <xsd:choice maxOccurs="unbounded">
                             <xsd:element ref="Documento"/>
                             <xsd:element ref="Fascicolo"/>
                        </xsd:choice>
                   </xsd:sequence>
                   <xsd:attribute name="id" type="xsd:ID" use="optional"/>
                   <xsd:attribute name="rife" type="xsd:IDREF" use="optional"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="ConfermaRicezione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="MessaggioRicevuto"/>
                        <xsd:element ref="Riferimenti" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Descrizione" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="MessaggioRicevuto">
              <xsd:complexType>
                   <xsd:choice>
                        <xsd:sequence>
                             <xsd:element ref="Identificatore"/>
                             <xsd:element ref="PrimaRegistrazione" minOccurs="0" maxOccurs="1"/>
                        </xsd:sequence>
                        <xsd:element ref="DescrizioneMessaggio"/>
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="AggiornamentoConferma">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="MessaggioRicevuto"/>
                        <xsd:element ref="Riferimenti" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="Descrizione" minOccurs="0" maxOccurs="1"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="NotificaEccezione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore" minOccurs="0" maxOccurs="1"/>
                        <xsd:element ref="MessaggioRicevuto"/>
                        <xsd:element ref="Motivo"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Motivo" type="xsd:string">
         </xsd:element>
         <xsd:element name="AnnullamentoProtocollazione">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="Identificatore"/>
                        <xsd:element ref="Motivo"/>
                        <xsd:element ref="Provvedimento"/>
                   </xsd:sequence>
                   <xsd:attribute name="versione" type="xsd:NMTOKEN" fixed="2001-05-07"/>
                   <!--xsd:attribute name='xml:lang' type='xsd:NMTOKEN' fixed='it'/-->
                   <xsd:attribute ref="xml:lang" fixed="it"/>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="Provvedimento" type="xsd:string">
         </xsd:element>
    </xsd:schema>By debugging the Jaxb-generated classes i have seen that i have this error in this piece of code:
    context.text(context.onIDREF(((com.sun.xml.bind.marshaller.IdentifiableObject)((java.lang.Object) _Rife))), "Rife");I don't know why and i'm not able to find the IdentifiableObject javaDoc.
    Can anybody help me?
    Thanks

  • JAXB and ClassCastException

    Hi all,
    When I try to unmarshal a XML document, I get a ClassCastException. I've listed the details below. I've also searched the forums on this one but can't seem to find any answer (maybe I've missed it somewhere). I appreciate any help or hints anyone can offer.
    XMLSchema: OrganizationalUnit.xsd
    JAXB Generated classes: OrganizationalUnit.java, OrganizationalUnitType.java etc.
    UnmarshallingCode:
    JAXBContext jc = JAXBContext.newInstance("com.myproject.unitinfo");
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    unmarshaller.setValidating(true);
    String filename = JOptionPane.showInputDialog("Filename:");
    OrganizationalUnit unit = (OrganizationalUnit)unmarshaller.unmarshal(new FileInputStream( filename ) );
    System.out.println("Participant ID:" + unit.getUnitID() );The above code generates the following error:
    ClassCastException caught.
    com.iwise.process.jaxb.unitinfo.impl.OrganizationalUnitImpl
    java.lang.ClassCastException: com.iwise.process.jaxb.unitinfo.impl.OrganizationalUnitImpl
         at com.iwise.process.test.TestClient.saveParticipant(TestClient.java:58)
         at com.iwise.process.test.TestClient.main(TestClient.java:33)
    TIA, Claire

    What was wrong with your package structure? I'm running into a similar problem where one XML doc/schema combo parses great, but another throws the java.lang.ClassCastException.

  • Wrong Case or ClassCastException

    Hello everyone
    I use JWSDP2.0, JDK is jdk1.5.0_12
    I have tried to generate class by the command:
    xjc -p test.jaxb poll.xsd
    Following is the schema
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xsd:element name="Poll" type="Poll"/>
         <xsd:complexType name="Poll">
              <xsd:sequence>
                   <xsd:element name="queryName" type="xsd:string"/>
                   <xsd:element name="params" type="QueryParams"/>
              </xsd:sequence>
              <xsd:anyAttribute processContents="lax"/>
         </xsd:complexType>
         <xsd:complexType name="QueryParams">
              <xsd:sequence>
                   <xsd:element name="param" type="QueryParam" minOccurs="0" maxOccurs="unbounded"/>
              </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="QueryParam">
              <xsd:sequence>
                   <xsd:element name="name" type="xsd:string"/>
                   <!-- See note in EPCIS spec text regarding the value for this element -->
                   <xsd:element name="value" type="xsd:anyType"/>
              </xsd:sequence>
         </xsd:complexType>     
    </xsd:schema>I modify the poll.java, and add @XmlRootElement in front of the class declaration.
    Then I write code to test marshall and unmarshall
    package test;
    import java.util.List;
    import java.io.*;
    import javax.xml.bind.*;
    import org.w3c.dom.*;
    import test.jaxb.*;
    public class JAXBTest {
         public static void main(String[] args){
              try {
                   JAXBContext context = JAXBContext.newInstance("test.jaxb");
                   ObjectFactory factory = new ObjectFactory();
                   Marshaller marshal = context.createMarshaller();
                   marshal.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
                   Unmarshaller unmarshal = context.createUnmarshaller();
                   Poll poll = factory.createPoll();
                   poll.setQueryName("Query1");
                   QueryParams params = factory.createQueryParams();
                   List list = params.getParam();
                   QueryParam param = factory.createQueryParam();               
                   param.setName("Name");
                   param.setValue("David");
                   list.add(param);
                   poll.setParams(params);
                  OutputStream os = new FileOutputStream( "poll.xml" );
                  marshal.marshal( poll, os );     
                  marshal.marshal(poll,System.out);
                  Poll input = (Poll)unmarshal.unmarshal( new File( "poll.xml" ) );
                  System.out.println(input.getQueryName());
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }I found the root element is generated to "poll", not the schema defined "Poll"
    But marshall and unmarshall are ok.
    In order to comform the schema, I modify Poll.java again.
    Change @XmlRootElement to @XmlRootElement(name = "Poll")The result is I can generate the right case element now("Poll").
    But I get the exception simultaneously, unmarshall is not ok
    java.lang.ClassCastException: javax.xml.bind.JAXBElement
         at test.JAXBTest.main(JAXBTest.java:29)
    is there any resolution to solve wrong case problem and make marshall/unmarshall ok?
    Message was edited by:
    chihwen

    Hi,
    As far as I know Oracle are porting Developer R6 to Linux.
    We're also anxiously waiting for it to be out.
    It should be out in 2 or 3 months.
    About CASE I don't thing anyone will port it to linux.
    Regards,
    Michael
    Jose Abelardo Gutierrez (guest) wrote:
    : My company is looking for CASE or RAD tools for database system
    : developement on Linux.
    : If I can find something that suits our needs we will change all
    : our application developement schema to Linux, and I'll very
    : happy, and our client to.
    : Thanks for your reading
    null

  • JaxB returns incompatible type class

    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 @
    [email protected]2 @ 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

    The problem might be also in an order of references. It's important. Ensure that the reference to your JAXB libs is the first one in the EAR, before any other server components.
    I see two options how you can reference the JAXB libs in EAR:
    1) Create External Library project. Copy your JAXB libs into it, include the libs public part as ASSEMBLY. Build the DC and check that folder /gen/... contains the jars in the public part's folder.
    1.1) Reference the Ext Lib DC from your EAR, build the EAR and ensure that the JAXB libs contained inside.
    1.2) Deploy EAR and check it.
    2) Create Server Library project. Copy your JAXB libs into it, include the libs public part as COMPILATION. Build the DC and check that folder /gen/... contains the jars in the public part's folder.
    2.1) Reference the Ext Lib DC from your EAR, build the EAR and ensure that the JAXB libs is NOT contained inside.
    2.2) Deploy the Server Lib and the EAR and check it.
    BR, Sergei

  • Xmlns not getting created using jaxb

    Hi, I'm a newbie to JAXB. I went through the tutorial for jaxb on jwdsp 1.5 site and generated source files for a given schema using xjc. However, the generated xml does not seem to output xmlns. Not sure how to set this. Here is the related xsd file:
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:element name="order">
              <xsd:complexType>
                   <xsd:sequence>
                       <xsd:any namespace="urn:abc.com"/>
                   </xsd:sequence>
                   <xsd:attribute name="xmlns" type="xsd:string" use="required" fixed="urn:abc.com"/>
              </xsd:complexType>
         </xsd:element>
    </xsd:schema>Also, I do not know how to set "any". I tried using a DOM element but I get a ClassCastException when trying to cast to JAXBObject. So any pointers in that regard will be greatly appreciated.

    Hi,
    When you use the MD01 the system will look for the planning file entry and for the materials which have planning file entry will only be included in the planning run.
    KIindly maintain the planning file entry in the md21 or mdab. and rerun your md01.
    it is working in md02 or md03 since  you are giving the input as material.
    reg
    dsk

  • Jaxb strange (de)serialization problem

    Hi!
    I have strange a problem in which deserialization of xml to an object generated by jaxb in some cases results in a classcastexception.
    Please bare with me...
    The problem occurs when I generate code for two schema's which both have an imported common schema which contain common data types and elements. Now I use 2 ant xjc task to generate the sources (to the same target folder). Whichever schema is created LAST works. That is, the sample xml for that schema can be deserialized. Now if I swap the order of generation the service for which the deserialization worked now fails and the other one works.
    If I add both schema's into a single call to xjc then it works but then I have a problem that I can't add any custom serialization because the additional of multiple binding files result in "not part of the compilation.." errors.
    This problem has been bugging me for days now and I wonder if anyone had the same problem? Or better, has a solution....
    Cheers,
    Robin

    sorry for the question already asked here. Actually I found the answer here
    http://forum.java.sun.com/thread.jspa?forumID=62&threadID=793180
    the problem was in the header, each time appended to the file. Anyhow, thanks to arnaud63 and ejp.

  • ClassCastException in my WS over JMS using JAX-RPC in WLS 10.3...

    Hi,
    I am developing a WS over JMS using JAX-RPC in WLS 10.3 (I tried both WLS 10.3.0 and 10.3.1). And when WLS is trying to marshal the response, it throws "ClassCastException":
    ava.lang.ClassCastException: org.tmforum.mtop.nrf.xsd.com.v1.EquipmentHolderEnumType cannot be cast to java.lang.String
    at com.bea.staxb.runtime.internal.StringTypeConverter.print(StringTypeConverter.java:45)
    at com.bea.staxb.runtime.internal.SimpleContentBeanMarshaller.print(SimpleContentBeanMarshaller.java:52)
    at com.bea.staxb.runtime.internal.RuntimeBindingProperty.getLexical(RuntimeBindingProperty.java:154)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeCharData(PushMarshalResult.java:639)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:413)
    at com.bea.staxb.runtime.internal.SimpleContentRuntimeBindingType.accept(SimpleContentRuntimeBindingType.java:46)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:403)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:403)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:400)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:403)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:400)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:403)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:400)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:403)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalType(PushMarshalResult.java:153)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visitProp(PushMarshalResult.java:631)
    at com.bea.staxb.runtime.internal.PushMarshalResult.visit(PushMarshalResult.java:403)
    at com.bea.staxb.runtime.internal.ByNameRuntimeBindingType.accept(ByNameRuntimeBindingType.java:89)
    at com.bea.staxb.runtime.internal.PushMarshalResult.writeContents(PushMarshalResult.java:195)
    at com.bea.staxb.runtime.internal.PushMarshalResult.marshalTopType(PushMarshalResult.java:96)
    at com.bea.staxb.runtime.internal.MarshallerImpl.marshalBindingType(MarshallerImpl.java:302)
    at com.bea.staxb.runtime.internal.MarshallerImpl.marshalElement(MarshallerImpl.java:383)
    at weblogic.wsee.bind.runtime.internal.LiteralSerializerContext.marshalElement(LiteralSerializerContext.java:82)
    at weblogic.wsee.bind.runtime.internal.BaseSerializerContext.internalSerializeElement(BaseSerializerContext.java:197)
    at weblogic.wsee.bind.runtime.internal.BaseSerializerContext.serializeElement(BaseSerializerContext.java:128)
    at weblogic.wsee.codec.soap11.SoapEncoder.encodePart(SoapEncoder.java:322)
    at weblogic.wsee.codec.soap11.SoapEncoder.encodeReturn(SoapEncoder.java:228)
    at weblogic.wsee.codec.soap11.SoapEncoder.encodeParts(SoapEncoder.java:215)
    at weblogic.wsee.codec.soap11.SoapEncoder.encode(SoapEncoder.java:134)
    at weblogic.wsee.codec.soap11.SoapCodec.encode(SoapCodec.java:134)
    at weblogic.wsee.ws.dispatch.server.CodecHandler.encode(CodecHandler.java:104)
    at weblogic.wsee.ws.dispatch.server.CodecHandler.handleResponse(CodecHandler.java:51)
    at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:287)
    at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:271)
    at weblogic.wsee.ws.dispatch.server.ServerDispatcher.callHandleResponse(ServerDispatcher.java:341)
    at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:189)
    at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
    at weblogic.wsee.server.jms.JmsWebservicesMessageDispatcher.dispatchMessage(JmsWebservicesMessageDispatcher.java:175)
    at weblogic.wsee.server.jms.JmsQueueListener.processMessage(JmsQueueListener.java:397)
    at weblogic.wsee.server.jms.JmsQueueListener.onMessage(JmsQueueListener.java:392)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4585)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:4271)
    at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3747)
    at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5096)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    The "EquipmentHolderEnumType" is generated JAXB object (obviously it is not a String) from WSDL using WLS wsld generation. And here is how that Enum is defined in XSD:
    <xsd:simpleType name="EquipmentHolderEnumType">
    <xsd:annotation>
    <xsd:documentation>
    <p>Equipment holder type</p>
    </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="MINOR_EXT"/>
    <xsd:enumeration value="rack"/>
    <xsd:enumeration value="shelf"/>
    <xsd:enumeration value="sub_shelf"/>
    <xsd:enumeration value="slot"/>
    <xsd:enumeration value="sub_slot"/>
    <xsd:enumeration value="remote_unit"/>
    <xsd:enumeration value="remote_slots"/>
    </xsd:restriction>
    </xsd:simpleType>
    My question is why WLS is trying to cast the EnumType to String when marshalling it? How can I fix this exception?
    Also, second question: my WS will take some time to get the response ready (1+ minute). I was using WLS console test client to test my WS. And the test client always got time out:
    java.io.IOException: Request timed out
    at weblogic.wsee.connection.transport.jms.JmsTransport.receive(JmsTransport.java:356)
    at weblogic.testclient.WebServiceOperation.invokeJms(WebServiceOperation.java:463)
    at weblogic.testclient.WebServiceOperation.addWeblogicHeadersAndInvoke(WebServiceOperation.java:382)
    at weblogic.testclient.WebServiceOperation.invokeComplex(WebServiceOperation.java:305)
    at weblogic.testclient.WebServiceOperation.invoke(WebServiceOperation.java:626)
    How can I configure the WLS console test client so that I can increase teh timeout setting for the client?
    Thank you very much!
    Jian

    Hi, pls how did you solve your problem exatly? Because I have similar problem without solution.
    I have WSDL contract like:
    <xs:element name="duration">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base="durationType">
    <xs:attribute name="days" type="xs:int" use="optional"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>
    <xs:simpleType name="durationType">
    <xs:restriction base="xs:string">
    <xs:enumeration value="PERIODIC"/>
    <xs:enumeration value="PERPETUAL"/>
    <xs:enumeration value="CREDIT_DAYS"/>
    </xs:restriction>
    </xs:simpleType>
    And client site generated by WLS ant task "generate-from-wsdl" with "JAXRPC" option and when I use calling of this client and exeption was appeared:
    FaultString [com.company.DurationType] FaultActor [null] Detail [<detail><java:string>java.lang.ClassCastException: com.company.DurationType</java:string></detail>];
    Note: all other messages are correct.
    thx

  • JAXB Runtime Error

    have generated the java files using jaxb (jwsdp1.6) from schema. I am using Jdeveloper 10.1.3. It throws a runtime error which is as follows:
    [-] 2006-04-24 17:12:10,617 ERROR ProcessBatchEJB::getBatchJob - Provider com.sun.xml.bind.ContextFactory_1_0_1 could not be instantiated: java.lang.ClassCastException
    06/04/24 17:12:10 java.lang.ClassCastException
    06/04/24 17:12:10 at com.sun.xml.bind.ContextFactory_1_0_1.createContext(ContextFactory_1_0_1.java:50)
    Any ideas??

    Make sure that you have put the jar files from Sun's implementation before the version that is embedded in JDeveloper. The ClassCastException may be occuring once you have created a new object instance using Oracle's factory and try to use it with Sun's implementation classes.
    Hope this helps,
    Eric

  • Remote object trying to return another remote object and a ClassCastExcepti

    I have a server running with a TreeModel (the tree model implements Remote). I also have the the TreeNodes all linked together on the server. Now, I can get to the TreeModel on the server and the root node of the remote tree model.
    treeModelStub = (treeModelIface)Naming.lookup(url+"remoteTM"); //works
    rootStub = (remoteTreeNodeIface)treeModelStub.getRoot(); //works. The call to getRoot returns Object
    But when I call
    remoteTreeNodeIface aChild = (remoteTreeNodeIface)rootStub.getChildAt(index) //Does not work. "Exception in thread "main" java.lang.ClassCastException
    at remoteTreeNode_Stub.getChildAt(Unknown Source)
    The remote tree node method getChildAt returns TreeNode because the class implements TreeNode:
    public class remoteTreeNode extends UnicastRemoteObject implements rdcaDataIface, Comparable, TreeNode {
    public TreeNode getChildAt(int idx) {
    System.out.println("DEBUG: class is "+this.getClass()); // class is remoteTreeNode
    return (remoteTreeNode)children.get(idx);
    The remote interface is defined as:
    public interface rdcaDataIface extends java.rmi.Remote {
    public TreeNode getChildAt(int idx) throws RemoteException;
    Any ideas why this does not work. Why can a remote object of type Object be returned just fine, but a TreeNode not be returned?
    Thank you for your help,
    Brent

    I have a server running with a TreeModel (the tree
    model implements Remote). I also have the the
    TreeNodes all linked together on the server. Now, I
    can get to the TreeModel on the server and the root
    node of the remote tree model.
    treeModelStub =
    (treeModelIface)Naming.lookup(url+"remoteTM");
    //works
    rootStub =
    (remoteTreeNodeIface)treeModelStub.getRoot();
    //works. The call to getRoot returns Object
    But when I call
    remoteTreeNodeIface aChild =
    (remoteTreeNodeIface)rootStub.getChildAt(index)******************************************
    can only be casted to rdcaDataIface. The returned object is an instanceof the rdcaDataIface_stub, which have nothing to do with TreeNode.
    //Does not work. "Exception in thread "main"
    java.lang.ClassCastException
    at remoteTreeNode_Stub.getChildAt(Unknown
    t(Unknown Source)
    The remote tree node method getChildAt returns
    TreeNode because the class implements TreeNode:
    public class remoteTreeNode extends
    UnicastRemoteObject implements rdcaDataIface,
    Comparable, TreeNode {
    public TreeNode getChildAt(int idx) {
    System.out.println("DEBUG: class is
    lass is "+this.getClass()); // class is
    remoteTreeNode
    return (remoteTreeNode)children.get(idx);
    The remote interface is defined as:
    public interface rdcaDataIface extends java.rmi.Remote
    public TreeNode getChildAt(int idx) throws
    ows RemoteException;
    Any ideas why this does not work. Why can a remote
    object of type Object be returned just fine, but a
    TreeNode not be returned?
    Thank you for your help,
    Brent

  • Marshaling problem in creation of xml thru JAXB

    Hi java gurus,
    I am trying to create an XML which will has the data of database using JAXB. I am able to generate JAXB classes, but its giving some error the stack trace is like this
    java.lang.NoSuchMethodError: com.sun.xml.bind.marshaller.XMLWriter.setXmlDecl(Z)V
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.createWriter(MarshallerImpl.java:223)
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.createWriter(MarshallerImpl.java:238)
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.createWriter(MarshallerImpl.java:233)
         at org.bas.dss.common.vo.bii.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:126)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:66)
         at org.bas.dss.common.dao.MetaDAO.createInstInformation(MetaDAO.java:627)
         at org.bas.core.fidownload.DownloadActionHandler.getInstInfoXMLData(DownloadActionHandler.java:163)
         at org.bas.core.fidownload.DownloadActionHandler.performPreDownloadAction(DownloadActionHandler.java:74)
         at org.bas.core.fidownload.DownloadAction.perform(DownloadAction.java:129)
         at org.bas.core.fidownload.DownloadAction.execute(DownloadAction.java:79)
    the method is like this,
    valueObject = getInstInformation (registrationId, appVersionId);
    System.out.println("MetaDAO-->valueObject:"+valueObject); //here i am gettingthe object
    context = JAXBContext.newInstance("org.bas.dss.common.vo.bii");
    System.out.println("MetaDAO-->context:"+context); //here i am getting the context
    sumissionInfoMarshaller = context.createMarshaller();
    System.out.println("MetaDAO-->sumissionInfoMarshaller:"+sumissionInfoMarshaller); //here also i am getting some object type
    sumissionInfoMarshaller.setProperty(
    Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE);
    System.out.println("MetaDAO-->MetaDAO-->");
    sumissionInfoMarshaller.marshal (valueObject, streamToWrite); // the problem is coming here.
    anyone can suggest what will be the problem, and tell me how can i resolve this issue,
    thanks in advance,
    varma

    Pl post this question to SDK Forum

  • Java.lang.ClassCastException

    My class CDRack is almost ready, but in the last method
    sortAlphabetically() there
    comes java.lang.ClassCastException. I found in the net
    http://java.sun.com/docs/books/tutorial/collections/algorithms/
    that with method Collections.sort(l) I can sort alphabetically.
    The code compiles, but when I run it with a tester program, it stops
    to ClassCastException in the almost last row.
    Something is wrong with Collections.sort(l) ?
    /** Class CDRack represents collections of compact discs. Discs are
    located in the rack in slots numbered from zero upwards. The discs are
    represented by Record objects and empty slots by null values. */
    public class CDRack extends Object {
      private Record[] mRecords;
      private int size;
    /**Creates a new, empty CD rack.
    Parameters:
    size - the size of the new rack, i.e. the number of slots it has */
          public CDRack(int size) {
              mRecords = new Record[size];
              this.size = size;
    /** "Organizes" the discs in the rack so that they will be located in
    consecutive slots starting at slot number zero, and any and all empty
    slots will be at the "end of the rack". After calling this method, the
    discs are in an undefined (i.e. arbitrary) order - the only thing this
    method guarantees is that there aren't any empty slots in between full
    ones.
          public void organize() {
              // Turn array into a list - more flexible
              List l = Arrays.asList(aanilevyt);
              // Remove all nulls from a copy of the list which supports  removal.
              l = new ArrayList(l);
              while (l.remove(null)) /*do nothing*/;
              // Clear the original array.
              for (int i = 0; i < mRecords.length; i++){
                   mRecords[i] = null;
              } // Put the non-nulls back.
              l.toArray(mRecords);
    /**"Organizes" the discs in the rack to the beginning of the rack (see
    the method organize) and sorts them in alphabetical order. Recordings
    by the same artist are placed in alphabetical order by disc name. */
        public void sortAlphabetically() {
              // Turn array into a list - more flexible
              List l = Arrays.asList(aanilevyt);
              // Remove all nulls from a copy of the list which supports  removal.
              l = new ArrayList(l);
              while (l.remove(null)) /*do nothing*/;
              // Clear the original array.
              for (int i = 0; i < mRecords.length; i++){
                   mRecords[i] = null;
              } // Put the non-nulls back.
              l.toArray(mRecords);
              Collections.sort(l);   // alphabetical order. THERE IS CLASSCASTEXCEPTION 
    }

    I have thought and thought but the sorting alphabetically doesnt work.
    I can't use Collections.sort and class Record doesnt implement Comparable(and I can't change it).
    One suggestion was that I could make my own class which implements Comparator. Could it be like this
    import java.util.*;
    public class AlphabeticComparator
    implements Comparator{
      public int compare(Object o1, Object o2) {
        String s1 = (String)o1;
        String s2 = (String)o2;
        return s1.toLowerCase().compareTo(
          s2.toLowerCase());
    }      But how an earth can I tell to CDRack class that it would
    use the class AlphabeticComparator?
    Somebody please save my Christmas!
    /** Class CDRack represents collections of compact discs. Discs are
    located in the rack in slots numbered from zero upwards. The discs are
    represented by Record objects and empty slots by null values. */
    public class CDRack extends Object {
      private Record[] mRecords;
      private int size;
    /**Creates a new, empty CD rack.
    Parameters:
    size - the size of the new rack, i.e. the number of slots it has */
          public CDRack(int size) {
              mRecords = new Record[size];
              this.size = size;
    /** "Organizes" the discs in the rack so that they will be located in
    consecutive slots starting at slot number zero, and any and all empty
    slots will be at the "end of the rack". After calling this method, the
    discs are in an undefined (i.e. arbitrary) order - the only thing this
    method guarantees is that there aren't any empty slots in between full
    ones.
          public void organize() {
              // Turn array into a list - more flexible
              List l = Arrays.asList(aanilevyt);
              // Remove all nulls from a copy of the list which supports  removal.
              l = new ArrayList(l);
              while (l.remove(null)) /*do nothing*/;
              // Clear the original array.
              for (int i = 0; i < mRecords.length; i++){
                   mRecords<i> = null;
              } // Put the non-nulls back.
              l.toArray(mRecords);
    /**"Organizes" the discs in the rack to the beginning of the rack (see
    the method organize) and sorts them in alphabetical order. Recordings
    by the same artist are placed in alphabetical order by disc name. */
        public void sortAlphabetically() {

  • ClassCastException when deploying jsf war on Weblogic 10.3.2

    Hello everybody,
    We 're having an issue when deploying jsf war on Weblogic 10.3.2
    The war works fine on Tomcat 6.
    When deploying on Weblogic we got the following exception:
    java.lang.ClassCastException: weblogic.xml.jaxp.RegistryXMLReader cannot be cast to org.xml.sax.XMLReader
    I've already put <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml
    After "googling", people suggest to remove xml-apis jar from WEB-INF/lib, but doing so results in other exceptions.
    Is there any fix for this issue? Please help it's been more than a month that we are crawling in the dark with this error.
    Thanks in advance.

    Hello everybody,
    We 're having an issue when deploying jsf war on Weblogic 10.3.2
    The war works fine on Tomcat 6.
    When deploying on Weblogic we got the following exception:
    java.lang.ClassCastException: weblogic.xml.jaxp.RegistryXMLReader cannot be cast to org.xml.sax.XMLReader
    I've already put <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml
    After "googling", people suggest to remove xml-apis jar from WEB-INF/lib, but doing so results in other exceptions.
    Is there any fix for this issue? Please help it's been more than a month that we are crawling in the dark with this error.
    Thanks in advance.

Maybe you are looking for

  • Transfer of files from access to oracle

    i want to transfer the data base files of ms access to oracle. without using oracle navigator how should i transfer the files?

  • Just getting more annoyed by the minute

    It seems impossible to get back to my nice stable V5 setup that synchronised with GoldMine via CompanionLink for months. It is just wasting so much of my time - all for the sake of a little care and thought on the part of RIM. iPhone and HTC are beco

  • Copying photos with categories

    Hi I have all my photos in Starter Edition 3.2 divided by categories. I now want to transfer my pictures onto another computer which also has Starter Edition 3.2 and maintain my categories. Is this possible and, if so, how? Thanks

  • Tomcat 5.0 not running as a service

    Hey everyone, I'm extremelly new to Java and Tomcat so bare with me. Have tomcat 5.0 running on a Windows Server 2003 machine. Everything seems to be running fine, my servlets are all working. The problem is I use a remote desktop connection to login

  • Upgrade to Cloud from Photoshop CS5.5 Subscription

    Hi everyone, I'm beyond confused. I signed up for a Photoshop CS5.5 subscription back in January here in Australia. I was under the impression this is automatically updated to CS6 upon release (which has now happened), yet I have no notifications of