13 Replies Latest reply on May 30, 2013 11:00 AM by ybarcelo

    Remote EJB invocation from JBoss module

    v.blahoz

      Hi everyone,

       

      we are using JBoss-as-7.1.1.Final and in our project we decided to gather common classes for all client applications in custom JBoss module. I am talking particularly about custom login module, which all deployed clients can be unsing. The login module authenticates via invocation of remote EJB deployed on another remote JBoss and here comes trouble. I am unable to invoke remote EJB from JBoss module, because it apparently ignores jboss-ejb-client.xml/properties as it is not deployed application, therefore invocation fails on

       

      java.lang.IllegalStateException: No EJB receiver available for handling [...] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@76bc603d

       

      So the question is - is there any chance to invoke remote EJB deployed on another JBoss on remote server from internal module (EJB context selector cannot be set programatically, because it's locked for modules), or is the only way to achieve this behavior to deploy login module as EAR.

       

      Thanks in advance

        • 1. Re: Remote EJB invocation from JBoss module
          alanshields

          Sorry what do you mean by "EJB context selector cannot be set programatically, because it's locked for modules"?

           

          Cheers

          Alan

          • 2. Re: Remote EJB invocation from JBoss module
            wdfink

            Maybe the scoped context introduced in AS7.2 will be an option for you.

            But I don't understand your environment. Do you use a CustomLoginModul which uses remote EJB's to verify the credentials instead of LDAP/DB/...?

            • 3. Re: Remote EJB invocation from JBoss module
              v.blahoz

              alan shields wrote:

               

              Sorry what do you mean by "EJB context selector cannot be set programatically, because it's locked for modules"?

               

              Cheers

              Alan

               

              Well, since JBoss module doesn't read jboss-ejb-client.properties automatically, my first attempt was to set the properties programatically (see https://community.jboss.org/thread/200914), but this results in an error saying "EJB client context selector may not be changed"

               

              Wolf-Dieter Fink wrote:

               

              Maybe the scoped context introduced in AS7.2 will be an option for you.

              But I don't understand your environment. Do you use a CustomLoginModul which uses remote EJB's to verify the credentials instead of LDAP/DB/...?

               

               

              That is correct, I use custom class extending UsernamePasswordLoginModule, which uses combination of LDAP/DB to verify credentials and do other stuff, and that is where I need remote EJB invocation.

               

              I'll have a look at the link you've posted, unfortunatelly upgrading to JBoss 7.2 is not an option at the moment.

               

              Thank you for your answers.

              • 4. Re: Remote EJB invocation from JBoss module
                jaikiran

                Assuming the jboss-ejb-client.xml (note that if the client is a server in itself, then you need the xml not the properties file) is in the META-INF folder of your JBoss Module, then when you are adding a dependency on that module in your top level deployment, what happens if you expose the META-INF folder of the dependency in jboss-deployment-structure.xml:

                 

                <dependencies>
                    <module name="my.foo.bar.module" meta-inf="export"/>
                ....
                
                • 5. Re: Remote EJB invocation from JBoss module
                  v.blahoz

                  jaikiran pai wrote:

                   

                  ... note that if the client is a server in itself, then you need the xml not the properties file...

                  I did think about which jboss-ejb-client file to use, so I tried both possibilities. Thanks for explaining why in this case the xml is needed.

                   

                  Unfortunately meta-inf exporting didn't cause any obvious alteration.

                  • 6. Re: Remote EJB invocation from JBoss module
                    v.blahoz

                    Since noone has come with any more suggestions, I assume that using JBoss 7.1.1 I can't change EJB receiver for EJB invocations in JBoss modules, thus we decided to remove our login module from modules folder and pack it with application war (in the futura with all applications) as library.

                     

                    Thanks for all answers.

                     

                    Cheers

                    1 of 1 people found this helpful
                    • 7. Re: Remote EJB invocation from JBoss module
                      ybarcelo

                      Hi Vladimir,

                      i'm having the same situation like you.

                      I have a custom login module and i need to invoke ejb for execute some methods.

                      Could you show me the steps to pack the module into application war and how call it in the security domain config?

                      Regards.

                      • 8. Re: Remote EJB invocation from JBoss module
                        v.blahoz

                        Yassir,

                        will do my best.

                        First of all, if you need the login module only for this specificit application, you can include it directly among other classes in your war. If you want it reuseable (actually in case it was in the war which is deployed among another applications, the other applications should be able to use the same security domain, but they would be dependant on the war containing login module being deployed) you just need to make the login module classes visible to JBoss. So you put them in some jar and either deploy it within an ear or make it accessible to your applications as a library (deploy into maven repository, local maven install...) and include this library in any of your applications, that needs it (in fact the application doen't really need that module, Jboss does, but through that application Jboss can access it).

                        Then you can simply specify your security domain like this

                         

                        <security-domain name="myCustomAuth" cache-type="default">

                          <authentication>

                            <login-module code="fully.qualified.name.of.MyLoginModule" flag="required" />

                          </authentication>

                        </security-domain>

                               

                         

                        That's about it. I certainly hope I didn't write any nonsense here and if so, someone would correct me.

                         

                        Cheers

                        • 9. Re: Remote EJB invocation from JBoss module
                          ybarcelo

                          Dear Vladimir,

                          Thank you SO MUCH!!!.

                          it make sense, i understand.

                          i will try.

                           

                          My best regards.

                          • 10. Re: Remote EJB invocation from JBoss module
                            ybarcelo

                            Hi Vladimir,

                            i had read  this: http://docs.jboss.org/jbosssecurity/docs/6.0/security_guide/html/Dynamic_Security_Domains.html

                            for to do your suggestion. but i don't have find any documentación for JBoss 7.1, 

                            do you have it?

                             

                            Regards.

                            • 11. Re: Remote EJB invocation from JBoss module
                              ybarcelo

                              Hi Vladimir, i'm getting this error in jboss console when i deploy the war:  ... realmjboss.security-domain.svcDomainSecurity Missing...

                              Error.png

                              This are my files

                               

                              My eclipse project structureMy web-xmlMy login-config.xmlMy jboss-web.xml
                              projectEstructure.pngweb.pnglogin-config.pngjboss-web.png
                              • 12. Re: Remote EJB invocation from JBoss module
                                v.blahoz

                                Yassir,

                                as for the documentation, the only I was able to find is this

                                https://community.jboss.org/wiki/JBossAS7SecurityDomainModel

                                https://community.jboss.org/wiki/JBossAS7SecurityCustomLoginModules

                                 

                                And as for your Exception, it seems to me, that you are missing definition of your security-domain in your standalone.xml. I personally don't know about login-config.xml and it's function as I don't use it at all, but standalone.xml domain definition looks very similar to it. In your case you should have something like this

                                 

                                 

                                <security-domain name="svcDomainSecurity" cache-type="default">
                                       <authentication>
                                           <login-module code="svc.loginmodule.SvcLoginModule" flag="required">
                                               <module-option ...
                                               ...
                                               ...
                                               ... />
                                          </login-module>
                                     </authentication>
                                </security-domain>
                                

                                 

                                Apart from this, I don't see any significant difference between your and my configuration.

                                 

                                Regards

                                • 13. Re: Remote EJB invocation from JBoss module
                                  ybarcelo

                                  Vladimir, thanks so much.

                                  Finally i could package the custom module on EAR

                                   

                                  MySvcEar.ear

                                  ---- Mylognmodule.jar  (jar module  with custom module)

                                  ----Myejbsecurity.jar    (ejb-jar  module   with  ejb for business methods for security)

                                  ----  mywebApp.war    (war module    with  web applicatión that contains form login to use custom login module)

                                   

                                  Regards.