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

Tomcat 3.1 Bug? You decide ...

0 views
Skip to first unread message

Charles Waltenbaugh

unread,
Aug 1, 2000, 3:00:00 AM8/1/00
to
The following code generates a tomcat internal exception
upon JSP compilation (stack trace included below). As you
can see I import com.mydomain.beans.* (which is where the
GYConnection.class file resides) with a proper page directive.

----- from index.jsp -----------------------------------------
<%@ page info="A database reporting application." %>
<%@ page import="com.mydomain.beans.*" %>

<jsp:useBean id="conn" class="GYConnection" scope="session" />

<html>
<head>
<title>Quality Assurance - Reports</title>
</head>
...
</html>
----- from index.jsp -----------------------------------------


----- Snippet of the generated servlet and the exception: -----
... standard servlet imports ...
...
import com.mydomain.beans.*;

public class _0002findex_0002ejspindex_jsp_13 extends HttpJspBase {
...
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
String _value = null;
try {

if (_jspx_inited == false) {
_jspx_init();
_jspx_inited = true;
}
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=8859_1");
pageContext = _jspxFactory.getPageContext(this, request, response,
"", true, 8192, true);

application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();

// HTML // begin [file="D:\\index.jsp";from=(0,60);to=(1,0)]
out.write("\r\n");
// end
// HTML // begin [file="D:\\index.jsp";from=(1,61);to=(3,0)]
out.write("\r\n\r\n");
// end
// begin [file="D:\\index.jsp";from=(3,0);to=(3,62)]
GYConnection conn = null;
boolean _jspx_specialconn = false;
synchronized (session) {
conn= (GYConnection)
pageContext.getAttribute("conn",PageContext.SESSION_SCOPE);
if ( conn == null ) {
_jspx_specialconn = true;
try {
conn = (GYConnection) Beans.instantiate(getClassLoader(), "GYConnection");
} catch (Exception exc) {
throw new ServletException (" Cannot create bean of class "+"GYConnection");
}
pageContext.setAttribute("conn", conn, PageContext.SESSION_SCOPE);
}
}
if(_jspx_specialconn == true) {
// end

... the rest on _jspService and the servlet class ...

Exception Generated:

javax.servlet.ServletException: Cannot create bean of class GYConnection
at _0002findex_0002ejspindex_jsp_13._jspService (
_0002findex_0002ejspindex_jsp_13.java:81)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:163)
at org.apache.tomcat.servlets.DefaultServlet.doGet(DefaultServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(
HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Unknown Source)
-----------------------------------------

I cannot tell what CLASSPATH is being used, but it seems not to include:
$TOMCAT_HOME/webapps/WEB-INF/classes
as it should. (I finally found a classpath reference in tomcat's jasper compiler log, Jasper.log,
and seems that it is set correctly.)

Here's the catch... I leave the import as-is and change the jsp:useBean tag
from: <jsp:useBean id="conn" class="GYConnection" scope="session" />
to: <jsp:useBean id="conn" class="com.mydomain.beans.GYConnection" scope="session" />

The jsp compiles and executes perfectly. Therefore, I assume CLASSPATH
is set properly since even adding the "com.mydomain.beans. ..." requires the
setting to be right.

So, why do I have to fully qualify the class name in the jsp:useBean tag
when I have a valid import?

TIA
csw


0 new messages