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.

Similar Messages

  • 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).

  • 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 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...

  • JAXB Marshalling Question

    below is what I get for marshalling some JAXB generated class instance, and i notice that several namespace was create ns1, ns2, ns3.... which are actually all sharing the same namespace, is there anyway (any option) that I can set to optimize it, so they can all simply use ns1, and won't define ns2, ns3...
    thank you.
    Jacob
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <aaa xmlns="http://schema.abc.com/def/gh">
    <ns1:HeaderReq xmlns:ns1="http://schema.abc.com/def">
    <ns1:Header>
    <ns1:sessionToken>sessionToken</ns1:sessionToken>
    <ns1:language>eng</ns1:language>
    <ns1:version>version2</ns1:version>
    </ns1:Header>
    <ns1:ddd>web</ns1:ddd>
    <ns1:eee>a</ns1:eee>
    </ns1:HeaderReq>
    <ns2:ccc xmlns:ns2="http://schema.abc.com/def">accountToken</ns2:ccc>
    <bbb>
    <ns3:firstName xmlns:ns3="http://schema.abc.com/def">Jacob</ns3:firstName>
    <ns4:lastName xmlns:ns4="http://schema.abc.com/def">Tseng</ns4:lastName>
    <relationship>SON</relationship>
    </bbb>
    </aaa>

    Hi Jacob,
    Here is the solution I used for getting rid of ns1,ns2 etc..when I was getting ns1,ns2.. etc.along with http://www.xyz.com/xml/yourxml in the generated XML output
    It worked for me. Let me know if you need any further help.
    -bhanu
    Please include the Following Code when you are marshalling the Document
    ======================== Your Main Java File ======================
    try {
              m.setProperty("com.sun.xml.bind.namespacePrefixMapper",new NamespacePrefixMapperImpl());
    // m is the Marshaller Object
    // NamespacePrefixMapperImpl()
    // You have to implement, sample code is given below
         catch ( PropertyException pe)
              System.out.println("Property Exception : " + pe.toString());
    ===============================================================
    Here is the Sample Code to implement NamespacePrefixMapperImpl()
    =========================================================
    import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
    class NamespacePrefixMapperImpl extends NamespacePrefixMapper {
    public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
    // W3c to show a prefix "xsi"
    if( "http://www.w3.org/2001/XMLSchema-instance".equals(namespaceUri) )
    return "xsi";
    // Your namespace http://www.xyz.com/yourxml/ to show prefix "tns"
    if( "http://www.xyz.com/yourxml/".equals(namespaceUri) )
    return "tns";
    return suggestion;

  • JAXB - Marshalling populated Java object into XML

    I have a populated Java object that I'd like to marshall to an xml file.
    I don't instantiate this object from a DTD, nor do I need to generate the object via unmarshalling an xml. I'm just trying to build something akin to a toXML() method for this object.
    Is JAXB what I should be using?
    Any suggestions?
    Thanks a lot.
    Paul

    Hi Paul,
    Did you ever sort this out?
    I too am now having problems with Marshalling to and from XML.
    I have been able to write my own Marshalling class but can't seem to be able to DeMarshal a XML stream to a SOAP object.
    Please reply to this message if you are able to maybe shed some light on my problem.
    I have a populated Java object that I'd like to
    marshall to an xml file.
    I don't instantiate this object from a DTD, nor do I
    need to generate the object via unmarshalling an xml.
    I'm just trying to build something akin to a toXML()
    method for this object.
    Is JAXB what I should be using?
    Any suggestions?
    Thanks a lot.
    Paul

  • 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 marshal and unmarshal

    hello,
    i have written some code to retrieve data from an XML file and mapped the data and display the mapped data in a new XML file, but i am able to display the mapped data in an MSdos window by running ANT, after this i am unable to write the displayed data in to XML file.
    Input XML file holds --- Firstname(Hello) and
    Lastname(World)
    my MSdos display data ----------- Hello World
    is in this way
    I want the above out put in to XML file
    if any body know this help me.
    Thank you.

    IMHO these classes are not meant to be serialised, the XML produced is the medium that is tranmitted between programs. The XMLB classes are available at both ends to do the marshalling/unmarshalling.I dissagree, xml is just an interface to the outside world, so to speak. I'm working with a project that uses jini and rmi, I really don't need the extra hasle of writting custom serialization classes.

  • 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,

  • JAXB: Marshalling complex nested data structures?

    Hello!
    I am dealing with complex data structures:
    Map< A, Set< B > >
    Set< Map< A, B > >
    Map< A, Map< B, Set< C > > >
    Map< A, Set< Map< B, C > > >
    [and so on](NOTE: In my case it doesn't matters if I use Set<?> or List<?>)
    I wanted to write wrappers for JAXB for these data structures, but I have no idea how.
    My idea was: write XmlAdapter with generics for Map, Set and List, but it failed:
    "[javax.xml.bind.JAXBException: class java.util.LinkedList nor any of its super class is known to this context.]"
    because I was using LinkedList<T> inside the XmlAdapter (it seems that from the point of view of JAXB,
    LinkedList<T> is same as LinkedList<Object>)
    Any ideas?

    According to sec 4.4 "By default if xml schema component for which java content interface is to be generated is scoped within a complex type then the java content interface should appear nested within the content interface representing the complex type. ".
    So I doubt that worked with beta and you may have to represent this anonymous complex type as a named complex type to avoid the nesting.
    Regards,
    Bhakti

  • JAXB marshalling complexType elements

    Does anyone know why JAXB always marshalls complexType elements with a seperate start and end tag, even if the element has no content?
    i.e.
    Given the schema element declaration:
    <xs:element name="foo" type="fooType"/>
    <xs:complexType name="fooType">
    <xs:attribute name="value" type="xs:string" use="required"/>
    </xs:complexType>
    Why do I get:
    <foo value="bar"></foo>
    Instead of:
    <foo value="bar"/>
    Is their a setting / property to control this behaviour?
    If not then I certainly think there should be because this will bloat the 5Mb XML files I am currently dealing with by quite a lot.
    Cheers,
    Simon

    I have exactly the same trouble here. Did you find a solution? If so, please contact me. I am so afraid of increase the amount space used to store all XML files.
    Thanks in advance
    Julio Garc�a
    [email protected]

  • XML marshalling exception

    Hello,
    I'm using Toplink JAXB to generate XML document from java classes in a JSF application (all in JDeveloper 10.1.3).
    Everything works fine in JDeveloper embedded OC4J, but when deploed to OAS 10.1.3, the application gives the following exception:
    Exception [TOPLINK-25007] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.XMLMarshalExceptionException Description: A descriptor for class com.allstate.mqq.re.xao.jaxb.map.MqqrequestImpl was not found in the project]
    Has anyone experienced the same problem?
    Please help
    Thanks
    Kate

    See:
    Re: Toplink JAXB Marshalling
    -Blaise

  • Running JAXB2 in a 10g Database

    Hi All,
    We have some java business logic which uses JAXB2. We now would like to be able to call / store this java code inside the database. It's a 10g database, which I understand has the 1.4 JVM, so I've retrotranslated the code (and the JAXB2 dependencies) and created a compatible jar. The loadjava command^1^ completes successfully, however when I try and execute the code which unmarshals the XML, I get the following error: Caused by: java.lang.RuntimeException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
    The ContextFactory is definitely in the jar file. Looking through the generated DB trace file I see the following:
    creating : class com/sun/xml/bind/v2/ContextFactory with resolver ((* london) (* PUBLIC) (org/apache/* -) (jp/gr/xml/relax/* -) (com/bea/* -) (javax/management/* -) (com/thoughtworks/xstream/* -) (org/jvnet/* -) (com/sun/xml/fastinfoset/* -) (sun/misc/* -))
    but then, instead of resolving the class:
    skipping : class com/sun/xml/bind/v2/ContextFactory
    Why would the ContextFactory be skipped? Is there any way I can force the loadjava command to resolve it?
    1. The server-side loadJava command I use is: call sys.dbms_java.loadjava( '-force -verbose -resolve /scripts/p3/db_sql/cta23001.jar','((* london) (* PUBLIC) (org/apache/* -) (jp/gr/xml/relax/* -) (com/bea/* -) (javax/management/* -) (com/thoughtworks/xstream/* -) (org/jvnet/* -) (com/sun/xml/fastinfoset/* -) (sun/misc/* -))' );

    Hi:
    You can find Jaxb related classes implemented by Oracle into ${ORACLE_HOME}/lib/xml.jar but not all classes should be installed, please look at Ant task named unpack-jaxb-classes at:
    [http://dbprism.cvs.sourceforge.net/viewvc/dbprism/cms-2.1/tasks/cms.xml?revision=1.19&view=markup]
    this Ant task extract all Jaxb required classes which can be installed into an Oracle 10g/11g database, see the Task pre-install which install this jar into SYS's schema.
    To see how to use Jaxb marshall/unmarshall operation please take a look at the method processRequestAction, inside the code you can see how to instantiate the marshaller and unmarshaller:
    [http://dbprism.cvs.sourceforge.net/viewvc/dbprism/cms-2.1/src/com/prism/cms/action/Controller.java?revision=1.8&view=markup]
    Best regards, Marcelo.

Maybe you are looking for