#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    2
    Rep Power
    0

    accessing jsp beans, (error: not found)


    I have a jsp page at: /usr/java/jakarta-tomcat-4.1.24/webapps/ROOT/calc.jsp

    jsp:useBean id="theBean" class="gov.usda.calc"/>
    <html>
    <head>
    <title>testing calcbean</title>
    </head>
    <body>
    <%
    int i = 4;
    int j = theBean.doubleIt(i);
    out.print(j);
    %>
    </body>
    </html>

    I have a bean (successfully compiled calc.java for it at:
    /usr/java/jakarta-tomcat-4.1.24/webapps/ROOT/WEB-INF/gov/usda
    /calc.class


    package gov.usda;
    public class calc
    {
    public int doublIt(int number)
    {
    return 2 * number;
    }
    }


    when I try to access my .jsp i get a "package gov.usda does not exist" error.

    The full error is:

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

    An error occurred at line: 0 in the jsp file: /calc.jsp

    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] /usr/java/jakarta-tomcat-4.1.24/work/Standalone/localhost/_/calc_jsp.java:41: package gov.usda does not exist
    [javac] gov.usda.calc theBean = null;
    [javac] ^



    An error occurred at line: 0 in the jsp file: /calc.jsp

    Generated servlet error:
    [javac] /usr/java/jakarta-tomcat-4.1.24/work/Standalone/localhost/_/calc_jsp.java:43: package gov.usda does not exist
    [javac] theBean = (gov.usda.calc) pageContext.getAttribute("theBean", PageContext.PAGE_SCOPE);
    [javac] ^



    An error occurred at line: 0 in the jsp file: /calc.jsp

    Generated servlet error:
    [javac] /usr/java/jakarta-tomcat-4.1.24/work/Standalone/localhost/_/calc_jsp.java:46: package gov.usda does not exist
    [javac] theBean = (gov.usda.calc) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "gov.usda.calc");
    [javac] ^
    [javac] 3 errors



    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.jav a:392)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
    at java.lang.Thread.run(Thread.java:536)


    ---------------------------------------------------
    I've tried restarting tomcat.

    Any ideas? I'm really flowndering here...

    Thanks,

    Scott Peterson
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Classes must be in the WEB-INF/classes folder
    Code:
    /usr/java/jakarta-tomcat-4.1.24/webapps/ROOT/WEB-INF/classes/gov/usda/calc.class
    Try this
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    2
    Rep Power
    0
    That did it!

    Thanks!

IMN logo majestic logo threadwatch logo seochat tools logo