1 Reply Latest reply on Oct 18, 2008 4:55 AM by jaikiran pai

    Problem deploy EJB 3 and JSP

    Manuel Umana Newbie

      Hello,

      I'm deploying an application in JBoss 4.0.4. I'm using EJB 3.0 and JSP.
      I can't view the EJB when I deploy the application in JBoss. It throw this exception javax.naming.NameNotFoundException: Hello not bound

      The JSP is in one project and the Java files are in other project, I make a war for the JSP and a ejb-jar for the ejb project.

      I'm using JDeveloper.

      What I doing wrong? What deployment descriptors I need to use to found the EJB?

      This is the code:

      HelloBean.java
      package pruebaejb;

      import javax.ejb.Stateless;

      @Stateless(name="Hello")
      public class HelloBean implements HelloRemote {
      public HelloBean() {
      }
      public String getMessage()
      {
      return "Hello World from EJB3";
      }
      }

      HelloRemote.java
      package pruebaejb;

      import javax.ejb.Remote;

      @Remote
      public interface HelloRemote {
      public String getMessage();
      }

      HelloClient.java
      package pruebaejb;
      import javax.naming.InitialContext;

      public class HelloClient
      {
      public String getMessage()
      {
      try
      {
      InitialContext ctx = new InitialContext();
      HelloRemote remote = (HelloRemote)ctx.lookup("Hello");
      String helloStr = remote.getMessage();
      return helloStr;
      }
      catch (Exception e)
      {
      e.printStackTrace();
      return "Error";
      }
      }
      }

      index.jsp
      <%@ page language="java" import="pruebaejb.* " pageEncoding="ISO-8859-1"%>
      <%
      String path = request.getContextPath();
      String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
      HelloClient client = new HelloClient();
      String helloMessage = client.getMessage();
      %>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



      My JSP 'index.jsp' starting page
      <meta http-equiv="pragma" content="no-cache">
      <meta http-equiv="cache-control" content="no-cache">
      <meta http-equiv="expires" content="0">
      <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
      <meta http-equiv="description" content="This is my page">


      <%= helloMessage %>




      web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      </web-app>

      Thank you