File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Unable to locate jaxb.properties for package external.xmlParser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unable to locate jaxb.properties for package external.xmlParser" Watch "Unable to locate jaxb.properties for package external.xmlParser" New topic
Author

Unable to locate jaxb.properties for package external.xmlParser

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 193
I am using JAXB to convert from Java Object to XML.

I have put the following values in the classpath
D:\HDFCPSL\WEB\src\external\xmlParser;
D:\HDFCPSL\WEB\src\external\xmlParser\bgm.ser;
D:\HDFCPSL\WEB\src\external\xmlParser\jaxb.properties


The code snippet I am using is




It is giving me an exception on Line 1

The exception is as follows :


11/12/14 13:25:27 javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package external.xmlParser
11/12/14 13:25:27 at javax.xml.bind.JAXBException.<init>(JAXBException.java:47)
11/12/14 13:25:27 at javax.xml.bind.ContextFinder.searchcontextPath(ContextFinder.java:205)
11/12/14 13:25:27 at javax.xml.bind.ContextFinder.find(ContextFinder.java:149)
11/12/14 13:25:27 at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:281)
11/12/14 13:25:27 at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:238)
11/12/14 13:25:27 at external.LoanDetailReaderProcess.generateXML(LoanDetailReaderProcess.java:249)
11/12/14 13:25:27 at external.LoanDetailReaderProcess.run(LoanDetailReaderProcess.java:126)
11/12/14 13:25:27 at java.lang.Thread.run(Thread.java:534)



Does anyone has a clue? How can I fix this...

Hoping a fast response

Thanks for reading.
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 193
Got the soution to my problem...Actually it was required to give the classLoader as the second argument.
Use the overloaded method of newInstance.

Something of this sort




Source of the solution : http://www.jguru.com/forums/view.jsp?EID=1276852
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 193
This solution worked for the above problem.

But in the same file I need to convert another object to XML

But this solution doesn't works there.

Though the jaxb.properties and bgm.ser file are there in the folder that is specified as the first argument of JAXBContext.newInstance

Still it is not working.
Any body has any clue?

I mean, what are the points one needs to take care, while using JAXBContext.newInstance

What I got to know is that


The FAQ on jaxb.properties not found recommends using

this.getClass().getClassLoader()
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 193
Yogesh Gandhi wrote:This solution worked for the above problem.

But in the same file I need to convert another object to XML

But this solution doesn't works there.

Though the jaxb.properties and bgm.ser file are there in the folder that is specified as the first argument of JAXBContext.newInstance

Still it is not working.
Any body has any clue?

I mean, what are the points one needs to take care, while using JAXBContext.newInstance

What I got to know is that


The FAQ on jaxb.properties not found recommends using

this.getClass().getClassLoader()



Huh !!! It was a mistake on my part, but the error message is also mis-leading.

Actually I generated java classes, and added those java files to my project.
And I was trying to run it..

And it was failing on line

JAXBContext context =
JAXBContext.newInstance("external.rtgs.inquiryXml", RtgsUtil.class.getClassLoader());

However, it should have given a NoClassDefFoundError, but no......it says, Unable to locate jaxb.properties

I am glad, i was able to find the root cause.....After compiling all the classes it worked !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to locate jaxb.properties for package external.xmlParser
 
Similar Threads
Publishing Concept using JAXR
Problem while connecting to UDDI registry
MPXJ : Jaxb error reading xml file
JAXB Unmarshalling
my package doesnt contain ObjectFactory.class or jaxb.index