2 Replies Latest reply on Jul 26, 2002 5:58 AM by Joel Vogt

    How to call an EJB from a JSP!!!

    Pratap Sinha Routray Newbie

      I ahve successfully deployed an ejb( a simple statless ejb In JBOSS3.0.0.Now i want to call it from a jsp file how ???
      when i call the jsp file it asks for the java files present in the package...
      thnx..
      my code is

      <%
      try
      {
      Properties props = new Properties();
      props.put(Context.PROVIDER_URL,"http://localhost:8080");
      InitialContext ctx = new InitialContext(props);
      ejbjar.HelloHome home = (ejbjar.HelloHome) ctx.lookup("ejb/ejbjar.HelloHome");
      ejbjar.Hello hel=home.create();
      String retval=hel.sayHello("Pratap calling EJB via JSP");
      out.println("returned: "+ retval);
      hel.remove();
      }
      catch(java.rmi.RemoteException e)
      {
      out.println("remote Exception occured: "+e);
      }
      catch(javax.naming.NamingException e)
      {
      out.println("naming Exception occured: "+e);
      }
      %>

      so plz help...
      error is..........
      An error occurred between lines: 5 and 25 in the jsp file: /clienthello.jsp Generated servlet error: C:\TEMP\Jetty__8080___hello\clienthello$jsp.java:69: Class ejbjar.HelloHome not found. ejbjar.HelloHome home = (ejbjar.HelloHome) ctx.lookup("ejb/ejbjar.HelloHome"); ^ An error occurred between lines: 5 and 25 in the jsp file: /clienthello.jsp Generated servlet error: C:\TEMP\Jetty__8080___hello\clienthello$jsp.java:69: Class ejbjar.HelloHome not found. ejbjar.HelloHome home = (ejbjar.HelloHome) ctx.lookup("ejb/ejbjar.HelloHome"); ^ An error occurred between lines: 5 and 25 in the jsp file: /clienthello.jsp Generated servlet error: C:\TEMP\Jetty__8080___hello\clienthello$jsp.java:70: Class ejbjar.Hello not found. ejbjar.Hello hel=home.create(); ^ 3 errors Date: Thu, 25 Jul 2002 11:47:53 GMT Server: Jetty/4.0.1 (Windows NT 4.0 x86) Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.3.1_01) Content-Type: text/html Content-Length: 2895
      HTTP ERROR: 500 Unable to compile class for JSP An error occurred between lines: 5 and 25 in the jsp file: /clienthello.jsp Generated servlet error: C:\TEMP\Jetty__8080___hello\clienthello$jsp.java:69: Class ejbjar.HelloHome not found. ejbjar.HelloHome home = (ejbjar.HelloHome) ctx.lookup("ejb/ejbjar.HelloHome"); ^ An error occurred between lines: 5 and 25 in the jsp file: /clienthello.jsp Generated servlet error: C:\TEMP\Jetty__8080___hello\clienthello$jsp.java:69: Class ejbjar.HelloHome not found. ejbjar.HelloHome home = (ejbjar.HelloHome) ctx.lookup("ejb/ejbjar.HelloHome"); ^ An error occurred between lines: 5 and 25 in the jsp file: /clienthello.jsp Generated servlet error: C:\TEMP\Jetty__8080___hello\clienthello$jsp.java:70: Class ejbjar.Hello not found. ejbjar.Hello hel=home.create(); ^ 3 errors
      RequestURI=/hello/clienthello.jsp
      thnx in advnc
      pratap