Solved

JAVA Beans Error - Not sure what it means

Posted on 2003-12-08
7
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet cookie finding by name 1 96
doubleChar java challenge 7 130
oracle fusion vs MQ 2 135
how to hide hide popup page refresh second time? 10 183
A big percent of today’s marketing activity is performed through the online environment. The marketing strategies that have existed a decade ago no longer relate to what’s happening today. We’re currently facing a revolutionary era, called the digit…
By reading this blog, MSPs will gain insight into how to improve communications with their clients as well as establish a more profitable business.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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