Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

Unable RUN Java Bean in JSP under Tomcat 5.0

Thread view: 
k.chinnareddy@gmail.com - 09 Jan 2008 10:25 GMT
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(JspServlet.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(SecureClassLoader.java:
124)
   
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:
1634)
   
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:
860)
   
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1307)
   
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1189)
    org.apache.jasper.compiler.Generator
$GenerateVisitor.visit(Generator.java:1214)
    org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java: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.java:456)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
   
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:
511)
   
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
295)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.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
Lew - 09 Jan 2008 15:33 GMT
> Hi
> This is my bean source.
[quoted text clipped - 19 lines]
> 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?

Signature

Lew

k.chinnareddy@gmail.com - 10 Jan 2008 06:20 GMT
> k.chinnare...@gmail.com wrote:
> > Hi
[quoted text clipped - 29 lines]
> --
> Lew

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

Thank you very much
chinna
Lew - 10 Jan 2008 14:23 GMT
Lew wrote:
>> How are you doing the compilation and build, via command-line tools?  Ant?

> 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?

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.