Solved

JAVA Beans Error - Not sure what it means

Posted on 2003-12-08
7
303 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JTable - RowFilter & Columns Header. 3 140
doubleChar java challenge 7 102
runtime exception and error differences 4 72
JavaScript parse form with colon separated values 2 74
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 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

13 Experts available now in Live!

Get 1:1 Help Now