Question

In my J2EE web project, I have a simple JSP (HomeScreen.jsp) and a servlet class (HomeScreenServlet.java) behind it. This class is calling non-static method (PDFAwt1) from another class (PDFAwt) which in turn calls many other methods from many different classes, as usually happens.

When I try to create an object of the PDFAwt to call PDFAwt1(), I get an exception:

java.lang.ClassNotFoundException: jxl.read.biff.BiffException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
...

Here is a little preview of PDFAwt1()

CreateExcelFile cef = new CreateExcelFile();

ImageConversion.setupPDFToPNG(ReferencePath);
ImageConversion.setupPDFToPNG(NewPath);

File folder = new File(ReferencePath + "/png");
File[] f = folder.listFiles();
File folder1 = new File(NewPath + "/png");
File[] f1 = folder1.listFiles();
...

CreateExcelFile()

import jxl.Workbook;
import jxl.format.Colour;
...
public class CreateExcelFile {
  public CreateExcelFile() {
    try {
      if (!new File("LabelsTemplate.xls").exists()) {
        WritableWorkbook workbook = Workbook.createWorkbook(new File("LabelsTemplate.xls"));
        WritableSheet sheet = workbook.createSheet("Sheet1", 0);
        ... 
    }
  }
}

Not able to find where the problem is exactly.. please help..

Was it helpful?

Solution

Missing jar in your class path, if you are using any IDE, download the respective jar and set it in your build path before running the application. In case you are not using any IDE, add the respective jar's to the lib folder of your web application.

OTHER TIPS

Your code is transitively dependent on some jars and you are missing those on your classpath. Maven is a good tool to avoid such transitive dependencies. If you are not using maven then you need to find the jars that you are using, required what all other jars. As a first step, try to find the jar which contains the follwing class:

jxl.read.biff.BiffException
public class BiffException extends JXLException  

Exception thrown when reading a biff file

This exception has a number of messages that should provide some information about the cause:

excelFileNotFound        
excelFileTooBig         
expectedGlobals         
passwordProtected         
streamNotFound         
unrecognizedBiffVersion
unrecognizedOLEFile  

Print the message to see exact problem.

You can find missing jar here

As the name suggests ClassNotFoundException in Java is a subclass of java.lang.Exception and Comes when Java Virtual Machine tries to load a particular class and doesn't found the requested class in classpath.

Another important point about this Exception is that, It is a checked Exception and you need to provide explicitly Exception handling while using methods which can possibly throw ClassNotFoundException in java either by using try-catch block or by using throws clause.

Oracle docs

public class ClassNotFoundException
 extends ReflectiveOperationException

Thrown when an application tries to load in a class through its string name using:

  • The forName method in class Class.
  • The findSystemClass method in class ClassLoader .
  • The loadClass method in class ClassLoader.

but no definition for the class with the specified name could be found.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top