• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applets and Parsers, Oh My!

 
Rich Wask
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applet and SAX Greenhorn
I getting an error message:
"Exception occurred during event dispatching:"
"java.lang.NoClassDefFoundError: org/xml/sax/SAXException"
I am running an applet that instanciates a class that utilizes a SAX parser (Xerces). Normally, this looks like I do not have my "classpath" set, but I have set my class path to the xerces.jar file and tried to move the xerces.jar file to where I am running the applet, with out any different results.
I created an application that instanciates the above class that uses SAX and everything work great. It is just when I try to instanciate the class that uses SAX in an applet, I get the above error message.
Is there something I am missing with applets?
Do I need to move the xerces's JAR files to a different location for applets?
Below is the applet code:
//
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.xerces.parsers.SAXParser;
import java.io.*;
import SAXPCTestApp;
public class WholeTest2 extends JApplet implements ActionListener {
// graphical components defined
private JLabel parentfileLabel;
private TextField parentfileField;
private String parentfileOut;
// setup of graphical interface components.
public void init()
{
// components can be attached to.
Container c = getContentPane();
// each GUI component on the Pane.
c.setLayout( new FlowLayout() );
// Parent file
parentfileLabel = new JLabel("Enter Parent file name:");
c.add(parentfileLabel);
parentfileField = new TextField(30);
c.add(parentfileField);
// Button
Button ButtonField = new Button("Process Data");
ButtonField.addActionListener(this);
c.add(ButtonField);
//xxx();
}
// Action event to perform when Enter key is pressed.
public void actionPerformed( ActionEvent a)
{
try {
xxx();
}
catch (Exception e)
{
System.out.println("Error reading URI: " + e.getMessage());
}
//System.exit(0);
}
public static void xxx() throws Exception, IOException, SAXException {
try{
System.out.println("In xxx method");
// THE NEXT LINE IS WHERE I GET THE ERROR MESSAGE
SAXPCTestApp qqq = new SAXPCTestApp();
System.out.println("In xxx method, after instanciation");
String pOut = "O1.xml";
// IF I COMMENT OUT THE ABOVE ERROR LINE, I WOULD GET THE ERROR HERE
SAXPCTestApp.SAXPCTestAppA(pOut);
}
catch (Exception e)
{
System.out.println("Error reading URI: " + e.getMessage());
}
System.out.println("Leaving xxx method");
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic