Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java Servlet with Xalan Problem

1 view
Skip to first unread message

Bob Connell

unread,
Jan 29, 2003, 3:54:53 PM1/29/03
to
I have a Java servlet that needs to transform some XML to HTML. I
thought xalan would be a great choice since it is used quite heavily.
I've currently run into a problem that I'm not sure how to solve. My
servlet is setup properly to resolve other exceptions I was getting in
my code.

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

Mike Schilling

unread,
Jan 29, 2003, 9:11:39 PM1/29/03
to

"Bob Connell" <rcon...@mitre.org> wrote in message
news:3E383F9D...@mitre.org...

> I have a Java servlet that needs to transform some XML to HTML. I
> thought xalan would be a great choice since it is used quite heavily.
> I've currently run into a problem that I'm not sure how to solve. My
> servlet is setup properly to resolve other exceptions I was getting in
> my code.
>
> 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)
>

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.


Bob Connell

unread,
Jan 30, 2003, 9:25:00 AM1/30/03
to Mike Schilling
Thanks Mike!

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

0 new messages