tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 3855] New: - Class.getResource throws ClassCastException
Date Thu, 27 Sep 2001 13:23:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3855>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3855

Class.getResource throws ClassCastException

           Summary: Class.getResource throws ClassCastException
           Product: Tomcat 4
           Version: 4.0 Final
          Platform: PC
        OS/Version: Windows 9x
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: avogt@skillsonline.de


When executing the following line of code in a web application,
	java.net.URL xmlDirURL = this.getClass().getResource("xmlsrc");
a ClassCastException is thrown. "xmlsrc" is the name of a subdirectory in the 
directory where the class is located to which the code belongs: The class file
is 
C:\Programme\apache\tomcat\4.0\webapps\dev\WEB-INF\classes\de\skillsonline\quiz\
Quiz.class
and the 
C:\Programme\apache\tomcat\4.0\webapps\dev\WEB-INF\classes\de\skillsonline\quiz\
xmlsrc
directory exists.

The code works with tomcat 3.2.1 and 3.2.3.
The purpose of the call is to extract the absolute path of the directory by a 
subsequent call to xmlDirURL.getFile(). If you are aware of a different way of 
obtaining this path, please tell me.

Here is the stack trace of the exception:


java.lang.ClassCastException: org.apache.naming.resources.FileDirContext
	at 
org.apache.catalina.loader.WebappClassLoader.findResourceInternal(Unknown 
Source)
	at org.apache.catalina.loader.WebappClassLoader.findResource(Unknown 
Source)
	at org.apache.catalina.loader.WebappClassLoader.getResource(Unknown 
Source)
	at java.lang.Class.getResource(Class.java:1249)
	at de.skillsonline.quiz.Quiz.setUserDir(Quiz.java:1611)
	at de.skillsonline.quiz.Quiz.readXML(Quiz.java:1539)
	at de.skillsonline.quiz.Quiz.setQuizKey(Quiz.java:62)
	at org.apache.jsp.quiz1$jsp._jspService(quiz1$jsp.java:142)
	at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at 
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Unknown Source)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
	at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown 
Source)
	at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
	at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
	at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
	at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
	at org.apache.catalina.core.StandardContext.invoke(Unknown Source)
	at org.apache.catalina.core.StandardHostValve.invoke(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
	at org.apache.catalina.valves.AccessLogValve.invoke(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
	at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
	at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
	at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
	at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
	at org.apache.catalina.connector.http.HttpProcessor.process(Unknown 
Source)
	at org.apache.catalina.connector.http.HttpProcessor.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:484)

Mime
View raw message