By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

Unable to load an XML for jaxb-ing

P: n/a
'lo!

Trying to use JAXB for my project. I did the following steps:
a. Created xml/xsd/xjb, placed it under "com.foo.blah"
b. xjc'd the xmls into "com.foo.blah.jaxb"
c. Tried to unmarshal:
--
1. JAXBContext jc = JAXBContext.newInstance("com.foo.blah.jaxb");
2. Unmarshaller um = jc.createUnmarshaller();
3. Object xmlData = unmarshaller.unmarshal(com.foo.blah.SomeClass.clas s.getResourceAsStream("abc.xml"));
--

Line 3. throws
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.un marshal(AbstractUnmarshallerImpl.java:173)
....

I presume this means the classloader of SomeClass is unable to locate
the XML file. I have tried placing the xml file in all directories...
\, com\, com\foo, com\foo\blah, com\foo\blah\jaxb, etc., in vain.

Can anyone tell me where I am going wrong?
Is this a locating/loading issues, or JAXB related? Am I using a wrong
class for loading? Shouldn't using a class at the level "com.foo.blah"
suffice in loading "com\foo\blah\abc.xml"?

Thanks in advance.

-Siplin
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Well, specifying the complete path picks up the classes...
Object xmlData = unmarshaller.unmarshal(com.foo.blah.SomeClass.clas s.getResourceAsStream("/com/foo/blah/jaxb/abc.xml"));

-Siplin

si****@hotmail.com (Sipayi) wrote in message news:<38**************************@posting.google. com>...
'lo!

Trying to use JAXB for my project. I did the following steps:
a. Created xml/xsd/xjb, placed it under "com.foo.blah"
b. xjc'd the xmls into "com.foo.blah.jaxb"
c. Tried to unmarshal:
--
1. JAXBContext jc = JAXBContext.newInstance("com.foo.blah.jaxb");
2. Unmarshaller um = jc.createUnmarshaller();
3. Object xmlData = unmarshaller.unmarshal(com.foo.blah.SomeClass.clas s.getResourceAsStream("abc.xml"));
--

Line 3. throws
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.un marshal(AbstractUnmarshallerImpl.java:173)
...

I presume this means the classloader of SomeClass is unable to locate
the XML file. I have tried placing the xml file in all directories...
\, com\, com\foo, com\foo\blah, com\foo\blah\jaxb, etc., in vain.

Can anyone tell me where I am going wrong?
Is this a locating/loading issues, or JAXB related? Am I using a wrong
class for loading? Shouldn't using a class at the level "com.foo.blah"
suffice in loading "com\foo\blah\abc.xml"?

Thanks in advance.

-Siplin

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.