JAXB marshalling error..

Hi, below codes is working properly with normal java app. ( public static void main(String[] args) { ... } )
try {
    FileOutputStream fout = new FileOutputStream(new File("C:/workspace/mysearch/data/", name));
    JAXBContext ctx = JAXBContext.newInstance(Project.class);
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(project, fout);
} catch (JAXBException ex) {
      ErrorManager.getDefault().notify(ex);
} catch (Exception ex) {
      ErrorManager.getDefault().notify(ex);
}but, it is not working with the Netbeans WizardAction's performAction() method. below is error messages.
javax.xml.bind.JAXBException:
at javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:96)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:205)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at dstinfo.mysearch.wizard.ProjectWizardAction.actionPerformed(ProjectWizardAction.java:56)
at org.openide.awt.AlwaysEnabledAction.actionPerformed(AlwaysEnabledAction.java:89)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Heya,
I have no supportting evidence for this, but I'd assume if you annotate the property in the way shown in your example, the framework would then try to generate the appropriate getter() method to be used when marshalling the data. I'd guess you could annotate the property with the @XmlTransient annotation and use the default getter() method and avoid this error, no ?
Good luck,

Similar Messages

  • JAXB Marshalling

    Hi,
    jaxb marshalling for a xml file takes 8 secs in one system but it takes 1/2 min in another system for the same file. I want to know how to identifyu if there is any difference in the parsers being useed. I searched the Manifest files but unable to find reference to the parser being used. I even compared the version numbers of the API in the Manifest file and all the jars seem to be same version.
    Please help me in identifying what could be the problem.
    Thanks,
    Ravinder

    I don't know anything about either of the computers involved or the XML document involved, but I will take a guess and say there are differences in network access between the two computers.

  • JAXB Marshalling of "double" problem - exponent is in the way

    An element declared as "xsd:double" in the schema is marshalled by JAXB as "3.000404E-4" to represent 0.0003000404 . When I try to process this XML document using XSLT, the standard number() function returns "NaN" because of the exponent in the representation of the number.
    Is there any way to have JAXB marshall this number in a way that is acceptable to XSLT?
    Thanks,
    -Allan

    This seems to have a solution by using JAXB custom bindings. See http://forum.java.sun.com/thread.jsp?forum=34&thread=507037
    Thanks anyway.
    -Allan

  • JAXB Marshalling devouring memory

    Hi there.
    I noticed some disturbing behavior with how JAXB marshals large XML documents. I have around 5000 data objects which, when marshalled, result in an XML document about 9.5 mb in size. Prior to calling marshal(), I had over 47mb available on my Heap. Before this method returned, an OutOfMemoryError had been thrown. I was able to fix this problem by setting my max Heap size to 128mb.
    My concern is how this will scale with larger data sets, as I don't want to keep throwing more and more ram at the problem. I haven't run any concrete benchmarks yet, but I was wondering if anyone has run into this problem before and could share some numbers with me.
    Thanks in advance!

    Immediately prior to calling marshal(), I have approx 47 mb available out of an original 64. So for 5000 catalog items, I'm using a max of 17 mb; that's 3.4 k for each item bound to JAXB. That's not unacceptable. The problem is that in the process of marshalling this data to XML, over 50 mb is being consumed. This XML is sent to a remote Web Service (the spec allows for xml up to 35mb), so the size of the document is not unreasonable.
    I did a little benchmarking, and found this behavior to scale fairly linearly, which is a Good Thing (128mb per 9000 items). However, I'm wondering if JAXB allows for more efficient memory management for marshalling larger data sets (i.e. Serializing binding objects to disk until it's time to build them to xml, or releasing objects as soon as they're marshalled).

  • Read XML from Azure CDN Marshalled error

    I would like to load an XML file stored in Azure CDN in a Windows 8.1 App. This code throws Marshaling error:The application called an interface that was marshalled for a different thread. (Exception from HRESULT:
    0x8001010E (RPC_E_WRONG_THREAD))
           public async Task<XDocument> LoadXmlFromCDNAsync()
      var url = new Uri("http://azXXXXXX.vo.msecnd.net/cdn/Data.xml");
                var handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip };
                var client = new HttpClient(handler);
                XDocument doc = new XDocument();
                using (var stream = await client.GetStreamAsync(url))
                    doc = XDocument.Load(stream);
                return doc;
    Thanks.
    FS

    Hi,
    I test your codes. And the result below:
    I can successfully load the XML file. I think there is no problem in the codes which you used to load an XML file.
    And as the error says, the problem is the thread on which the call occurs: the app cannot manipulate UI elements from non-UI threads.  That error usually means you are calling something that requires the UI thread from a different thread. You can
    call Dispatcher.RunAsync to marshall a task back to the UI thread.
    See
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.core.coredispatcher.runasync.aspx
    And see the thread below:
    https://social.msdn.microsoft.com/Forums/en-US/f1fe027f-2c6c-4a22-9418-566fcf67cebe/the-application-called-an-interface-that-was-marshalled-for-a-different-thread?forum=winappswithcsharp
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • MINOR CODE: jms corba marshalling error

    I have a JMS queue connection factory and queue deployed on Sun Application Server 8.2 that I am trying to access through jndi. I am able to look up the queues using JNDI when I run a command line test program. It sets the context using my jndi.properties file.
    java.naming.factory.initial=com.sun.appserv.naming.S1ASCtxFactory
    java.naming.provider.url=iiop://smosi-1:3360
    b2bconnection.queueConnectionFactory=jms/B2BintegrationMDBDestinationFactory
    b2bconnection.queueName=jms/B2BintegrationMDBBeanWhen I run the code from within another application server called pramati, I get the stack trace printed out below. Pramati is the application server from where I'm trying to access the JMS qeueus located on sun application server. It looks like a marshalling error. I did some digging around, and found out that I am able to read all of the objects from JNDI ( i.e. jms, jdbc, ejb, etc ) except for a mysterious context called __SYSTEM that is being used by the java libraries to load the jmsra resource adapter. This context can be loaded from the command line, but not within the pramati application server. Any attempt to load it gives the error below... If I can solve this, I'll be the star of the development team for sure. PLEASE help me if you can. Thanks.
    Other things to note are that both servers have been configured to use the same JDK version, which is 1.4.2_12.
    Aug 16, 2006 4:42:32 PM com.sun.corba.ee.impl.encoding.CDRInputStream_1_0 read_v
    alue
    WARNING: "IOP00810210: (MARSHAL) Error from readValue on ValueHandler in CDRInpu
    tStream"
    org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 210 completed: Maybe
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.valuehandlerRead
    Error(ORBUtilSystemException.java:6646)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:1048)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:879)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_inter
    face(CDRInputStream_1_0.java:873)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_inter
    face(CDRInputStream_1_0.java:863)
    at com.sun.corba.ee.impl.encoding.CDRInputStream.read_abstract_interface
    (CDRInputStream.java:275)
    at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectDelegate(IIOPInput
    Stream.java:363)
    at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectOverride(IIOPInput
    Stream.java:526)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333)
    at java.util.Hashtable.readObject(Hashtable.java:848)
    at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.corba.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInput
    Stream.java:1694)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.
    java:1212)
    at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputSt
    ream.java:400)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHand
    lerImpl.java:330)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.
    java:296)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:1034)
    at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStre
    am.java:259)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputSt
    ream.java:1989)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputSt
    ream.java:2213)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.
    java:1221)
    at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputSt
    ream.java:400)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHand
    lerImpl.java:330)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.
    java:296)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:1034)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:879)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_inter
    face(CDRInputStream_1_0.java:873)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_inter
    face(CDRInputStream_1_0.java:863)
    at com.sun.corba.ee.impl.encoding.CDRInputStream.read_abstract_interface
    (CDRInputStream.java:275)
    at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectDelegate(IIOPInput
    Stream.java:363)
    at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectOverride(IIOPInput
    Stream.java:526)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333)
    at java.util.Hashtable.readObject(Hashtable.java:848)
    at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.corba.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInput
    Stream.java:1694)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.
    java:1212)
    at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputSt
    ream.java:400)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHand
    lerImpl.java:330)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.
    java:296)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:1034)
    at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStre
    am.java:259)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputSt
    ream.java:1989)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputSt
    ream.java:2213)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.
    java:1221)
    at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputSt
    ream.java:400)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHand
    lerImpl.java:330)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.
    java:296)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:1034)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:879)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_inter
    face(CDRInputStream_1_0.java:873)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_inter
    face(CDRInputStream_1_0.java:863)
    at com.sun.corba.ee.impl.encoding.CDRInputStream.read_abstract_interface
    (CDRInputStream.java:275)
    at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectDelegate(IIOPInput
    Stream.java:363)
    at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectOverride(IIOPInput
    Stream.java:526)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333)
    at java.util.Hashtable.readObject(Hashtable.java:848)
    at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.corba.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInput
    Stream.java:1694)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.
    java:1212)
    at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputSt
    ream.java:400)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHand
    lerImpl.java:330)
    at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.
    java:296)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInput
    Stream_1_0.java:1034)
    at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStre
    am.java:259)
    at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14
    .read(DynamicMethodMarshallerImpl.java:333)
    at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.re
    adResult(DynamicMethodMarshallerImpl.java:424)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invo
    ke(StubInvocationHandlerImpl.java:133)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unkno
    wn Source)
    at com.sun.enterprise.naming._SerialContextProvider_DynamicStub.list(_Se
    rialContextProvider_DynamicStub.java)
    at com.sun.enterprise.naming.SerialContext.list(SerialContext.java:478)
    at javax.naming.InitialContext.list(InitialContext.java:395)
    at com.sun.b2b.connection.B2BConnector.printContext(B2BConnector.java:72
    Message was edited by:
    queperknuckle

    Tried with following error,
    String orbArgs[] = new String[] { "-ORBInitRef", nameService };
    java.util.Properties props = System.getProperties();
    props.put("org.omg.CORBA.ORBClass", "com.iona.corba.art.artimpl.ORBImpl");
    props.put("org.omg.CORBA.ORBSingletonClass", "com.iona.corba.art.artimpl.ORBSingleton");
    // create and initialize the ORB
    orb = ORB.init(orbArgs, props);
    But now received,
    org.omg.CORBA.INITIALIZE: can't instantiate default ORB implementation com.iona.corba.art.artimpl.ORBImpl  vmcid: 0x0 minor code: 0  completed: No
            at org.omg.CORBA.ORB.create_impl(ORB.java:297)
              at org.omg.CORBA.ORB.init(ORB.java:336)
    Please help.

  • JAXB marshal "lt;" and "gt;" instead " " and " "... URGENT

    Hi!
    I defined in jaxb that some tag (un)marshal (from/to) org.w3c.dom.Document.
    But when jaxb marshalling, the assigned document has got
    "lt" instead "<"
    "gt" instead ">".
    This is "equals" characthers when is represent in browser, but itegrity of xml file in not same.
    How can I forced "<" and ">"?
    Please, can me anybody help?

    I assume you mean it displays the following substitutions in the output document.
    & lt;      <      less than
    & gt;      >      greater than
    & amp;      &      ampersand
    & apos;      '      apostrophe
    & quot;      "      quotation mark
    { I have had to add an artificial space after the & in the entity reference, to prevent this forum from doing the entity reference subsititution even!}
    These are predefined entity references, which are required for valid xml. Since xml element are delimited by '<' and '>', the parser needs to know that you are not trying to define new elements when you use these characters in element text.
    If you use a parser on the output xml, you will get '<' and '>' back as the resulting element text.
    Scott
    http://www.swiftradius.com

  • JAXB unmarshalling error

    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x >100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • JAXB unmarshalling error for " " token as part of xsd:string type element

    JAXB unmarshalling error for "<" token as part of xsd:string type element
    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x > 100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • JAXB Validation Error

    Hi,
    Iam using JAXB. I get an validation error. When i try to marshal an object to XML. The code is simple as shown below
    1. Container.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://agi.com"
    xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://agi.com"
    elementFormDefault="qualified">
    <complexType name="ContainerType" abstract="true">
    <sequence>
    <choice>
    <element name="File" type="anyType" />
    <element name="Pen" type="anyType" />
    </choice>
    </sequence>
    </complexType>
    <element name="Container" type="tns:ContainerType" abstract="true" />
    </schema>
    2. Holder.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://agi.com"
    xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://agi.com"
    elementFormDefault="qualified">
    <include schemaLocation="Container.xsd"></include>
    <complexType name="HolderType">
    <complexContent>
    <restriction base="tns:ContainerType">
    <sequence>
    <choice>
    <element name="File">
    <complexType>
    <sequence>
    <element name="FileName"
    type="string">
    </element>
    <element name="Capacity"
    type="integer">
    </element>
    </sequence>
    </complexType>
    </element>
    <element name="Pen">
    <complexType>
    <sequence>
    <element name="Make"
    type="string">
    </element>
    </sequence>
    </complexType>
    </element>
    </choice>
    </sequence>
    </restriction>
    </complexContent>
    </complexType>
    <element name="Holder" type="tns:HolderType"></element>
    </schema>
    Main.java
    package test.client;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.math.BigInteger;
    import java.util.List;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Marshaller;
    import javax.xml.bind.Unmarshaller;
    import javax.xml.bind.Validator;
    import test.vo.AnyType;
    import test.vo.Holder;
    import test.vo.ObjectFactory;
    import test.vo.HolderType.FileType;
    import test.vo.HolderType.PenType;
    import com.sun.xml.bind.StringInputStream;
    public class Main {
    public static void main(String s[]) throws Exception{
    JAXBContext ctx = JAXBContext.newInstance("test.vo" );
    ObjectFactory obj = new ObjectFactory();
    Holder input = obj.createHolder();
    FileType file = obj.createHolderTypeFileType();
    file.setCapacity( BigInteger.valueOf(35) );
    file.setFileName("Accounts");
    AnyType any = obj.createAnyType();
    List lst = any.getContent();
    lst.add(file);
    input.setFile(any);
    Marshaller marsh = ctx.createMarshaller();
    marsh.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
    new Boolean(true));
    marsh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
    "http://agi.com");
    Validator validator = ctx.createValidator();
    validator.validate(input);
    StringWriter sw = new StringWriter();
    marsh.marshal(input, new PrintWriter(sw) );
    StringBuffer sb = sw.getBuffer();
    System.out.println(sb.toString() );
    This throws the following exception
    DefaultValidationEventHandler: [ERROR]: tag name "test.vo.AnyType" is not allowed. Possible tag names are: <test.vo.HolderType.FileType>
    Location: obj: test.vo.impl.HolderImpl@1cd8669
    Exception in thread "main" com.sun.xml.bind.serializer.AbortSerializationException: tag name "test.vo.AnyType" is not allowed. Possible tag names are: <test.vo.HolderType.FileType>
    at test.vo.impl.runtime.ValidationContext.reportEvent(ValidationContext.java:199)
    at test.vo.impl.runtime.ValidationContext.reportEvent(ValidationContext.java:166)
    at test.vo.impl.runtime.MSVValidator.childAsElementBody(MSVValidator.java:336)
    at test.vo.impl.runtime.MSVValidator.childAsBody(MSVValidator.java:292)
    at test.vo.impl.ContainerTypeImpl.serializeBody(ContainerTypeImpl.java:52)
    at test.vo.impl.HolderTypeImpl.serializeBody(HolderTypeImpl.java:30)
    at test.vo.impl.HolderImpl.serializeBody(HolderImpl.java:43)
    at test.vo.impl.runtime.MSVValidator._validate(MSVValidator.java:102)
    at test.vo.impl.runtime.MSVValidator.validate(MSVValidator.java:77)
    at test.vo.impl.runtime.ValidationContext.validate(ValidationContext.java:75)
    at test.vo.impl.runtime.ValidatorImpl.validate(ValidatorImpl.java:121)
    at test.vo.impl.runtime.ValidatorImpl.validate(ValidatorImpl.java:104)
    at test.client.Main.main(Main.java:63)
    However if i commentout the validation it works fine yeilding the
    following result
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Holder xsi:schemaLocation="http://agi.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://agi.com">
    <File>
    <FileName>Accounts</FileName>
    <Capacity>35</Capacity>
    </File>
    </Holder>
    Which look good conforming to the schema above
    It willbe helpful if someout could point out the mistake iam doing
    Please help
    Regards
    Agilan Palani

    I changed the code
    marsh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,"http://agi.com Holder.xsd");
    to
    marsh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,"http://agi.com E:/Agilan/Holder.xsd");
    But still the same error.
    I have validated the generated xml using XMLObjective. It says the generated xml is valid against the schema.
    I really dont know why the JAXB validation fails?
    Please help

  • JAXB-marshalling problem

    I am trying to use JAXB for binding. The schema compiler works ok i.e i have got the classes generated but when now when i try to apply marshalling i get an error
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/MarshallableObject
    could anyone help what could be the problem with this.
    Any help is appreciated.
    satya

    i am also getting the same error
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/MarshallableRootElement
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at NodeLister.main(NodeLister.java:46)
    i do not know what to do now...i am stuck

  • JAXB: Encoding error (Malformed UTF-8, trying to set ISO)

    Hi, I get this error when doing a Unmarshaller.unmarshal( anURL );
    DefaultValidationEventHandler: [WARNING]: Declared encoding "ISO-8859-1" does not match actual one "UTF-8"; this might not be an error.
    DefaultValidationEventHandler: [FATAL_ERROR]: Character conversion error: "Malformed UTF-8 char -- is an XML encoding declaration missing?" (line number may be too low).
    org.xml.sax.SAXParseException: Character conversion error: "Malformed UTF-8 char -- is an XML encoding declaration missing?" (line number may be too low).
         at org.apache.crimson.parser.InputEntity.fatal(InputEntity.java:1100)
    (...) etc..So far, I set the ISO-8859-1 encoding 4 places;
    1. the xml response from the servlet: xml.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n")
    2. the original XSD which the JAXB classes was generated from
    3. In the client, after recieving the string containing the XML: bytes b[] = xmlString.getBytes("ISO-8859-1");
    4. In the client; when posting to the server: httpConn.setRequestProperty("Content-Type","text/xml;charset=ISO-8859-1");
    Yet, JAXB still thinks I'm doing UTF-8 here! Did I forget something?
    thanks,
    bjorn

    bump .. no one knows why this happens?

  • JAXB compiler error : Complex Type Definition Representation Error

    Hi,
    I have a problem when I try to generate Java classes for the XML Digital Signature schema along with the XAdES extension. Apparently, we got an XML validation issue when the XAdES schema is parsed.
    Here is the xjc tool ouput :
    [ERROR] src-ct.1: Complex Type Definition Representation Error for type 'IdentifierType'.  When complexContent is used, the base type must be a complexType.
      line 33 of XAdES.xsd
    [ERROR] src-ct.1: Complex Type Definition Representation Error for type 'EncapsulatedPKIDataType'.  When complexContent is used, the base type must be a complexType.
      line 57 of XAdES.xsdNow these are the schema lines from XAdES.xsd that cause the problem :
    <xsd:complexType name="IdentifierType">
      <xsd:complexContent>
        <xsd:extension base="xsd:anyURI">
          <xsd:attribute name="Qualifier" type="QualifierType" use="optional"/>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="EncapsulatedPKIDataType">
      <xsd:complexContent>
        <xsd:extension base="xsd:base64Binary">
          <xsd:attribute name="Id" type="xsd:ID" use="optional"/>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>The most disturbing thing is that those two schemas I used (e.g. xmldsig-core-schema.xsd and XAdES.xsd) come directly from the W3C, so they should be fully compliant to the XML schema spec, shouldn't they ?
    Moreover, I tried to validate these two schemas with XML Spy 4.3 and the problem occurs in slightly different way. In fact, the <xsd:complexContent> tags are replaced silently by XML Spy with <xsd:simpleContent> tags in order to validate the schema. So XML Spy seems to have a problem too with these complex type definitions. Besides, if I replace the <xsd:complexContent> tags the same way as XML Spy does, and if I run again the JAXB compiler, it works fine...
    Does anyone have any knowledge about this issue ? I'd like very much to hear about anyone who has experienced or better solved the same kind of issue.
    By the way, here is the version of JAXB that I use :
    xjc version "1.0.2-b15-fcs"
    JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build 1.0.2-b15-fcs)Any help appreciated.
    Thanks,
    Gregory

    <xsd:extension base="xsd:anyURI">
    <xsd:extension base="xsd:base64Binary">
    The base attribute of the xs:extension elements shoule refer to a complexType.
    For example,
    <xs:complexType name="complexTypeA">
    </xs:complexType>
    <xsd:complexType name="IdentifierType">
    <xsd:complexContent>
    <xsd:extension base="complexTypeA">
    <xsd:attribute name="Qualifier" type="QualifierType" use="optional"/>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

  • JAXB marshaling and unmarshaling

    I used JAXB to generate nine classes (one is simply a type-safe enum) to correspond to my XML DTD. I then wrote the code to instantiate the root and some child elements which are all added to the root content. Then I am able to call validate() and marshal() on the root element and produce the desired XML. Great!
    The trouble is that I'm having difficulty using these classes to unmarshal the XML that they validated and wrote. Has anyone else seen this? In some cases, the call to unmarshal() returns the root element with no content (e.g., "<myRoot/>"). In other cases, I get an InvalidContentException on a nested element that repeats (e.g., "Expected an end tag for a "fooList" element, but found a start tag for a "foo" element").
    Has anyone else seen this? I've been through the bug parade and didn't catch this mentioned there.
    Thanks!
    Mark

    Here's the code for the problem I'm running into. Is anyone able to reproduce the problem and diagnose it? I must be doing something wrong because the Checkbook example works just fine for me. Please help!
    The obvious trouble here is that Test4.java does not correctly unmarshal the XML that it writes to temp.xml. Where have I gone wrong?
    Thanks,
    Mark
    -------- begin cut (xyz.dtd) --------
    <!ELEMENT Id ( #PCDATA ) >
    <!ELEMENT Name ( #PCDATA ) >
    <!ELEMENT Amt ( #PCDATA ) >
    <!ELEMENT Transaction ( Id, Name, Amt ) >
    <!ELEMENT Transactions ( Transaction+ ) >
    <!ATTLIST Transactions count NMTOKEN #IMPLIED >
    --------- end cut (xyz.dtd) ---------
    -------- begin cut (xyz.xjs) --------
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xml-java-binding-schema version="1.0-ea">
    <options package="xyz"/>
    <element name="Transactions" type="class" root="true">
    <attribute name="count" convert="int"/>
    <content>
    <element-ref name="Transaction"/>
    </content>
    </element>
    <element name="Name" type="value"/>
    <element name="Amt" type="value" convert="int"/>
    <element name="Id" type="value" convert="int"/>
    <element name="Transaction" type="class">
    <content>
    <element-ref name="Id"/>
    <element-ref name="Name"/>
    <element-ref name="Amt"/>
    </content>
    </element>
    </xml-java-binding-schema>
    --------- end cut (xyz.xjs) ---------
    -------- begin cut (Test4.java) --------
    import xyz.*;
    import javax.xml.bind.*;
    import javax.xml.marshal.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Random;
    public class Test4 {
    private static Random rand = new Random();
    public static void main(String[] args) {
    // need file to work with...
    try {
    File f = new File( "temp.xml" );
    FileOutputStream fout =
    new FileOutputStream( f );
    // make some transactions
    int TransCt = 1;
    Transactions txns = new Transactions();
    java.util.List transactions = txns.getTransaction();
    for (int i=0; i < TransCt; i++) {
    Transaction t = makeBogus();
    transactions.add( t );
    txns.setCount( TransCt );
    txns.validate();
    txns.marshal( fout );
    fout.flush();
    fout.close();
    FileInputStream fin = new FileInputStream( f );
    Transactions t = new Transactions();
    t.unmarshal( fin );
    t.validate();
    t.marshal( System.out );
    catch (Exception e) {
    e.printStackTrace();
    private static Transaction makeBogus() {
    String[] names =
    { "Bob", "Larry", "Tom", "Ted", "Bill",
    "Gail", "Louise", "Sam", "Erin", "Wilma" };
    Transaction transaction = new Transaction();
    // calculate transaction id...
    int range = Integer.MAX_VALUE / 3 * 2;
    int Id = rand.nextInt(range);
    transaction.setId( Id );
    // pick a name
    transaction.setName( names[rand.nextInt(10)] );
    transaction.setAmt( rand.nextInt( 100 ) );
    return transaction;
    --------- end cut (Test4.java) ---------

  • JAXB Marshalling without UnMarshalling

    Hi,
    Using JAXB can I Marshall an java object to xml directly without Unmarshalling it first?
    Thanks.

    well... yes, as long as the java object is in java binding format...

Maybe you are looking for

  • How to populate a poplist through a record group?

    Dear People, I use forms along with 10g.I have create a record group RG9 with query SELECT DNAME FROM DEPT;.now how to populate it to a list item?.i tried it using a the following code in When_new_form_instance trigger.The code is as follows, declare

  • IBook G4 and HDTV

    Hello, I have an iBook G4 (1.33 GHz, 1.5 GB) running OS 10.4.11. Can the iBook use a 1080p LCD HDTV as a monitor for showing iPhoto slideshows, etc? If so, what adaptors, cables, etc. do I need? Thanks. Mike

  • Several random osx 10.4 questions

    hello- i just updated from 10.2 and im having a few problems. 1) i cannot install windows media player or AIM (4.7, for mac). i download the files and they come up as unreadable. is there a solution? 2) is there a way to change the 'short name' of yo

  • {O:201*FUNCTION-POOL=WDR_RG_PROXY_FACTORYCLASS=LCL_VIEW_CTLR_PROXY}

    hi when i am debugging method     i got this what is the meaning of this

  • Pm-suspend not waking up properly

    The log file does not indicate a problem.  It goes to sleep fine, but when i wake it up the monitor does not come back on and the keyboard (usb) is flashing on and off. here is the /var/log/pm-suspend.log: Initial commandline parameters: Mon Jun 15 1