Solved

JAVA Beans Error - Not sure what it means

Posted on 2003-12-08
7
302 Views
Last Modified: 2010-04-01
I'm new to JAVA Beans and I'm having the following problem. Any ideas what could be wrong? It may be something very

simple that I do not yet know about. :)

Tomcat Server- 4.1.29
Red Hat Linux 9.0
Apache Server- 2.0.48
MySql-  3.23.58
JVM is also installed

I can create a JSP page, query a MySQL database and display it on a web page. But when I try this code:


<jsp:useBean id="user" scope="session" class="User"/>

<jsp:setProperty name="user" property="*"/>

<jsp:useBean id="db" scope="session" class="DB"/>

<jsp:setProperty name="db" property="cString" value="jdbc:mysql://localhost:3306/worctest?user=oc2" />


I receive the error below. I don’t think it's not recognizing the USER class or the DB class, even though they are in the

same directory.



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: 37 in the jsp file: /members.jsp

 

Generated servlet error:

    [javac] Compiling 1 source file

 

/usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/oc2/members_jsp.java:58: cannot resolve symbol symbol  : class

User

location: class org.apache.jsp.members_jsp

      User user = null;

      ^

 

 

 

An error occurred at line: 37 in the jsp file: /members.jsp

 

Generated servlet error:

/usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/oc2/members_jsp.java:60: cannot resolve symbol symbol  : class

User

location: class org.apache.jsp.members_jsp

        user = (User) pageContext.getAttribute("user", PageContext.SESSION_SCOPE);

                ^

 

 

 

An error occurred at line: 37 in the jsp file: /members.jsp

 

Generated servlet error:

/usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/oc2/members_jsp.java:63: cannot resolve symbol symbol  : class

User

location: class org.apache.jsp.members_jsp

            user = (User) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "User");

                    ^

 

 

 

An error occurred at line: 39 in the jsp file: /members.jsp

 

Generated servlet error:

/usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/oc2/members_jsp.java:75: cannot resolve symbol symbol  : class

DB

location: class org.apache.jsp.members_jsp

      DB db = null;

      ^

 

 

 

An error occurred at line: 39 in the jsp file: /members.jsp

 

Generated servlet error:

/usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/oc2/members_jsp.java:77: cannot resolve symbol symbol  : class

DB

location: class org.apache.jsp.members_jsp

        db = (DB) pageContext.getAttribute("db", PageContext.SESSION_SCOPE);

              ^

 

 

 

An error occurred at line: 39 in the jsp file: /members.jsp

 

Generated servlet error:

/usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/oc2/members_jsp.java:80: cannot resolve symbol symbol  : class

DB

location: class org.apache.jsp.members_jsp

            db = (DB) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "DB");

                  ^

6 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.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.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:2417)

      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:171)

      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:193)

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)

      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)

      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)

      at java.lang.Thread.run(Thread.java:534)

 

Apache Tomcat/4.1.29

 

0
Comment
Question by:hschechter
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 9898460
you need pacakge name in the class attribute, e.g.:
<jsp:useBean id="user" scope="session" class="com.mycorp.User"/>

also, here is the general rules to make you bean to work:
1) make "package mypackage" as the first line of MyBean.java
2) make sure MyBean class is public. i.e. "public class MyBean "
3) compile MyBean.java into MyBean.class. put MyBean.class in WEB-INF\classes\mypackage. i.e. "javac -d {path}/WEB-INF/classes MyBean.java"
4) make sure everybody have permission to read the class file and dir path. and make sure directory/file name in exact case, check this in a DOS window.
5) include "<jsp:useBean id="db" class="mypackage.MyBean"/>" in a very simple jsp page.
6) restart the server.
0
 

Author Comment

by:hschechter
ID: 9898604
Hmm... that doesn't seem to be getting it going. I'll try again and post the results.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9899524
is your bean in a package? did you followed the steps that described above? of cause, you need to change the mypackage and MyBean to the real package and bean name.

if you still have problem, let me know your result of each step.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Accepted Solution

by:
anthony_castillon earned 500 total points
ID: 9916525
Did you include the User and DB classes in the import attribute of the page directive?  As in,

<%@ page import="" %>

In your <jsp:useBean>,  you should have the full class name of DB & User in the 'class' attribute, as in,
 <jsp:useBean id="user" class="com.my.package.User">  ....</jsp:useBean>
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10760762
what's the outcome and why a B grade?
0
 

Author Comment

by:hschechter
ID: 10760783
Your solution was on the correct track, but we were ultimately able to find the issue ourselves.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10760805
we would like to understand what was the issue so it will help other as well as us.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now