?
Solved

JAVA Beans Error - Not sure what it means

Posted on 2003-12-08
7
Medium Priority
?
309 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Accepted Solution

by:
anthony_castillon earned 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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