i am working with JSP and EJBs. i have written a simple code for verifying username and password of user by using session beans. my problem is that i am getting the following exception:
[EXCEPTION]
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.S ervletException : VerifyUser not bound
org.apache.jasp er.runtime.Page ContextImpl.doH andle PageException(P ageContextImpl. java:848)
org.apache.jasp er.runtime.Page ContextImpl.han dlePa geException(Pag eContextImpl.ja va:781)
org.apache.jsp. Verify_jsp._jsp Service(org.apa che.j sp.Verify_jsp:9 8)
org.apache.jasp er.runtime.Http JspBase.service (Http JspBase.java:97 )
javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet .java:810)
org.apache.jasp er.servlet.JspS ervletWrapper.s ervic e(JspServletWra pper.java:322)
org.apache.jasp er.servlet.JspS ervlet.serviceJ spFil e(JspServlet.ja va:314)
org.apache.jasp er.servlet.JspS ervlet.service( JspSe rvlet.java:264)
javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet .java:810)
org.jboss.web.t omcat.filters.R eplyHeaderFilte r.doF ilter(ReplyHead erFilter.java:8 1)
root cause
javax.naming.Na meNotFoundExcep tion: VerifyUser not bound
org.jnp.server. NamingServer.ge tBinding(Naming Serve r.java:491)
org.jnp.server. NamingServer.ge tBinding(Naming Serve r.java:499)
org.jnp.server. NamingServer.ge tObject(NamingS erver .java:505)
org.jnp.server. NamingServer.lo okup(NamingServ er.ja va:278)
org.jnp.interfa ces.NamingConte xt.lookup(Namin gCont ext.java:610)
org.jnp.interfa ces.NamingConte xt.lookup(Namin gCont ext.java:572)
javax.naming.In itialContext.lo okup(InitialCon text. java:347)
org.apache.jsp. Verify_jsp._jsp Service(org.apa che.j sp.Verify_jsp:6 7)
org.apache.jasp er.runtime.Http JspBase.service (Http JspBase.java:97 )
javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet .java:810)
org.apache.jasp er.servlet.JspS ervletWrapper.s ervic e(JspServletWra pper.java:322)
org.apache.jasp er.servlet.JspS ervlet.serviceJ spFil e(JspServlet.ja va:314)
org.apache.jasp er.servlet.JspS ervlet.service( JspSe rvlet.java:264)
javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet .java:810)
org.jboss.web.t omcat.filters.R eplyHeaderFilte r.doF ilter(ReplyHead erFilter.java:8 1)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.9
[/EXCEPTION]
im also presenting code for ur consideration
Expand|Select|Wrap|Line Numbers
- VerifyUser.java
- ------------------------
- package hina.mahmood;
- import javax.ejb.*;
- import java.rmi.*;
- public interface VerifyUser extends javax.ejb.EJBObject
- {
- public Boolean Verify(String user, String pswd) throws RemoteException;
- }// end interface
- ---------------------------------------------------------------------------
- VerifyUserHome.java
- -------------------------------
- package hina.mahmood;
- import javax.ejb.*;
- import java.rmi.*;
- import javax.ejb.EJBHome;
- public interface VerifyUserHome extends javax.ejb.EJBHome
- {
- public VerifyUser create() throws RemoteException,CreateException;
- }// end interface
- --------------------------------------------------------------------------------
- VerifyUserBean.java
- -------------------------------
- package hina.mahmood;
- import javax.ejb.*;
- import java.rmi.*;
- import java.sql.*;
- public class VerifyUserBean implements SessionBean
- {
- private SessionContext ctx;
- public Boolean Verify(String user,String pswd) throws RemoteException
- {
- int flag=0;
- Boolean bool=new Boolean("false");
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- Connection con=DriverManager.getConnection("jdbc:odbc:honie");
- Statement stmt=con.createStatement();
- String query="Select username,password from hina";
- ResultSet rs=stmt.executeQuery(query);
- while(rs.next())
- {
- if((rs.getString("username").equals(user))&&(rs.getString("password").equals(pswd)))
- {
- flag=1;
- break;
- }
- }// end while
- }// end try
- catch(Exception e)
- {System.out.println(e);}
- if(flag==0)
- {
- bool=new Boolean("false");
- return bool;
- }
- else
- if(flag==1)
- {
- bool=new Boolean("true");
- return bool;
- }
- return bool;
- }// end method
- public void ejbcreate() throws RemoteException,CreateException
- {}// end method
- public void setSessionContext(SessionContext ctx)
- {
- this.ctx=ctx;
- }
- public void ejbPassivate()
- {}
- public void ejbActivate()
- {}
- public void ejbRemove()
- {}
- }// end class
- ----------------------------------------------------------------------------
- [note]
- Verify.jsp is the page that uses the session bean
- [/note]
- -------------------------------------
- <%@ page import="java.rmi.*,javax.naming.Context,javax.naming.Initi alContext,hina.mahmood.*"%>
- <%
- String username=request.getParameter("user");
- String password=request.getParameter("pswd");
- InitialContext cxt=new InitialContext();
- Object obj=cxt.lookup("VerifyUser");
- VerifyUserHome userHome=(VerifyUserHome)javax.rmi.PortableRemoteO bject.narrow(obj,VerifyUserHome.class);
- VerifyUser vs=userHome.create();
- Boolean b=vs.Verify(username,password);
- boolean bool=b.booleanValue();
- if(bool)
- response.sendRedirect("main.jsp");
- else
- response.sendRedirect("error.jsp");
- %>
- -------------------------------------------
can anyone plz tel me that what this exception is and how can i get rid of it???
thanks