0 Replies Latest reply on Mar 17, 2012 6:30 AM by sragvuw

    Accessing EJB methods from an Action Class defined in struts

    sragvuw

      I have two projects defined in Eclipse. One of them is an EJB(3.0) project and the other is a dynamic web project.

      I have defined a stateless session bean named LoginAuthenticator and created two interfaces local and remote for it. In my EJB project I have defined the JNDI.properties file as

       

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java
      .naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java
      .naming.provider.url=localhost:1099

       

      I am able to deploy the jar file on JBoss 5.0.0 I am getting the following output on the console after deploying

       

      LoginAuthenticator/remote - EJB3.x Default Remote Business Interface
      LoginAuthenticator/remote-com.SR.enterprise.session.LoginAuthenticatorRemote - EJB3.x Remote Business Interface
      LoginAuthenticator/local - EJB3.x Default Local Business Interface
      LoginAuthenticator/local-com.SR.enterprise.session.LoginAuthenticatorLocal - EJB3.x Local Business Interface

       

      Now from another web project I have defined an action class LoginAction which will access the exposed methods of my session bean. The initial context is created as

       

      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props
      .put(javax.naming.Context.PROVIDER_URL,"jnp://localhost:1099");
      props
      .put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");

       

      I am calling the remote method as

       

      LoginAuthenticatorRemote loginAuthenticator = (LoginAuthenticatorRemote) context.lookup("LoginAuthenticator/remote");

       

      When i run the second project on Tomcat 6.0, I am getting the following error message

       

      javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.SocketException: Permission denied: connect]]]

       

      The port value in jmx-console under service=Naming is 1099 The RmiPort value in jmx-console under service=Naming is 1098 Both the RmiBindAddress & BindAddress in jmx-console under service=Nameing are 127.0.0.1

      What could be the reason for the error I am getting? What else should I configure for this? Any help would be highly appreciated