| Author |
Unable to compile class when using jsp:useBean
|
Udaya Bascar
Ranch Hand
Joined: Jun 18, 2002
Posts: 32
|
|
hi i am getting this error when i try to compile this jsp program i am making use of jsp:usebean in this pgm i have enclosed below jsp pgm, java pgm, error report i am using Platform : Windows98 Application Server: Apache Tomcat/4.1.12 Browser : IE 5.0 thanx n advance **************************************************C:\tomcat\webapps\examples\jsp\scope\prop.jsp <jsp:useBean id="Props" class="ScopeTest" scope="application"> <html> <head> <title>Scope Test</title> </head> <body bgcolor="#FFFFFF"> <br> <br> <br> <center> a<b>Usage of UseBean in JSP</b> </center> <br> Counter (scope=application) has a value of <b><jsp:getProperty name="Props" property="nextInt" /></b> </body> </jsp:useBean> </html> **************************************************C:\tomcat\webapps\examples\WEB-INF\classes\scope\ScopeTest.class C:\tomcat\webapps\examples\WEB-INF\classes\scope\ScopeTest.java public class ScopeTest { private int i; public ScopeTest() { i=0; } public int getNextInt() { return i++; } } **************************************************C:\autoexec.bat SET BLASTER=A220 I7 D1 T2 REM - By Windows Setup - SET SNDSCAPE=C:\WINDOWS C:\WINDOWS\COMMAND\DOSKEY SET JAVA_HOME=C:\jdk1.4 SET CATALINA_HOME=C:\tomcat SET SNDSCAPE=C:\WINDOWS SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.4\BIN cls **************************************************HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 0 in the jsp file: /jsp/scope/prop.jsp Generated servlet error: [javac] Compiling 1 source file C:\tomcat\work\Standalone\localhost\examples\jsp\scope\prop_jsp.java:41: cannot resolve symbol symbol : class ScopeTest location: class org.apache.jsp.prop_jsp ScopeTest Props = null; ^ An error occurred at line: 0 in the jsp file: /jsp/scope/prop.jsp Generated servlet error: C:\tomcat\work\Standalone\localhost\examples\jsp\scope\prop_jsp.java:43: cannot resolve symbol symbol : class ScopeTest location: class org.apache.jsp.prop_jsp Props = (ScopeTest) pageContext.getAttribute("Props", PageContext.APPLICATION_SCOPE); ^ An error occurred at line: 0 in the jsp file: /jsp/scope/prop.jsp Generated servlet error: C:\tomcat\work\Standalone\localhost\examples\jsp\scope\prop_jsp.java:46: cannot resolve symbol symbol : class ScopeTest location: class org.apache.jsp.prop_jsp Props = (ScopeTest) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "ScopeTest"); ^ An error occurred at line: 17 in the jsp file: /jsp/scope/prop.jsp Generated servlet error: C:\tomcat\work\Standalone\localhost\examples\jsp\scope\prop_jsp.java:69: cannot resolve symbol symbol : class ScopeTest location: class org.apache.jsp.prop_jsp out.print(JspRuntimeLibrary.toString((((ScopeTest)pageContext.findAttribute("Props")).getNextInt()))); ^ 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:313) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:324) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240) 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:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java: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.java:643) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:471) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java: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.StandardContext.invoke(StandardContext.java:2396) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java: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.java: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:405) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533) at java.lang.Thread.run(Thread.java:536) --------------------------------------------------------------------------------
|
 |
sampy jagan
Ranch Hand
Joined: Sep 17, 2002
Posts: 34
|
|
|
your ScopeTest.class may not be in the class path. it should be in Meta-Inf\Classes folder.
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
your ScopeTest.class may not be in the class path. it should be in Meta-Inf\Classes folder.
Incorrect. Classes should be in proper package hierarchy under WEB-INF/classes (and case counts!) You state that your class resides in
C:\tomcat\webapps\examples\WEB-INF\classes\scope\ScopeTest.java
so that part's ok, but in your useBean you specify
class="ScopeTest"
According to the class location, it should be in package scope, so your declaration should be: Whenever you reference a class by its name, you must be sure to use the fully-qualified name of the class, including its package hierarchy. hth, bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
By the way, I'm assuming that the .class file for
C:\tomcat\webapps\examples\WEB-INF\classes\scope\ScopeTest.java
resides in that same folder? You might want to ponder the wisdom of putting your source files in the classpath. hth, bear
|
 |
 |
|
|
subject: Unable to compile class when using jsp:useBean
|
|
|