• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ant NoClassDefFoundError

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I work on a struts application that runs on Jboss, and I am having a problem that I believe is due to my build.xml. I am a bit of an Ant newbie, so please bear with me.

Basically, I wanted to the jakarta commons-httpClient jar to my application, and for some reason, whenever I create an instance of the class that imports the PostMethod class (which is inside the jar) I get a NoClassDefFoundError. It's my guess that somehow the jar is not making it into the ear.

Attached is my build.xml. It's kind of large (I didn't write it -- I'm just modifying it) but the part that I think pertains to this problem is the <path id="shared.classpath"> tag. As far I can tell, it should be copying everything from the lib directory that matches commons-*.jar, and the jar in question is /lib/commons-httpClient-3.0-rc1.jar

Any ideas why I might be getting this error?

Thanks in advance,


Ben Rainville

Here's the build.xml (I couldn't figure out how to post it in here -- something about illegal HTML tags? If anyone can tell me, I'll post the xml here instead of an external link).
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your hypothesis is that a certain jar isn't in the ear.

So, open it up and see if it is or not(use jar or winzip or your favorite tool).

If it isn't, then is it in the directory that the ear is created from? Looks like it is creating the ear from basedir -> ${dist.dir}/ear. It looks like it is including everything in that directory. Is it?


[ March 29, 2005: Message edited by: Carol Enderlin ]
 
Ben Rainville
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, good idea. Not sure why I didn't think of that myself. I looked in the ear, and the jar I want is in there. So my guess was wrong.

Any ideas what else could be the problem? What else could cause a ClassDefNotFoundError?
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there are different ways to configure and package an ear to get the classpath to work.

What part of your application needs the jar you're having the trouble with? Just the web application? (you mentioned struts so I'm guessing it could be just the web app) You could put the jar in WEB-INF/lib within the war. Looks like your jar is being excluded from the war, included in the ear.

If you need those classes in multiple modules such as a war and ejb...one way is to add jars to the classpath of war and ejb.jar files is to list them in the manifest (META-INF/manifest.mf). Your build file isn't having ant create the manifests, but it does look like it could be including manifest files. You could take a look at one or two of yours from a war/ejb.jar. The manifest may have a line that starts like this "Class-Path: "

WebLogic has a feature where you can put jars into a certain location within the ear and they are available to the entire application without mucking with the manifest. Not being familiar with JBoss, I don't know what tricks it might use.

You can add jars external to the ear to the classpath used to start your server, that can be a bit tricky depending upon what the start scripts are like. I prefer to get it all working in one package (ear).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic