1 2 3 Previous Next 43 Replies Latest reply on Sep 23, 2013 8:07 AM by thiru123

    EJB bean is not working in Multi threading of JBoss 7.1.1 Final

    bijoyjp

      am getting "java.lang.IllegalStateException: No EJB receiver available for handling"  exception in my JBoss 7.1. am using multithreading, in single thread the ejb bean is working. in thread call if am using run() the ejb  is working nad if am using start() means am getting the above exception. The remote object am getting but while calling the methods inside been am getting above exception,

      am pasting the exception code

       

      java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:JMSRa,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@1f12373

          at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)

          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)

          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

          at $Proxy15.ReadTxnFromInputQueueString(Unknown Source)

          at queueInterface.TransactionQueueListener.QueueListener(TransactionQueueListener.java:111)

          at queueInterface.TransactionQueueListener.run(TransactionQueueListener.java:353)

          at GUI.TransactionQueueInterface.<init>(TransactionQueueInterface.java:78)

          at FMSMain.callCreateComponents(FMSMain.java:55)

          at FMSMain.main(FMSMain.java:145)

       

      The remote object i printed and it is : Proxy for remote EJB StatelessEJBLocator{appName='', moduleName='JMSRa', distinctName='', beanName='JMSRA', view='interface Remote.JMSRARemote'}

       

      but remote object.getmethod() is not working

        • 1. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
          wdfink

          Hello Bijoy,

          welcome to the forms.

           

          The use of EJB remote calls in AS7 is a bit different to former releases.

          Could you please provide a bit more information how your client code look like?

          • 2. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
            bijoyjp

            Hi Wolf-Dieter Fink,

             

            Sure, below pasted is the code that am using for getting the remote object.

            JMSRARemote objRemote = null;

            Properties env = null;

            Context initContext = null;

            Object obj = null;

            JMSRAHome home = null;

            env = new Properties();

            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

            env.put(Context.PROVIDER_URL, "remote://localhost:4447");

            env.put("jboss.naming.client.ejb.context", true);

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

            initContext = new InitialContext(env);

            obj = initContext.lookup("JMSRa/JMSRA!Home.JMSRAHome");

            home = (JMSRAHome) PortableRemoteObject.narrow(obj, JMSRAHome.class);

            objRemote = home.create();

             

            after this if I try  objRemote.ReadTxnFromInputQueueString("inputqueue1");

            It’s working. After this method am calling multithreading i.e.

            transactionQueueListener[i].start()

             

            and inside thread am using the same remote object (objRemote) which is declared as public static, whenever am trying to call the method inside the bean by using the remote object i.e.


            objRemote.ReadTxnFromInputQueueString("inputqueue1"); am getting the exception

             


            java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:JMSRa,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@1f12373;

             

            for thread call if am using thread.run(); means everything is working am able to call remote method in the bean and result is getting. since am using multi threading i have to use start() method for calling thread.

             

            am using jboss-as-7.1.1.Final and running in standalonemode

            • 3. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
              olli24

              Hi there.

               

              We are migrating from JBoss5 to JBoss7 and faced the same/similar problem.

               

              Thread-A creates the InitContext and does the JNDI EJB lookup and creates the instance of the EJB remote inferface.

              Thread-A can invoke methods via the EJB remote interface.

               

              Thread-B gets the reference of the EJB remote interface.

              But if Thread-B tries to invoke a method via the EJB remote interface following exception is thrown:

              Exception in thread "xxx" java.lang.IllegalStateException: No EJBReceiver available for node name oliver2

              at org.jboss.ejb.client.EJBClientContext.requireNodeEJBReceiver(EJBClientContext.java:613)

              at org.jboss.ejb.client.EJBClientContext.requireNodeEJBReceiverContext(EJBClientContext.java:648)

              at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:71)

              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)

               

              Of course accessing the remote interface is serialized via synchronized blocks.

               

              I use the same Context properties like Bijoy James

              Under JBoss5 this has been working.

               

              How I can Thread-B allow using the remote interface, which was created from Thread-A?

               

              Thanks in advance for any help.

              • 4. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                wdfink

                I recommend to use the jboss-ejb-client.properties (and not the remoting-project URL remote://... which is deprecated)

                Have a look to https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

                Does this work?

                 

                The reason is that AS7 is a new implementation andtherefor the ejb-client works different, specially in case of multithreading. There is a JIRA with enhancements EJBCLIENT-34 for this, but it is not finished right now.

                Also I'll reproduce your issue and see how to achieve this.

                1 of 1 people found this helpful
                • 5. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                  olli24

                  Thanks for fast answer.

                   

                  I can confirm that the multithreading case works, if the EJB Client properties are set via file jboss-ejb-client.properties, instead of setting them as InitContext properties.

                   

                  My only InitContext property is now:

                  properties = new Properties();

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

                  return new InitialContext(properties);

                   

                  The other properties are now defined in the file jboss-ejb-client.properties:

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

                  remote.connections=default

                  remote.connection.default.host=oliver2

                  remote.connection.default.port=9000

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

                  • 6. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                    bijoyjp

                    Hi,

                     

                    where i need to place "jboss-ejb-client.properties" file in Jboss 7.1.1 Final

                    • 7. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                      olli24

                      You have 3 options:

                       

                      1) Place the "jboss-ejb-client.properties" file in the classpath of the remote client

                       

                      or

                       

                      2) Set the path to the file via System Property as JRE command line parameter

                      -Djboss.ejb.client.properties.file.path=C:\jboss-ejb-client.properties

                       

                      or

                       

                      3) Set the path to the file via System Property during runtime

                      System.setProperty("jboss.ejb.client.properties.file.path", "C:\\jboss-ejb-client.properties");

                      • 8. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                        bijoyjp

                        Hi Oliver,

                         

                        I placed the "jboss-ejb-client.properties" in "jboss-as-7.1.1.Final\bin\" folder

                        But in my code am not able to get the remote object.

                        Am using the below code for getting the remote object.

                        String appName = "";

                        String moduleName = "jboss-as-ejb-remote-app";

                        String distinctName = "";

                        Properties objProperties = new Properties();

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

                        initContext = new InitialContext(objProperties);

                         

                        Object obj = initContext.lookup("ejb:"+ appName + "/"+ moduleName + "/" + distinctName + "/JMSRa/JMSRA!Home.JMSRAHome");

                         

                        JMSRAHome home = (JMSRAHome) PortableRemoteObject.narrow(obj, JMSRAHome.class);

                        JMSRARemote  objRemote = home.create();

                         

                        Am getting exception on last line “home.create(); ”

                        As  java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:jboss-as-ejb-remote-app,distinctname:]

                         

                         

                        How u are getting the remote object for invoking the method inside the bean.

                        • 9. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                          olli24

                          May be something with your lookup name is wrong.

                           

                          Have a look at your JBoss log file after your EJB has been deployed.

                          There you can see the JNDI bindings of your EJB.

                           

                          JBoss7 EJB lookup Name

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

                           

                          This is my lookup name as example:

                          "ejb:/MtzWebComm//CommEJB!de.miditec.communication.ejb.CommEJBHome";

                          appName      : Empty String

                          moduleName : MtzWebComm

                          distinctName : Empty String

                          beanName     : CommEJB

                          viewClassName: de.miditec.communication.ejb.CommEJBHome

                          • 10. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                            bijoyjp

                            Hi Oliver,

                             

                            Is the "jboss-ejb-client.properties" file i placed correctly?  ie "jboss-as-7.1.1.Final\bin\jboss-ejb-client.properties".

                            • 11. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                              olli24

                              In think the bin folder is not part of your client CLASSPATH.

                              So, if you want to put the file into the bin folder, you have to set the path inside your client via

                              System.setProperty("jboss.ejb.client.properties.file.path", "..:\\bin\\jboss-ejb-client.properties");

                              • 12. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                                wdfink

                                You need the jboss-ejb-client.properties in the classpath of your (remote)client application, not at server side.

                                How do you start your client, could you show the command-line?

                                • 13. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                                  bijoyjp

                                  yes i placed the jboss-ejb-client.properties in the classpath of client application. but how to check the Context is using the same properties file?.

                                   

                                  The code that am using in client application side for fetching data from beans is given below

                                   

                                  public void getJMSRARemote(String Url)

                                  {             

                                                  String appName = "";

                                                  String moduleName = "JMSRa";

                                                  String distinctName = "";

                                                  try {

                                                                  Properties objProperties = new Properties();                    

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

                                                                  Context initContext = new InitialContext(objProperties);                                            

                                                                  String beanName = JMSRAHome.class.getSimpleName();

                                                                  String viewClassName = JMSRAHome.class.getName();                                

                                                                  String str = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName;                                              

                                                                  Object obj = initContext.lookup(str);                                     

                                                                  JMSRAHome home = (JMSRAHome) PortableRemoteObject.narrow(obj, JMSRAHome.class);

                                                                  JMSRARemote objRemote = home.create();

                                   

                                                                  if(objRemote!=null)

                                                                                  objRemote.ReadTxnFromInputQueueString("inputqueue1");   

                                                  }

                                                  catch(Exception e) {

                                                                  e.printStackTrace();

                                                                  System.exit(0);

                                                  }   

                                  }

                                   

                                   

                                   

                                  I started jboss by using below command

                                   

                                  D:\jboss-as-7.1.1.Final\bin>standalone.bat

                                   

                                  After that I run the java class file in the client application.

                                   

                                   

                                  am getting the exception on "home.create();" as

                                  java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:JMSRa,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@f63055

                                  • 14. Re: EJB bean is not working in Multi threading of JBoss 7.1.1 Final
                                    wdfink

                                    How do you start the 'java class file'.

                                    You need to have the properties file in the classpath of that application.

                                    1 2 3 Previous Next