Solved

JAVA Beans Error - Not sure what it means

Posted on 2003-12-08
7
304 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
Adding Computers to AD groups through an SCCM Task Sequence
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

822 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