473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Unable to load an XML for jaxb-ing

'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
1 2179
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: S Mulgund | last post by:
I have some legacy data that I want to convert to XML. I've designed a schema to represent the data in XML form, and I'm trying to figure out how best to perform the raw->XML conversion. The Java...
4
by: jesper | last post by:
Hi I am currently following the tutorial from IBM (http://www-106.ibm.com/developerworks/xml/edu/x-dw-xjaxb-i.html) I have three problems at the moment. 1. It says else where that when the...
0
by: Mark | last post by:
I'm betting it me. Here is the simple schema I'm using: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"...
1
by: Sony Antony | last post by:
We have a situation wherin we should translate the incoming XML based on one schema to the outgoing XML that is based on another schema. Since both input and output are both XML, XSLT was the...
13
by: Christoph Brunner | last post by:
Hi, on the sun homepage i had submit to the bugparade a request for feature enhancement for the JAXB API. After a period of time sun called me to post my request to a newsgroup an get comments...
0
by: Brett Selleck | last post by:
We have an issue where the JAXB generated classes are creating an interface which references itself. The Schema is valid, and I have not seen this ran into before. The code is below. What is...
0
by: Mark | last post by:
I'm betting it me. Here is the simple schema I'm using: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"...
0
by: ciaran.mchale | last post by:
I used Google to find information about JAXB 2.0 and I ended up downloading a document called "The Java Architecture for XML Binding (JAXB) 2.0: Proposed Final Draft September 30, 2005". ...
0
by: mnsh | last post by:
Hello, I am new to JAXB. So I would like somebody to help me solve this problem. I have a class say Test which contains only a List which has some 6 to 7 user defined objects. I am able to...
0
by: malsh1358 | last post by:
Hi I need check required elements and attributes in JAXB java classes , if there are any value for them place it , otherwise place default value in xml file , because of it I upgrade JAXB2.0 to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.