You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sven Hoffmann <sv...@freenet.de> on 2002/09/23 10:27:48 UTC

Can't find Java class while compiling a JSP

Hi,
I tried to run a simple JSP example and get an error while accessing a JSP.
Under the webapps directory of my Tomcat 4.1.10 installation I created a directory named "Tracking". Under that directory I have a driectory named "jsp". Under that directory I have another directy named "tracking" in which I stored two JSP files "logInForm.jsp" and "test.jsp". The "logInForm.jsp" is a simple formular in which the user can enter a user-name, a password and other parameter needed for an login in my backend system. When the user submits this form the request is directed to the URL http://localhost:8080/Tracking/jsp/tracking/test.jsp At this point Tomcat tries to compile the "test.jsp" into a servlet. The "test.jsp" should create a new instance of a Java class named "tracking.testBean" in which all the login data the user has entered in the formular will be stored. The "test.jsp" is quite easy:
    <%@ page errorPage="ErrorPage.jsp" %>
    <%@ page import = "tracking.TestBean" %>

    <jsp:useBean id="testBean" class="tracking.TestBean" scope="session">
    </jsp:useBean>
    <jsp:setProperty name="testBean" property="*" />

    <%
     java.io.FileWriter file=new java.io.FileWriter("g:\\tracking\\output.log", true);
   
     //DEBUG
       file.write("test.jsp:TestBean:\n");
       file.write("\t sessionID: "+ session.getId() +"\n");
       file.write("\t user: "+testBean.getUser()+"\n");
       file.write("\t password: "+testBean.getPassword()+"\n");
       file.write("\t server: "+testBean.getServer()+"\n");
      file.close();
    //DEBUG ENDE
  %>

 
While compiling the "test.jsp" the following error occured:

    org.apache.jasper.JasperException: Unable to compile class for JSP

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
        [javac] Compiling 1 source file
    F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:7: cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
    import tracking.TestBean;
                    ^
    F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:44: cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
          tracking.TestBean testBean = null;
                  ^

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
    F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:46: cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
            testBean = (tracking.TestBean) pageContext.getAttribute("testBean", PageContext.SESSION_SCOPE);
                                ^

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
    F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:49: cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
                testBean = (tracking.TestBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "tracking.TestBean");
                                    ^
    4 errors

    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:120)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:182)


I've no idea why Tomcat is'nt able to find the Java class "tracking.TestBean". I've stored the file "TestBean.class" in the directory "...webapps\Tracking\Web-Inf\classes\tracking".

Thank you for your hints!

Bye
Sven Hoffmann.


Re: Can't find Java class while compiling a JSP

Posted by Remy Maucherat <re...@apache.org>.
Sven Hoffmann wrote:
> Hi,
> I tried to run a simple JSP example and get an error while accessing a JSP.
> Under the webapps directory of my Tomcat 4.1.10 installation I created a directory named "Tracking". Under that directory I have a driectory named "jsp". Under that directory I have another directy named "tracking" in which I stored two JSP files "logInForm.jsp" and "test.jsp". The "logInForm.jsp" is a simple formular in which the user can enter a user-name, a password and other parameter needed for an login in my backend system. When the user submits this form the request is directed to the URL http://localhost:8080/Tracking/jsp/tracking/test.jsp At this point Tomcat tries to compile the "test.jsp" into a servlet. The "test.jsp" should create a new instance of a Java class named "tracking.testBean" in which all the login data the user has entered in the formular will be stored. The "test.jsp" is quite easy:
>     <%@ page errorPage="ErrorPage.jsp" %>
>     <%@ page import = "tracking.TestBean" %>
> 
>     <jsp:useBean id="testBean" class="tracking.TestBean" scope="session">
>     </jsp:useBean>
>     <jsp:setProperty name="testBean" property="*" />
> 
>     <%
>      java.io.FileWriter file=new java.io.FileWriter("g:\\tracking\\output.log", true);
>    
>      //DEBUG
>        file.write("test.jsp:TestBean:\n");
>        file.write("\t sessionID: "+ session.getId() +"\n");
>        file.write("\t user: "+testBean.getUser()+"\n");
>        file.write("\t password: "+testBean.getPassword()+"\n");
>        file.write("\t server: "+testBean.getServer()+"\n");
>       file.close();
>     //DEBUG ENDE
>   %>
> 
>  
> While compiling the "test.jsp" the following error occured:
> 
>     org.apache.jasper.JasperException: Unable to compile class for JSP
> 
>     An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp
> 
>     Generated servlet error:
>         [javac] Compiling 1 source file
>     F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:7: cannot resolve symbol
>     symbol  : class TestBean  
>     location: package tracking
>     import tracking.TestBean;
>                     ^
>     F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:44: cannot resolve symbol
>     symbol  : class TestBean  
>     location: package tracking
>           tracking.TestBean testBean = null;
>                   ^
> 
>     An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp
> 
>     Generated servlet error:
>     F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:46: cannot resolve symbol
>     symbol  : class TestBean  
>     location: package tracking
>             testBean = (tracking.TestBean) pageContext.getAttribute("testBean", PageContext.SESSION_SCOPE);
>                                 ^
> 
>     An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp
> 
>     Generated servlet error:
>     F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:49: cannot resolve symbol
>     symbol  : class TestBean  
>     location: package tracking
>                 testBean = (tracking.TestBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "tracking.TestBean");
>                                     ^
>     4 errors
> 
>     at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:120)
>     at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
>     at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
>     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
>     at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
>     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:182)
> 
> 
> I've no idea why Tomcat is'nt able to find the Java class "tracking.TestBean". I've stored the file "TestBean.class" in the directory "...webapps\Tracking\Web-Inf\classes\tracking".

Either install Tomcat on the C: drive, or upgrade to Tomcat 4.1.11.

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Can't find Java class while compiling a JSP

Posted by Miguel Angel Mulero Martinez <mi...@mad.tecsidel.es>.
This is a bug of Tomcat 4.1.10 when not installed on drive C. You can
upgrade to 4.1.11, install it on drive C, or patch de 4.1.10 version.



-----Mensaje original-----
De: Sven Hoffmann [mailto:sv.hoffmann@freenet.de]
Enviado el: lunes, 23 de septiembre de 2002 10:28
Para: Tomcat Users List
Asunto: Can't find Java class while compiling a JSP

Hi,
I tried to run a simple JSP example and get an error while accessing a
JSP.
Under the webapps directory of my Tomcat 4.1.10 installation I created a
directory named "Tracking". Under that directory I have a driectory
named "jsp". Under that directory I have another directy named
"tracking" in which I stored two JSP files "logInForm.jsp" and
"test.jsp". The "logInForm.jsp" is a simple formular in which the user
can enter a user-name, a password and other parameter needed for an
login in my backend system. When the user submits this form the request
is directed to the URL
http://localhost:8080/Tracking/jsp/tracking/test.jsp At this point
Tomcat tries to compile the "test.jsp" into a servlet. The "test.jsp"
should create a new instance of a Java class named "tracking.testBean"
in which all the login data the user has entered in the formular will be
stored. The "test.jsp" is quite easy:
    <%@ page errorPage="ErrorPage.jsp" %>
    <%@ page import = "tracking.TestBean" %>

    <jsp:useBean id="testBean" class="tracking.TestBean"
scope="session">
    </jsp:useBean>
    <jsp:setProperty name="testBean" property="*" />

    <%
     java.io.FileWriter file=new
java.io.FileWriter("g:\\tracking\\output.log", true);

     //DEBUG
       file.write("test.jsp:TestBean:\n");
       file.write("\t sessionID: "+ session.getId() +"\n");
       file.write("\t user: "+testBean.getUser()+"\n");
       file.write("\t password: "+testBean.getPassword()+"\n");
       file.write("\t server: "+testBean.getServer()+"\n");
      file.close();
    //DEBUG ENDE
  %>


While compiling the "test.jsp" the following error occured:

    org.apache.jasper.JasperException: Unable to compile class for JSP

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
        [javac] Compiling 1 source file

F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp
\tracking\test_jsp.java:7: cannot resolve symbol
    symbol  : class TestBean
    location: package tracking
    import tracking.TestBean;
                    ^

F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp
\tracking\test_jsp.java:44: cannot resolve symbol
    symbol  : class TestBean
    location: package tracking
          tracking.TestBean testBean = null;
                  ^

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:

F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp
\tracking\test_jsp.java:46: cannot resolve symbol
    symbol  : class TestBean
    location: package tracking
            testBean = (tracking.TestBean)
pageContext.getAttribute("testBean", PageContext.SESSION_SCOPE);
                                ^

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:

F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp
\tracking\test_jsp.java:49: cannot resolve symbol
    symbol  : class TestBean
    location: package tracking
                testBean = (tracking.TestBean)
java.beans.Beans.instantiate(this.getClass().getClassLoader(),
"tracking.TestBean");
                                    ^
    4 errors

    at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHa
ndler.java:120)
    at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.ja
va:293)
    at
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
    at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.ja
va:474)
    at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
va:182)


I've no idea why Tomcat is'nt able to find the Java class
"tracking.TestBean". I've stored the file "TestBean.class" in the
directory "...webapps\Tracking\Web-Inf\classes\tracking".

Thank you for your hints!

Bye
Sven Hoffmann.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>