Ok I will try your suggestion. First a couple of further clues - here is the code I am eventually calling as you guessed:

public CommandService(InputStream xmlStream) throws JAXBException, NoSuchMethodException, ClassNotFoundException { JAXBContext jc = JAXBContext.newInstance ("com.williams1000.command.xjc", Services.class.getClassLoader());
        Unmarshaller u = jc.createUnmarshaller();
        services = (Services) u.unmarshal(xmlStream);
...
    }


1. The code actually works fine in eclipse. So I thought I'd browse to the crimson files, but Eclipse doesn't seem to know about them, ie it must be using some other library. I don't know how this could be unless there is a config parameter that tells jaxme to switch to
 a different library.

2. Even though the code fails at the command line, I didn't include the crimson.jar as a dependency, so it must have found the classes from somewhere else - perhaps from maven (kick off builds with maven much as you would with ant)

So maybe it's an incompatible library thing. I'll post up my dependencies separately

Thanks
AW


On 10 Oct 2005, at 20:31, Jochen Wiedmann wrote:


Ashley Williams wrote:


I've just finished changing over my code from sun jaxb to jaxme and straight away my test suite fails complaining that
my xml file doesn't contain a root element:
org.xml.sax.SAXParseException: Document root element is missing.
    at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)


This error message is the Crimson error code P-067. It indicates, that the XML parser either doesn't see the "<services" part or that there is some non-whitespace character before.

This is *not* a JaxMe error message. In fact, the error is reported, before JaxMe gets to see any SAX events.

From the line numbers, I can see that you are using the method

    unmarshal(InputStream)

My guess is, that the data floating through the input stream is not what you expect it to be.

When in doubt, try to replace

    Object result = unmarshaller.parse(istream);

with the following code:

    String fileName = "/tmp/test.xml"; // c:/temp/test.xml for Windows
    FileOutputStream f = new FileOutputStream(fileName);
    byte[] buffer = new byte[1024];
    for (;;) {
        int res = istream.read(buffer);
        if (res == -1) { break; }
        f.write(buffer, 0, res);
    }
    f.close();
    Object result = unmarshaller.parse(new FileInputStream(fileName));

and inspect the file. If you still believe, there's an error, file a bug report with the contents of test.xml and your schema.


Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to