tags:

views:

987

answers:

1

I am doing using JAXB to unmarshall some XML into Java objects:

My code looks a little like this:

InputStream testMsg = getClass().getResourceAsStream("TestDocumentEvent.xml");
Unmarshaller unmarshaller = JAXBContext.newInstance(DocumentEvent.class).createUnmarshaller();
DocumentEvent unmarshalled = (DocumentEvent) unmarshaller.unmarshal(testMsg);

However, when I run this code I get an exception:

java.lang.IllegalArgumentException: is parameter must not be null

What's going on?

+3  A: 

This is because the InputStream you are passing to the unmarshaller ('is' parameter, geddit) is null, check that the resource name is correct.

SCdF
I know, I answered my own question. I added this because there isn't much on google about this and the error isn't that readable
SCdF
I don't know, it seems pretty obvious to me - if the unmarshal call is complaining immediately that its argument is null, what's unreadable about that?
Jon Skeet
You are saying that "IS" is short for "InputStream" in the complaint? Yes, that's a little unclear, but at least from context it's easy to figure out.
Eddie
@Jon, if the world was made of Jon Skeets we wouldn't need SO, if your rep is anything to go by. Sadly marginal code jockeys such as myself still need a helping hand once and awhile.
SCdF