• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting InstantiationException

Lakshmi Geetha
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have written a simple bean and am trying to use it in a jsp page.
i am getting the following exception.
please help in finding out the problem.
500 Servlet Exception
java.lang.InstantiationException: `allbeans.MyBean' has no public zero-arg
at _test._myjsp__jsp._jspService(/test/MyJSP.jsp:14)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:179)
at com.caucho.server.http.Invocation.service(Invocation.java:288)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)
at com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:937)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)

Resin 2.0.5 (built Fri Jan 11 08:29:05 PST 2002)

In my jsp page
<jsp:useBean id="myBean" class="allbeans.MyBean" scope="request" />
my bean class
package allbeans;
import java.io.*;
public class MyBean implements Serializable
public MyBean()
_name = "geetha";
public String getName()
return _name;
public void setName(String name)
_name = name;
private String _name;

Tim Holloway
Posts: 18411
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well obviously it DOES have a zero-argument public constructor.
1. Does the source filename EXACTLY (including upper/lower case) match the class name? This SHOULDN'T cause that exception (there's a different exception reserved for that, but maybe it didn't catch it).
2. Have you placed the class in WEB-INF/classes/allbeans/MyBean.class?
3. If so, recompile, move the class file to that location, and restart the server.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!