• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

JSON XMLSerializer class not found error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any number of things could be wrong. Post the stack trace and the code which threw the exception.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To fix add this to your maven dependencies:


 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic