Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting NoClassDefFoundError on class known to be in jar in the classpath

Posted on 2009-05-06
10
Medium Priority
?
791 Views
Last Modified: 2013-11-10
I'm learning Restlet by working with a small example application.  When I run the app, I get java.lang.NoClassDefFoundError: org/restlet/ext/json/JsonRepresentation.  I have org.restlet.ext.json in the subdirectory with my other external jars, including other org.restlet... jars. jar -tf org.restlet.ext.json.jar does in fact have the JsonRepresentation class in it. So, the class is in the jar and the jar is in the manifest Class-Path but the runtime is unable to resolve the class reference.

Any help would be much appreciated.
0
Comment
Question by:bluegreenone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24321370
how are you running it?
and whats your manifest look like?

0
 

Author Comment

by:bluegreenone
ID: 24321955
java -jar WebSrvApp.jar

Manifest:

Main-Class: com.nynjpkg.WebSrvApp
Class-Path: com/nynjpkg/lib
                   com/nynjpkg/lib/org.restlet.jar
                   com/nynjpkg/lib/com.noelios.restlet.jar
                   com/nynjpkg/org.apache.commons.httpclient.jar
                   com/nynjpkg/org.json.jar
                   com/nynjpkg/org.restlet.ext.json.jar
0
 
LVL 92

Expert Comment

by:objects
ID: 24321980
try it with all the jars on one line

0
Cyber Threats to Small Businesses (Part 1)

This past May, Webroot surveyed more than 600 IT decision-makers at medium-sized companies to see how these small businesses perceived new threats facing their organizations.  Read what Webroot CISO, Gary Hayslip, has to say about the survey in part 1 of this 2-part blog series.

 

Author Comment

by:bluegreenone
ID: 24325270
Thanks for the suggestion. Tried it.  Still getting the same error.
0
 
LVL 92

Expert Comment

by:objects
ID: 24332426
where exactly are the jars?

> com/nynjpkg/lib

remove that from the class-path
and make sure it has a couple of blank lines at the end

whats your manifest look like now?

0
 

Author Comment

by:bluegreenone
ID: 24335515
My directory structure is:

Classes
     com
          nynjpkg
               lib

My jar is in Classes.
My classes are in nynjpkg
External jars are in lib
After removing com/nynjpkg/lib per your suggestion, my manifest looks like:

Main-Class: com.nynjpkg.WebSrvApp
Class-Path: com/nynjpkg/lib/org.restlet.jar com/nynjpkg/lib/com.noelios.restlet.jar com/nynjpkg/org.restlet.ext.json_2.0.jar com/nynjpkg/org.apache.commons.httpclient.jar com/nynjpkg/org.json.jar

After making your suggested change, I'm still getting the same error.
0
 

Expert Comment

by:tgexpert
ID: 24345024
Does your classpath has Classes directory in it?
0
 

Author Comment

by:bluegreenone
ID: 24345338
No. Since the error I'm getting involves a class in an external jar, I didn't think about having my own class directory in the path. I'll give it a try.
0
 

Author Comment

by:bluegreenone
ID: 24345364
Nope. Added my own class path to the manifest Class-Path, and still get the same result.
0
 

Accepted Solution

by:
bluegreenone earned 0 total points
ID: 24390554
After checking 100 times that the JsonRepresentation class was in the jar, and the jar was in my classpath, and ruling out things like misspellings, I resorted to compiling the JsonRepresentation class as part of my application package. This works and solved my problem, but I still would like to have determined why it wasn't working the other way.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question