users@jaxb.java.net

Java SDK 1.3 Compatability

From: Geoff Bawn <geoff.bawn_at_PPA.NHS.UK>
Date: Wed, 18 Jun 2003 08:14:08 -0600

I am using JAXB 1.0.1 within Websphere Application Developer version 5 which only supports Java 1.3.1

To isolate the error I am getting I changed the create-marshal example to marshal to an XML Serialized output stream so that I could specify the indentation value (in addition to other properties of the OutputFormat). The added code is as follows:

FileOutputStream fos = new FileOutputStream("c:/data/geoff3.xml");
// Set the formatting options for the XML File
OutputFormat of = new OutputFormat();
of.setIndenting(true);
of.setIndent(8);
// Create an XML Serialized object with the correct formatting
XMLSerializer xmlSer = new XMLSerializer(fos, of);
// Marshal the xml file
m.marshal(po, xmlSer);

I get the following error when I compile and run under Java 1.3.1

Exception in thread "main" java.lang.NoSuchMethodError: java.lang.StringBuffer:
method append(Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer; not found
        at org.apache.xml.serialize.IndentPrinter.printSpace(IndentPrinter.java:
251)
        at org.apache.xml.serialize.XMLSerializer.startElement(XMLSerializer.jav
a:338)
        at po.primer.impl.runtime.SAXMarshaller.endAttributes(SAXMarshaller.java
:169)
        at po.primer.impl.PurchaseOrderImpl.serializeElementBody(PurchaseOrderIm
pl.java:42)
        at po.primer.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:161)
        at po.primer.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:83)

        at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshal
lerImpl.java:80)
        at Main.main(Main.java:146)

The problem is that the append method of StringBuffer with an argument of Stringbuffer only exists in Java 1.4 and not Java 1.3

If I compile and run under Java 1.4, everything is OK.

I am assuming that the XercesImpl jar file supplied with JAXB-1.0.1 is causing this error.

Can anybody confirm this? Is there a work around?

Thanks