0 Replies Latest reply on Aug 9, 2006 5:19 AM by smix007

    Ejb Session

    smix007

      Hello,
      Beginning in J2EE, I wish to develop my first applicationweb. I use for this JBoss 3.2.3 (for reasons of compatibility with the JDK 4 and it plug-in JBoss-IDE 1.4.0 of eclipse).
      I succeeded in deploying the servlet. I am in stage of creation of Ejb Session.
      I parameterized the file xdoclet-build.xml so that it generates me Remote interfaces and the Room interfaces and also the EJB and thanks to the target (@ejb.interface-method view-type="remote") added in my EjbReferenceBean.java

      and while launching the xdoclet I generate:
      EjbReferenceBeanRemoteHome.java, EjbReferenceBeanHome.java and EjbReferenceBeanBean.java in the repertory \Bureau\template\J2EE tutorial\generated-ejb\com\spim\ejb whereas my servlet and in the repertoire \Bureau\template\J2EE tutorial\src-web\com\spim\servlet

      By adding the methods following in my servlet AccessServlet.java:

      import com.spim.ejb.EjbReferenceBeanRemote;
      import com.spim.ejb.EjbReferenceBeanRemoteHome;

      private void initAccess(){

      System.out.println("Entering Access.initAccess method()");
      try{
      ejbReferenceHome = getHome();
      }catch (Exception e){
      System.out.println("Exception in Access.initAcess method" + e);
      }
      System.out.println("Leaving Access.initAccess method()");
      }

      private EjbReferenceBeanRemoteHome getHome() throws NamingException {

      Object result = getContext().lookup(EjbReferenceBeanRemoteHome.JNDI_NAME);

      return ((EjbReferenceBeanRemoteHome)
      javax.rmi.PortableRemoteObject.narrow(result, EjbReferenceBeanRemoteHome.class ));
      }

      private InitialContext getContext() throws NamingException {

      Hashtable props = new Hashtable ();
      props.put(
      InitialContext.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      props.put(InitialContext.PROVIDER_URL,"jnp://127.0.0.1:1099");
      InitialContext initialContext = new InitialContext (props);
      return initialContext ;
      }
      protected void doPost(
      HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub

      String ref = request.getParameter("reference");
      String choix = request.getParameter("choix");
      try{
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("Vous avez entré les informations suivantes :");
      EjbReferenceBeanRemote erb = ejbReferenceHome.create();
      out.println(erb.enregisterEtat(ref, choix));

      }catch(Exception e){
      System.out.println("Exception in Access.doPost method" + e);
      }

      }


      The compiler does not manage to recognize the two following lines:
      ejbReferenceHome = getHome();

      and

      EjbReferenceBeanRemote erb = ejbReferenceHome.create();


      PS: my EjbReferenceBean.java is in the repertoire: \Bureau\template\J2EE tutorial\src-ejb\com\spim\ejb

      Would somebody have an idea. I thank you in advance