1 2 3 Previous Next 34 Replies Latest reply on Oct 15, 2013 10:29 AM by steeltomato Go to original post
      • 15. Re: JNDI Lookup of EJBs
        mohanpotturi

        Carlo,

         

        com.comp.prod.ejb.place.xxxQueryRemote$$$view3 is the result of my lookup. I was actually expecting to receive com.comp.prod.ejb.place.xxxQueryRemote. I am not familiar with class loading stuff. Please explain how I can output classloading information. Thank you.

        • 16. Re: JNDI Lookup of EJBs
          wolfc

          obj.getClass().getClassLoader().toString() should do the trick.

          • 17. Re: JNDI Lookup of EJBs
            mohanpotturi

            Thanks a bunch Carlo. Here is the ClassLoader.toString() out put:

             

            xxxQueryRemote$$$view3:  ModuleClassLoader for Module "deployment.yyyApp.ear.yyy-ejb.jar:main" from Service Module Loader

            xxxQueryRemote: ModuleClassLoader for Module "deployment.yyyApp.ear:main" from Service Module Loader

             

            Now what does it tell us?

            • 18. Re: JNDI Lookup of EJBs
              mohanpotturi

              Carlo,

               

              You are the man! I dun in some more after seeing the classloader output and sure enough, there are two occurances of the remote interfaces. One in the ejb jar and one in the common jar. I am not sure why this was done. I have to investigate it further. But after removing it from common jar, I am able to get past that point. You have been very helpful. I really apreciate it.

              • 19. Re: JNDI Lookup of EJBs
                wolfc

                Cool, nice to see that it is working out.

                 

                Hmm, that leaves two bugs. Note to devs:

                - ear flat class path not working

                - remote interface should be able to traverse class loader boundaries

                • 20. Re: JNDI Lookup of EJBs
                  wolfc

                  And I'll leave the thread with another class loading bug hunting trick:

                  obj.getClass().getProtectDomain().getCodeSource().getLocation().toString()

                  • 21. Re: JNDI Lookup of EJBs
                    scottg

                    If you are working with a single ear deployment I can see that it would be fairly easy to insure that there is only one copy of they interface in the deployment.  But what about situations where an ear/war/whatever needs to invoke an EJB contained in a different ear/war/whatever.

                    • 22. Re: JNDI Lookup of EJBs
                      mohanpotturi

                      Yup you are right Scott. Thats a problem and that is waht Carlo was talking about couple of posts above.

                      • 23. Re: JNDI Lookup of EJBs
                        trollfar

                        Stumbled on the same problem - any solutions or work-arounds? Need to address from one external .war into an .ear.

                        • 24. Re: JNDI Lookup of EJBs
                          mvoegele

                          Just wanted to add, that I ran into the same issue, when deploying an ear and war separately and trying to inject a remote ejb into a managed bean in war:

                           

                          Caused by: java.lang.IllegalArgumentException: Can not set com.axatech.ch.services.IrgendeinServiceRemote field org.icefaces.application.showcase.facelets.navigation.NavigationBean.irgendeinService to com.axatech.ch.services.IrgendeinServiceRemote$$$view2
                          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
                          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
                          at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
                          at java.lang.reflect.Field.set(Field.java:680)

                           

                          As Carlo wrote later on, interface classes should really be able to pass classloader borders.


                          • 25. Re: JNDI Lookup of EJBs
                            trollfar

                            Replying to my own question - yes there is a workaround. Got a tip from Mohan that elaborates his post above and says that you have to avoid duplicates within the entire AS of all interface classes (and, I think, some classes used by the interface).

                             

                            Thus I (and Mohan) make different client wars for local deployment (that do not include the interface etc) and remote deployment (that do include the interface).

                            • 26. Re: JNDI Lookup of EJBs
                              wolfc

                              I got a very preliminary patch here https://github.com/wolfc/jboss-as/tree/AS7-1658

                               

                              It mem leaks, so it is not useful yet. Also creation of MarshallingInvocationHandler is slow.

                               

                              But you can try it out to see if you run into other issues.

                              • 27. Re: JNDI Lookup of EJBs
                                mdzhokanov

                                I've rebuilt your patched version but still can't cast the received "view" to the relevant @Local interface. Receive following exception during an injection of an @EJB into ManagedBean field:

                                 

                                java.lang.IllegalArgumentException: Can not set bg.regel.backend.api.login.LoginEJBLocal field bg.regel.web.beans.LoginManagedBean.loginEJB to bg.regel.backend.api.login.LoginEJBLocal$$$view1

                                at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [:1.7.0]

                                    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [:1.7.0]

                                    at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [:1.7.0]

                                    at java.lang.reflect.Field.set(Field.java:680) [:1.7.0]

                                • 28. Re: JNDI Lookup of EJBs
                                  wolfc

                                  Can you post the entire stack trace?

                                   

                                  I suspect that injection does not run in the correct context.

                                  • 29. Re: JNDI Lookup of EJBs
                                    wolfc

                                    Ah I didn't read the fine details of your post. An @Local interface must come from a shared class loader / library, else you can never pass parameters by reference.