Runtime classpath issue -- NoClassDefFoundError

Hi,

It shames me to post such a common, everyday problem, but I cannot figure this one out.

I have a class in the package service: service.SynchImage. I have a class in another package as well: vigra.matlab.LOTFClient. In LOTFClient, I am importing service.SynchImage and trying to instantiate it.

All my source code compiles successfully.

When I try to run my program, I get a NoClassDefFoundError telling me it cannot find service/SynchImage.

This is how I am trying to use service.SynchImage (from LOTFClient):

package vigra.matlab;

import service.SynchImage;

publicfinalclass LOTFClientimplements Runnable{

privatestaticbyte[] in;

publicvoid run(){

try{

if (imAq ==null){//imAq is not relevant

thrownew Exception("Proxy to LOTFVigra is invalid");

}else{

System.out.println("Connection to LOTFVigra service successful");

in = imAq.acquireImage();

SynchImage si =new SynchImage(in, 640, 480);

}

}catch (Exception e){

System.err.println(e.getMessage());

}

}

}

Again, this DOES compile successfully. Here is how I am running this class:

package vigra.matlab;

publicclass LOTFDriver{

publicstaticvoid main(String[] args){

LOTFClient client =new LOTFClient();

Thread thread =new Thread(client);

thread.start();

}

}

Alrighty. I'm using an Ant build script to compile all this. In my build script, I set the classpath to the appropriate directories, as follows:

<!-- Define the Java classpath -->

<path id="classpath">

<pathelement location="${CATALINA_HOME}/webapps/kdb/WEB-INF/classes" />

<pathelement location="/u/dgresh/Ice-3.1.0/lib/Ice.jar" />

</path>

<!-- Compile the Java code -->

<target name="compile" depends="init">

<javac srcdir="${src}" destdir="${build}">

<classpath refid="classpath" />

</javac>

</target>

When I browse to $CATALINA_HOME/webapps/kdb/WEB-INF/classes I see the "service" package there. When I browse inside the package, I see "SynchImage.class" there. I found a duplicate "service" package that did not contain the SynchImage.class file and deleted it, but I still get the error.

Is there anything else I should be checking for? What on earth am I missing? It must be something incredibly obvious, but what is it?

Oh, here is SynchImage, if it matters:

package service;

import java.awt.image.BufferedImage;

publicclass SynchImage{

privatestaticbyte[] input;

privatestaticint width;

privatestaticint height;

public SynchImage(byte[] input,int width,int height){

this.input = input;

this.width = width;

this.height = height;

ImageProcessor.createAndSaveImage(input, width, height);

}

publicstatic BufferedImage fetchImage(){

return ImageProcessor.createImage(input, width, height);

}

}

Thanks

[5521 byte] By [Djaunla] at [2007-11-27 6:22:21]
# 1
Also, the runtime error is not being thrown at the import statement, because System.out.println("Connection to LOTFVigra service successful");is executing.
Djaunla at 2007-7-12 17:39:14 > top of Java-index,Java Essentials,Java Programming...
# 2

Okay, I'm now very confused.

In $CATALINA_HOME/webapps/kdb/WEB-INF/classes I was building my project to "LOTFVigra/$project", and the service package to "classes".

If I don't build it to LOTFVigra/vigra/matlab/*.class and simply build it to CATALINA_HOME/webapps/kdb/WEB-INF/classes/vigra/matlab/*.class, it will run. Why on earth would this occur?

Djaunla at 2007-7-12 17:39:14 > top of Java-index,Java Essentials,Java Programming...