My servlet is throwing an exception but not in my code. I'm using the
sample code that xalan has provided, modified just a little bit to
match my XML and XSL files.
My webserver is Tomcat 4.1
The error is:
The server encountered an internal error () that prevented it from
fulfilling this request.
root cause
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:246)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
Here is a code snippet:
public void doGet (HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException, java.net.MalformedURLException
{
// The servlet returns HTML.
response.setContentType("text/html; charset=UTF-8");
// Output goes in the response stream.
PrintWriter out = response.getWriter();
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();
// Get the XML input document and the stylesheet.
Source xmlSource = new StreamSource(new
URL("file:C:\\SensorType.xml").openStream());
Source xslSource = new StreamSource(new
URL("file:C:\\ctype.xsl").openStream());
// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
//**** The line above is where it fails ******
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new StreamResult(new
FileOutputStream("C:\\testIT.out")));
}
Any ideas on what I could be doing wrong?
thanks!
Bob
Some class's base class was non-final at compile time but is final at
run-time. There are apparently different versions of some jar file in the
build and deployment environments, most likely xalan.jar.
I didn't think the problem was with my code (since it came directly from
Apache) ;->
I removed all the extra xalan.jar and xerces.jar files from my system (and I
had quite a few of them).
However this did not fix the problem.
I actually stumbled on the solution by accident. I gave up on this problem and
went to work on my other servlet (which worked before removing old jar files)
and found this was broken with the same error. This got me to reverse the
steps I did previously and realize the solution.
The solution:
I incorrectly placed the xalan jar files in the
C:\Program Files\Apache Group\Tomcat 4.1\webapps\<myfunction>\WEB-INF\lib
When I placed them in the following directory everything worked fine!
C:\Program Files\Apache Group\Tomcat 4.1\common\lib
Bob