wood burning stoves 2.0*
The moose likes Applets and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Hey Guys,
i've got this issue...
when i run my applet code inside jbuilder (using jdk1.4.2_08), i get it to run correctly, yet when i run it outside using a browser (which is supposingly using the same jdk-i set this in the control panel to use the same jdk), i get , after the applet running much code, a java.lang.NoClassDefFoundError...
eventhough the class is there !!!
i am really confused about this
Thanks guys...
Best,
---Mohammad
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The exception message should tell you which class is not found -- what does it say?


[Jess in Action][AskingGoodQuestions]
Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Ernest,
that is correct, i am getting the following exception i am printing "this" which is the originating class)
this rg.dcm4cheri.imageio.plugins.DcmImageReaderSpi@2af081
java.lang.NoClassDefFoundError
at org.dcm4cheri.imageio.plugins.DcmImageReaderSpi.createReaderInstance(DcmImageReaderSpi.java:126)
at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:296)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:488)
at javax.imageio.ImageIO.read(ImageIO.java:1381)
at javax.imageio.ImageIO.read(ImageIO.java:1348)
at dicomviewer.ImageData.setDataAndCreateImage(ImageData.java:499)
at dicomviewer.ImageData.setDicomData(ImageData.java:122)
at dicomviewer.DicomFile.load(DicomFile.java:287)
at dicomviewer.Viewer.postData(Viewer.java:376)
at dicomviewer.LoaderThread.run(LoaderThread.java:54)

The instruction at which it is crashing is
return new DcmImageReader(this);
knowing that DcmImageReader is an existing class !
Any ideas?
Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

It doesn't have to be DcmImageReader that's missing; it could be a class that DcmImageReader refers to. Classes are loaded lazily, so this may be the first time DcmImageReader is being loaded, and some other class that it uses isn't available. Are there any libraries which you're using in the development environment that aren't present in the applet environment?
Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Actually,
i have everything packaged inside a jar file (i am using my own code, in addtition to some other code ... dcm4che open source library for DICOM images)
and i am using the jar file in the browser
how do i make sure that nothing is missing there?
besides, why would anything be missing if i am compiling all my classes, and they are running first inside jbuilder?
Thanks a lot Ernest...
Best,
---Mohammad
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

When you run it under JBuilder, it very well might use your machine's CLASSPATH, for example -- I don't know for sure. But look at the class in question, look at what libraries it uses, and use "jar tf jarfile.jar" to get a listing of the jar file to check and make sure they're there.
Ebunoluwa Adedoye
Greenhorn

Joined: Sep 23, 2005
Posts: 15
did u try to creat an html file that will be saved in the same folder with the programname.class file.if u have created an html file than check if there is no space between the code.this is an example of a html file.
<html>
<applet code="programname.class"width="300"height="100">
</applet>
</html>
u will save this in the same file with the.class of ur program than save this html file with an html extension than go to the folder u saved the html file and click on it.
Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Ernest, I did check that all classes are in the jar file being used..
and Ebunoluwa, I also tried using the classes instead of the jar file,
both ways led to no progress
MayDay .. MayDay .. HELP !
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

If you're unpacking the jar files that other libraries come in, maybe you're neglecting to include everything in those jar files? This happened in a project I worked on some time ago: we were unjarring many libraries and combining all the class files they contained into one big jar file, but it turned out that one of the jar files included some data in a file in its jar file's META-INF directory that it absolutely needed, and wouldn't load without. Perhaps you're leaving out something important in building that one jar file?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NoClassDefFoundError
 
Similar Threads
NoClassDefFound error in applet
Applet Class loader problem in Websphere 4.0.1AE
Running an applet in appletviewer
"No such method exists" while calling function in applet using IE and JDK1.4.2
error in uploading file