5 Replies Latest reply on Jun 28, 2013 5:03 AM by fialka

    Problem with JBoss 7.1 lookup

    fialka

      Hello,

      I used older version of JBoss for EJB educational purposes, so I understand the main principles, but I never really played with configuration. Recently I tried JBoss 7.1 and got stuck with calling my EJBs from java client.

      I'm using Eclipse, created an EAR containing one EJB project with one bean and a client class trying to call it.

       

      I keep getting

      Exception in thread "main" java.lang.IllegalStateException: No EJB receiver available for handling [appName:ofiEJB,modulename:beans,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@34975276

       

      I found this issue being discussed many times here, but it always concerned something more complex, like calling from another machine. What I really want is just call a simple bean from a java client on the same machine. Could you please help me find what is the problem?

       

      My bean:

      package ofi;

       

      import javax.ejb.Local;

      import javax.ejb.Remote;

      import javax.ejb.Stateless;

       

      @Stateless

      @Remote(JokeService.class)

      public class JokeBean implements JokeService {

         

          @Override

          public String getJoke(){

              return "Hello";

          }

      }

       

      Interface:

       

       

        • 1. Re: Problem with JBoss 7.1 lookup
          fialka

          Interface:

           

          package ofi;

           

          public interface JokeService {

             

              String getJoke();

           

          }

           

          Client (copied from a tutorial):

          import java.util.Hashtable;

           

          import javax.naming.Context;

          import javax.naming.InitialContext;

          import javax.naming.NamingException;

           

          import ofi.JokeBean;

          import ofi.JokeService;

           

           

          public class MyClient {

             

          public static void main(String[] args){

                 

                  try {

                   final Hashtable jndiProperties = new Hashtable();

                      jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                    //  jndiProperties.put("jboss.naming.client.ejb.context", true);  // I tried it both with and without this line

                     

                      final Context context = new InitialContext(jndiProperties);

                      // The app name is the application name of the deployed EJBs. This is typically the ear name

                      // without the .ear suffix. However, the application name could be overridden in the application.xml of the

                      // EJB deployment on the server.

                      // Since we haven't deployed the application as a .ear, the app name for us will be an empty string

                      final String appName = "ofiEJB";

                      // This is the module name of the deployed EJBs on the server. This is typically the jar name of the

                      // EJB deployment, without the .jar suffix, but can be overridden via the ejb-jar.xml

                      // In this example, we have deployed the EJBs in a jboss-as-ejb-remote-app.jar, so the module name is

                      // jboss-as-ejb-remote-app

                      final String moduleName = "beans";

                      // AS7 allows each deployment to have an (optional) distinct name. We haven't specified a distinct name for

                      // our EJB deployment, so this is an empty string

                      final String distinctName = "";

                      // The EJB name which by default is the simple class name of the bean implementation class

                      final String beanName = JokeBean.class.getSimpleName();

                      // the remote view fully qualified class name

                      final String viewClassName = JokeService.class.getName();

                      // let's do the lookup

                      System.out.println("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

                     

                          JokeService service = (JokeService) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

                     

                     

                          service.getJoke();

                      } catch (NamingException e) {

                          // TODO Auto-generated catch block

                          e.printStackTrace();

                      }  

              }

          }

           

           

          I have tried to have the client in the same project and also in a separate project. I tried to use jboss-ejb-client.properties

           

          endpoint.name=client-endpoint

          remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

          remote.connections=default

           

          remote.connection.default.host=localhost

          remote.connection.default.port = 4447

          remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

           

          I tried to add dependency to jboss-client.jar. No combination worked so far. Still got the same exception.

           

          If anyone knows how to solve it, I would be very gratefull. I feel a bit silly not being able to get such a basic thing working...

           

          Thank you

           

          Ondrej

          • 2. Re: Problem with JBoss 7.1 lookup
            jaikiran

            Welcome to the forums!

             

            What does the server side logs look like when you deploy the deployment? Especially the log message which shows the JNDI names for your beans. Also, you might want to try WildFly (JBoss AS is renamed to WildFly) latest release http://wildfly.org/download/ instead of AS 7.1.1 since many bug fixes (although not relevant to this specific issue) have been fixed in that newer version.

            • 3. Re: Problem with JBoss 7.1 lookup
              fialka

              The server log does not show any error:

               

              08:31:31,953 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-5) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080

              08:31:32,143 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

              08:31:32,568 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - Stack CXF Server 4.0.2.GA

              08:31:32,811 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on localhost/127.0.0.1:4447

              08:31:32,813 INFO  [org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on /127.0.0.1:9999

              08:31:32,815 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) JBAS015012: Started FileSystemDeploymentService for directory D:\uni\jboss-as-7.1.1.Final\standalone\deployments

              08:31:32,883 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found ofiEJB.ear in deployment directory. To trigger deployment create a file called ofiEJB.ear.dodeploy

              08:31:33,064 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "ofiEJB.ear"

              08:31:33,146 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "beans.jar"

              08:31:33,386 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named JokeBean in deployment unit subdeployment "beans.jar" of deployment "ofiEJB.ear" are as follows:

               

                  java:global/ofiEJB/beans/JokeBean!ofi.JokeService

                  java:app/beans/JokeBean!ofi.JokeService

                  java:module/JokeBean!ofi.JokeService

                  java:jboss/exported/ofiEJB/beans/JokeBean!ofi.JokeService

                  java:global/ofiEJB/beans/JokeBean

                  java:app/beans/JokeBean

                  java:module/JokeBean

               

              08:31:33,790 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990

              08:31:33,791 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 14797ms - Started 186 of 267 services (80 services are passive or on-demand)

              08:31:33,901 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "ofiEJB.ear"

               

               

              It seems to me that the server side is right and it's the client side that is unable to communicate with the server correctly.

              • 4. Re: Problem with JBoss 7.1 lookup
                jaikiran

                Are you sure jboss-ejb-client.properties is available in the client classpath? How did you verify that part?

                • 5. Re: Problem with JBoss 7.1 lookup
                  fialka

                  Thank you very much!

                   

                  I managed to get it working, the problem was really the classpath. I had the file in correct location and moved it by mistake and did not re-check it.