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

Similar Messages

  • Marshalling and Unmarshalling on xml

    is this the one of the way of parsing xml??

    If by "marshalling and Unmarshalling on xml" you mean converting between XML and Java, then yes, JAXB can be a viable alternative to SAX or DOM, depending on your requirements.
    It is a simpler solution if it's the binding that you actually need.
    If Java representation of XML isn't relevant and you're only concerned about firing events when a particular XML artifact is detected, then SAX would be more indicated.
    Take the good habit of listing your actual requirements before considering a range of options.

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

  • 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 2.0] Unmarshalling error if the XML contains w3c.Element nodes

    Hi!
    I'm using the JAXB 2.0 library to create an XML file according to a XML Schema (XSD).
    I use the JAXB 2.0 classes, that I have previuosly generated, to fill the data and finally I execute the marshal method to store a XML file with the object's info.
    The second step is unmarshalling the file. Alright in my first attempt: I get all the JAXB objects filled with the data of the file.
    Now I try to add w3c.dom.Element nodes underneath a JAXB object that accepts a list of w3c.dom.Elements:
    org.w3c.dom.Element cip = (org.w3c.dom.Element) doc.createElement("CIP");
    root.appendChild(cip);
    t = doc.createTextNode("CIP");
    t.setData("TEST");
    cip.appendChild(t);
    qpd3.getAny().add(cip);
    And the resulting XML file is marshalled correctly again. Moreover, the node QPD contains a list of simple nodes like 'CIP' (the w3c.dom.Element of the example).
    The second step, to try unmarshalling the XML file I just have generated:
    Using a main method in my class the file is unmarshalled with no problems.
    It's now, when I deploy the web service that calls the unmarshall method (sending the same XML file to the same function), I receive a parsing error!!
    2007-01-30 20:00:08.221 ERROR caught exception while handling request: java.lang.IllegalAccessError: void oracle.xml.parser.schema.XSDNode.<init>()
    Why does this error appear??? I supose JDeveloper tries to parser the w3c.dom.Element nodes like a XSDNode and therefore it fails (what is a XSDNode...?). But if I execute the same method from the "main" of my class it works! Maybe the problem is related with the libraries that OC4J loads when it starts...
    Can anyone help me?? Thanks in advance!
    Sergi

    Hi Blaise,
    The Document class I use to generate the w3c.dom.Element nodes in the marshaling procedure belongs to oracle.xml.parser.v2.XMLDocument class. And it is located in the jar file: file:/C:/Oracle/jdeveloper/jdk/jre/lib/rt.jar!/org/w3c/dom/Document.class
    I have also checked if the unmarshal method of my class has linked the same library, althought is not used in the unmarshalling process (but maybe is implicit...) and it's OK.
    Have you seen something wrong?
    Thank you!
    Sergi

  • 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 behaviour when unmarshalling documents with an encoding declaration

    The following is against JWSDP-1.5, 1.4.2_07-b05 on XP Pro SP 2...
    When I unmarshall a document using JAXB 1.0, and obtain Strings from the resulting objects, I would expect the Strings to be encoded with the character encoding specified by the text declaration. Is this a correct assumption?
    Unfortunately, from the sample code (given below) I am not experiencing this behaviour. I've included the code, sample output, and the RELAX NG schema used.
    Any help very welcome.
    ian
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.util.List;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.JAXBException;
    import javax.xml.bind.Marshaller;
    import org.xml.sax.InputSource;
    import com.chellomedia.transcoding.Category;
    import com.chellomedia.transcoding.ObjectFactory;
    import com.chellomedia.transcoding.Schedule;
    public class TranscoderExemplar {
         private static final String CATEGORY_NAME = "\u00bfMa\u00f1ana?";
         public static void main(String[] args) throws Exception {
              try {
                   ByteArrayOutputStream os = generateSampleDocument("US-ASCII");
                   inspectDocument("US-ASCII", os);
                   os = generateSampleDocument("ISO-8859-1");
                   inspectDocument("ISO-8859-1", os);
                   os = generateSampleDocument("UTF-8");
                   inspectDocument("UTF-8", os);
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (JAXBException e) {
                   e.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
         private static void inspectDocument(String encoding, ByteArrayOutputStream os) throws Exception {
              byte[] b = os.toByteArray();
              System.out.println(encoding + " document byte length: " + b.length);
              InputSource is = new InputSource(new ByteArrayInputStream(b));
              is.setEncoding(encoding);
              JAXBContext context = JAXBContext.newInstance("com.chellomedia.transcoding");
              Schedule schedule = (Schedule)context.createUnmarshaller().unmarshal(is);
              context.createValidator().validate(schedule);
              List categories = schedule.getCategories();
              for (int i = 0, n = categories.size(); i < n; i++) {
                   Category c = (Category)categories.get(i);
                   String name = c.getName();
                   System.out.println(encoding + " name string length: " + name.length());
                   System.out.println(encoding + " name byte length: " + name.getBytes().length);
         private static ByteArrayOutputStream generateSampleDocument(String encoding) throws JAXBException,
              FileNotFoundException
            ObjectFactory of = new ObjectFactory();
              Schedule schedule = of.createSchedule();
              List categories = schedule.getCategories();
              Category category = of.createCategory();
              category.setId(1);
              category.setName(CATEGORY_NAME);
              categories.add(category);
              Marshaller m = of.createMarshaller();
              m.setProperty("jaxb.encoding", encoding);
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              m.marshal(schedule, os);
              FileOutputStream fos = new FileOutputStream(encoding + "-representation.xml");
              m.marshal(schedule, fos);
              return os;
    }...and the schema
    <grammar xmlns="http://relaxng.org/ns/structure/1.0"
             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
             xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
             xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
             jaxb:extensionBindingPrefixes="xjc"
             jaxb:version="1.0">
      <jaxb:schemaBindings>
        <jaxb:package name="com.chellomedia.transcoding"/>
      </jaxb:schemaBindings>
      <start>
        <ref name="Schedule"/>
      </start>
      <define name="Schedule">
        <element name="schedule">
          <ref name="Categories"/>
          <zeroOrMore>
            <ref name="Event"/>
          </zeroOrMore>
        </element>
      </define>
      <define name="Categories">
        <element name="categories">
          <zeroOrMore>
            <ref name="Category"/>
          </zeroOrMore>
        </element>
      </define>
      <define name="Category">
        <element name="category">
          <attribute name="id"><data type="int"/></attribute>
          <attribute name="name"/>
          <zeroOrMore>
            <ref name="Subcategory"/>
          </zeroOrMore>
        </element>
      </define>
      <define name="Subcategory">
        <element name="subcategory">
          <attribute name="id"/>
          <attribute name="name"/>
        </element>
      </define>
      <define name="Event">
        <element name="event">
          <attribute name="id"/>
          <attribute name="title"/>
          <attribute name="description"/>
          <attribute name="category"/>
          <attribute name="subcategory"/>
        </element>
      </define>
    </grammar>...with sample output
    US-ASCII document byte length: 171
    US-ASCII name string length: 8
    US-ASCII name byte length: 8
    ISO-8859-1 document byte length: 163
    ISO-8859-1 name string length: 8
    ISO-8859-1 name byte length: 8
    UTF-8 document byte length: 160
    UTF-8 name string length: 8
    UTF-8 name byte length: 8

    The following is against JWSDP-1.5, 1.4.2_07-b05 on XP Pro SP 2...
    When I unmarshall a document using JAXB 1.0, and obtain Strings from the resulting objects, I would expect the Strings to be encoded with the character encoding specified by the text declaration. Is this a correct assumption?
    Unfortunately, from the sample code (given below) I am not experiencing this behaviour. I've included the code, sample output, and the RELAX NG schema used.
    Any help very welcome.
    ian
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.util.List;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.JAXBException;
    import javax.xml.bind.Marshaller;
    import org.xml.sax.InputSource;
    import com.chellomedia.transcoding.Category;
    import com.chellomedia.transcoding.ObjectFactory;
    import com.chellomedia.transcoding.Schedule;
    public class TranscoderExemplar {
         private static final String CATEGORY_NAME = "\u00bfMa\u00f1ana?";
         public static void main(String[] args) throws Exception {
              try {
                   ByteArrayOutputStream os = generateSampleDocument("US-ASCII");
                   inspectDocument("US-ASCII", os);
                   os = generateSampleDocument("ISO-8859-1");
                   inspectDocument("ISO-8859-1", os);
                   os = generateSampleDocument("UTF-8");
                   inspectDocument("UTF-8", os);
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (JAXBException e) {
                   e.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
         private static void inspectDocument(String encoding, ByteArrayOutputStream os) throws Exception {
              byte[] b = os.toByteArray();
              System.out.println(encoding + " document byte length: " + b.length);
              InputSource is = new InputSource(new ByteArrayInputStream(b));
              is.setEncoding(encoding);
              JAXBContext context = JAXBContext.newInstance("com.chellomedia.transcoding");
              Schedule schedule = (Schedule)context.createUnmarshaller().unmarshal(is);
              context.createValidator().validate(schedule);
              List categories = schedule.getCategories();
              for (int i = 0, n = categories.size(); i < n; i++) {
                   Category c = (Category)categories.get(i);
                   String name = c.getName();
                   System.out.println(encoding + " name string length: " + name.length());
                   System.out.println(encoding + " name byte length: " + name.getBytes().length);
         private static ByteArrayOutputStream generateSampleDocument(String encoding) throws JAXBException,
              FileNotFoundException
            ObjectFactory of = new ObjectFactory();
              Schedule schedule = of.createSchedule();
              List categories = schedule.getCategories();
              Category category = of.createCategory();
              category.setId(1);
              category.setName(CATEGORY_NAME);
              categories.add(category);
              Marshaller m = of.createMarshaller();
              m.setProperty("jaxb.encoding", encoding);
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              m.marshal(schedule, os);
              FileOutputStream fos = new FileOutputStream(encoding + "-representation.xml");
              m.marshal(schedule, fos);
              return os;
    }...and the schema
    <grammar xmlns="http://relaxng.org/ns/structure/1.0"
             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
             xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
             xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
             jaxb:extensionBindingPrefixes="xjc"
             jaxb:version="1.0">
      <jaxb:schemaBindings>
        <jaxb:package name="com.chellomedia.transcoding"/>
      </jaxb:schemaBindings>
      <start>
        <ref name="Schedule"/>
      </start>
      <define name="Schedule">
        <element name="schedule">
          <ref name="Categories"/>
          <zeroOrMore>
            <ref name="Event"/>
          </zeroOrMore>
        </element>
      </define>
      <define name="Categories">
        <element name="categories">
          <zeroOrMore>
            <ref name="Category"/>
          </zeroOrMore>
        </element>
      </define>
      <define name="Category">
        <element name="category">
          <attribute name="id"><data type="int"/></attribute>
          <attribute name="name"/>
          <zeroOrMore>
            <ref name="Subcategory"/>
          </zeroOrMore>
        </element>
      </define>
      <define name="Subcategory">
        <element name="subcategory">
          <attribute name="id"/>
          <attribute name="name"/>
        </element>
      </define>
      <define name="Event">
        <element name="event">
          <attribute name="id"/>
          <attribute name="title"/>
          <attribute name="description"/>
          <attribute name="category"/>
          <attribute name="subcategory"/>
        </element>
      </define>
    </grammar>...with sample output
    US-ASCII document byte length: 171
    US-ASCII name string length: 8
    US-ASCII name byte length: 8
    ISO-8859-1 document byte length: 163
    ISO-8859-1 name string length: 8
    ISO-8859-1 name byte length: 8
    UTF-8 document byte length: 160
    UTF-8 name string length: 8
    UTF-8 name byte length: 8

  • JAXB Validation without a Schema

    Part of the benefit of JAXB is that a schema is not required; annotating Java classes alone allows for XML serialization/deserialization. With the deprecation of the Unmarshaller.setValidating() in favor of the unmarshaller.setSchema() method, however, it seems that validation is only available when an XSD is present. Is there another way to validate XML during unmarshalling without a physical schema file?

    Unmarshaller#setValidating(boolean) is deprecated as of 2.0 [1].
    This method throws an UnsupportedOperationException in the UnmarshallerImpl class within sun's v2 jaxb implementation.
    [1] https://jaxb.dev.java.net/nonav/jaxb20-pfd/api/javax/xml/bind/Unmarshaller.html#setValidating(boolean)

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

Maybe you are looking for

  • Invoices not flowing to RMCA

    Hello Experts, i had a requirement, where profit center was missing for contract and invoices. I had written a program, now profit center is getting updated succcessfuly but when  in VF02  i am releasing any inovice to RMCA ... i am getting a standar

  • Java.lang.NullPointerException during adding new IDM Form

    Hi, I have problem with Net Beans 6.1. When I try to create new Form (or Rule/Workflow) red sign with following warning is appeared: java.lang.NullPointerException      at javax.swing.plaf.basic.BasicTextUI.uninstallUI(BasicTextUI.java:816)      at o

  • Connect to Sony BRAVIA

    I was using android all these days and was comfotably connecting internet to my SONY BRAVIA LED TV. With this Lumia 925 am unable to do so. Tried all the possibilities but not able to do so. Very disappointed with this. Please help in getting connect

  • Pixel artifacts with 9600XT

    Hi, I just upgraded my FX5200 to a radeon 9600XT. I have two apple Monitors connected. The adc Monitor (15") works fine. The dvi Monitor (20") has pixel artifacts when I drag windows arround. They go away when I reopen it or make a selektion. But the

  • No more CalDAV connection with iOS6

    After having updated to iOS6, I have ongoing trouble with my calendar connections to a CalDAV server. Everything seemed to work proper and there was no error message. I encountered the misfunction only after missing calendar entries on the server mai