1 Reply Latest reply on Nov 11, 2001 11:35 AM by Jorge

    [Default] Excepci¾n: javax.naming.CommunicationException [Ro

    Jorge Newbie

      [Default] Excepci¾n: javax.naming.CommunicationException [Root exception is java
      .lang.ClassNotFoundException: InterestHome]


      import java.io.IOException;
      import java.io.PrintWriter;
      import java.util.Hashtable;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.rmi.PortableRemoteObject;
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;


      import Interest;
      import InterestHome;

      public class InterestServlet extends HttpServlet {

      private Interest m_resource = null;
      public void init() {
      try {
      System.setProperty("java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");
      System.setProperty("java.naming.provider.url",
      "localhost:1099");
      Hashtable env = new Hashtable();
      env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(InitialContext.PROVIDER_URL, "localhost:1099");
      env.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming");

      Context jndiContext = new InitialContext(env);

      Object ref = jndiContext.lookup("interest");

      InterestHome home = (InterestHome)
      PortableRemoteObject.narrow (ref, InterestHome.class);

      m_resource = home.create();
      } catch(Exception e) {
      System.out.println("Excepción: " + e );
      }
      }
      public void doGet (HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {

      PrintWriter out;
      String title = "Servlet interface to EJB";

      response.setContentType("text/html");

      out = response.getWriter();

      out.println("");
      out.println(title);
      out.println("<BODY bgcolor=\"#FFFFFF\">");
      out.println("<H1>" + title + "</H1>");
      out.println("<H2>Calling EJB...</H2>");

      try {
      if (m_resource == null) {
      out.println ("Could not connect to Interest bean.");
      } else {

      //out.println (m_resource.testResource( ));
      out.println("OK");
      }
      } catch(Exception e) {
      out.println(e.toString());
      } finally {
      out.println("");
      out.close();
      }
      }
      }

      ///////////////////////////////////////

      <ejb-jar>
      JBoss Interest Sample Application
      <display-name>Interest EJB</display-name>
      <enterprise-beans>

      <ejb-name>Interest</ejb-name>
      InterestHome
      Interest
      <ejb-class>InterestBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

      </enterprise-beans>
      </ejb-jar>

      ////////////////////////////////////////


      <enterprise-beans>

      <ejb-name>Interest</ejb-name>
      <jndi-name>interest</jndi-name>

      </enterprise-beans>


      WHAT IS MY ERROR? SORRY I DON'T KNOW HELP ME PLEASE