File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSON XMLSerializer class not found error

 
Supraja Jayakumar
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I was trying out JSON and included json.lib in my classpath.
I was trying out an example to convert xml to JSON.

But i keep getting classnotfound error with xmlserializer though
the class is there in the json lib.

It tries to find some other xmlserializer elsewhere. I deleted that file totally but
still it complains.

What is this problem. Its kind of weird.

Thanks
Supraja J
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any number of things could be wrong. Post the stack trace and the code which threw the exception.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also - are you trying to compile with an IDE or directly from the command line?

Bill
 
Supraja Jayakumar
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Any number of things could be wrong. Post the stack trace and the code which threw the exception.


OK. Here it is.

Exception in thread "main" java.lang.NoClassDefFoundError: nu/xom/Serializer
at jsontoxml.ConvertXMLToJSON.main(ConvertXMLToJSON.java:20)
Caused by: java.lang.ClassNotFoundException: nu.xom.Serializer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

Thanks for your help.
 
Supraja Jayakumar
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:Also - are you trying to compile with an IDE or directly from the command line?

Bill


No. I am using eclipse. I put the json lib in the classpath. Then put the sample xml file in the class path too since
I did:


But this led to a null pointer exception since the IOUtils.toString(is) dint work out. IOUtils belongs to org.apache

Then I read it as a normal file using BufferedReader. The file was read but I got classnotfound exception later.
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's this "json.lib" thing? Is it a jar file? If so, did you examine it to see if that XOM class was in it? (I would expect XOM to be a dependency, instead of being combined with JSON, but then the documentation should have said that.)
 
Supraja Jayakumar
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:What's this "json.lib" thing? Is it a jar file? If so, did you examine it to see if that XOM class was in it? (I would expect XOM to be a dependency, instead of being combined with JSON, but then the documentation should have said that.)


Hi Paul

Yes. JSON is a jar that helps converting xml files into json (A slightly light weight and more readable format)json
And no, XOM does'nt seem to be part of that. There was a dependency file given.
I think it maybe that the file is not being identified or something.

So in that case, let me tell you what I did. I created a new File (add->new->file) in eclipse and copied the dependency to this and put it in the class path.
It was something like this:


I have'nt added a dependency before so I did right click on Project in eclipse->import->import archive file.
Is this how it is done. Probably this is the problem.

Thanks
Supraja J
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I know what JSON is. And yes, I know what XOM is. However your question appears to be how to configure Eclipse so that your classpath is correct. In other words it doesn't have much to do with Java programming. So let me move the question to the IDEs forum.
 
Joonas Reynders
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To fix add this to your maven dependencies:


 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you created your project in Eclipse, did you create it as a Maven project? If you did, then the m2eclipse plugin should keep the Eclipse list of JARs in sync with the dependencies (you might have to right-click the project and choose Maven | Update Project or Update Dependencies). If you did not create a Maven project, then you will have to manually add those JARs to your Java Build Path for your project.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic