Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Unable RUN Java Bean in JSP under Tomcat 5.0

Reply
Thread Tools

Unable RUN Java Bean in JSP under Tomcat 5.0

 
 
k.chinnareddy@gmail.com
Guest
Posts: n/a
 
      01-09-2008
Hi
This is my bean source.

public class Counter1 implements java.io.Serializable
{
int count=0;
public Counter1(){}
public int getCount()
{
count++;
return this.count;
}

public void setCount(int count)
{
this.count=count;
}
}

I have stored class file under example web application

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\example
\WEB-INF\classes\MyBean

jsp file placed under example

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\example

<%@ page import="MyBean.*" %>
<html>
<head>
<title>Bean class</title>
</head>
<body>
<jsp:useBean id="hello" class="MyBean.Counter1"/>
<jsp:setProperty name="hello" property="count" value="3" />
<jsp:getProperty name="hello" property="count" />

</body>
</html>

When I am calling my jsp file
http://localhost:8080/example/counter.jsp

error is like this:

javax.servlet.ServletException: MyBean/Counter1 (wrong name: Counter1)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:244)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


root cause

java.lang.NoClassDefFoundError: MyBean/Counter1 (wrong name: Counter1)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java :620)
java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:
124)

org.apache.catalina.loader.WebappClassLoader.findC lassInternal(WebappClassLoader.java:
1634)

org.apache.catalina.loader.WebappClassLoader.findC lass(WebappClassLoader.java:
860)

org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:
1307)

org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:
1189)
org.apache.jasper.compiler.Generator
$GenerateVisitor.visit(Generator.java:1214)
org.apache.jasper.compiler.Node$UseBean.accept(Nod e.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody( Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node .java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.j ava:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
org.apache.jasper.compiler.Generator.generate(Gene rator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(C ompiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:470)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:451)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)

org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:
511)

org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:
295)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:
292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.28 logs.


Please tell me what would be the problem. Your help will be
appreciated
May be I am missing Important step
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      01-09-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi
> This is my bean source.
>
> public class Counter1 implements java.io.Serializable
> {
> int count=0;
> public Counter1(){}
> public int getCount()
> {
> count++;
> return this.count;
> }
>
> public void setCount(int count)
> {
> this.count=count;
> }
> }
>
> I have stored class file under example web application
>
> C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\example
> \WEB-INF\classes\MyBean


Put Counter1 in the MyBean package. Better yet, change that to the 'mybean'
package and put Counter1 there. Your class file will wind up in the
corresponding classpath directory, WEB-INF/classes/mybean/Counter1.class.

How are you doing the compilation and build, via command-line tools? Ant?

--
Lew
 
Reply With Quote
 
 
 
 
k.chinnareddy@gmail.com
Guest
Posts: n/a
 
      01-10-2008
On Jan 9, 8:33 pm, Lew <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > Hi
> > This is my bean source.

>
> > public class Counter1 implements java.io.Serializable
> > {
> > int count=0;
> > public Counter1(){}
> > public int getCount()
> > {
> > count++;
> > return this.count;
> > }

>
> > public void setCount(int count)
> > {
> > this.count=count;
> > }
> > }

>
> > I have stored class file under example web application

>
> > C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\example
> > \WEB-INF\classes\MyBean

>
> Put Counter1 in the MyBean package. Better yet, change that to the 'mybean'
> package and put Counter1 there. Your class file will wind up in the
> corresponding classpath directory, WEB-INF/classes/mybean/Counter1.class.
>
> How are you doing the compilation and build, via command-line tools? Ant?
>
> --
> Lew


I have stored Counter1 in MyBean package. Then it was working very
fine.

Thank you very much
chinna
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      01-10-2008
Lew wrote:
>> How are you doing the compilation and build, via command-line tools? Ant?


(E-Mail Removed) wrote:
> I have stored Counter1 in MyBean package. Then it was working very
> fine.


How are you doing the compilation and build, via command-line tools? Ant?

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run jsp under tomcat in Linux david wolf Java 1 04-13-2006 06:57 PM
useBean in JSP for bean within a bean kumar Java 1 02-13-2004 09:33 PM
[HELP] Bean Newbie: C++ library to Java bean. How? Takeshi Java 0 01-28-2004 11:36 AM
Differnce between Java Bean and Enterprise Java Bean Markku Salminen Java 3 01-21-2004 09:25 AM
jsp/bean/tomcat Max Java 0 07-06-2003 11:32 AM



Advertisments