tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shanti Suresh <sha...@umich.edu>
Subject Re: Tomcat 7.0.30 JAR Scanner ClassCastException
Date Fri, 05 Oct 2012 13:15:26 GMT
Hi Jesse,

I have a JSP which will tell which library loads which class.  This has
helped me immensely in troubleshooting a challenging library conflict that
we ran into recently.  Please place this JSP in
apache-tomcat-7.0.23/webapps/ROOT/.  Invoke it as:

http://<hostname>/whichjar.jsp

And keying in the name of a class will tell you which library the class is
being loaded from.  So find out where :
org.apache.tomcat.util.scan.StandardJarScanner and
org.apache.tomcat.JarScanner are being loaded from.

------------------whichjar.jsp:------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
%>
<%
    String className = (String) request.getParameter("className");
    if (className == null)
        className = "";
%>
<html>
<head>
<title>Which jar?</title>
</head>
<body>
<h1>Which Jar?</h1>
<form method="post" action="whichjar2.jsp">
Enter fully qualified class name:<br>
<input type="text" name="className" value="<%=className%>" size="50" />
<input type="submit" />
</form>
<%
    if (className.length() != 0) {
        String givenClass = className;
        if (!className.startsWith("/")) {
            className = "/" + className;
        }
        className = className.replace('.', '/');
        className = className + ".class";

        java.net.URL classUrl = this.getClass().getResource(className);
        if (classUrl != null) {
            String foundIn = classUrl.getFile();
            String filepath;
            if (foundIn.startsWith("file")) {
                filepath = foundIn.substring(6, foundIn.length() - 1
                        - className.length());
            } else {
                filepath = foundIn.substring(1, foundIn.length()
                        - className.length());
            }
            out.println("\nClass '" + givenClass + "' found in \n'"
                    + filepath + "' ");
        } else {
            out.println("\nClass '" + givenClass + "' not found");
        }
    }
%>
</body>
</html>

---------------------------------------------

Thanks.

                       -Shanti
On Wed, Oct 3, 2012 at 9:44 AM, Jesse Farinacci <jieryn@gmail.com> wrote:

> Greetings,
>
> I am using Apache Tomcat 7.0.30 on IBM Java 6. I have a @WebServlet
> inside a ROOT.war!/WEB-INF/lib/common-servlets.jar which forwards to a
> JSP located in common-servlets.jar!/META-INF/resources/some.jsp. When
> I reference the path for this @WebServlet Tomcat throws the following
> exception:
>
> org.apache.jasper.JasperException: Unable to initialize
> TldLocationsCache: org.apache.tomcat.util.scan.StandardJarScanner
> cannot be cast to org.apache.tomcat.JarScanner
>
> org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:252)
>
> org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:205)
>
> org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:607)
>
> org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:409)
>         org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
>         org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
>         org.apache.jasper.compiler.Parser.parse(Parser.java:138)
>
> org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
>
> org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
>         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
>         org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
>         org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
>         org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
>
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
>
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
>
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
>         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>         at
> com.acme.web.MyJspDelegatingServlet.doGet(MyJspDelegatingServlet.java:122)
>
>  org.apache.catalina.core.ApplicationDispatcher.invoke
> Servlet.service() for servlet org.apache.jasper.servlet.JspServlet
> threw exception
>  java.lang.ClassCastException:
> org.apache.tomcat.util.scan.StandardJarScanner incompatible with
> org.apache.tomcat.JarScanner
>         at
> org.apache.jasper.compiler.JarScannerFactory.getJarScanner(JarScannerFactory.java:39)
>         at
> org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:243)
>         at
> org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:205)
>         at
> org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:607)
>         at
> org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:409)
>         at
> org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
>         at
> org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
>         at
> org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
>         at
> org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
>         at
> org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
>         at
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
>         at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
>         at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
>         at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>         at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
>         at
> org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
>         at
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
>         at
> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
>         at
> com.acme.web.MyJspDelegatingServlet.doGet(MyJspDelegatingServlet.java:122)
>
> I thought perhaps I had an old library somewhere, but grep and md5sum
> confirms that my deployed Tomcat 7.0.30 has the same libs that Apache
> is shipping in the official download. I went back to 7.0.29 and see
> the problem there as well. I haven't gone back farther.
>
> Any help on this is appreciated. I make heavy use of modular Servlet
> 3.0 jar files bundled inside the war file, and so there is a lot of
> function missing for my applications..
>
> Thank you,
> -Jesse
>
> --
> There are 10 types of people in this world, those
> that can read binary and those that can not.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message