1 2 3 4 5 6 Previous Next 79 Replies Latest reply on Jan 10, 2013 6:57 PM by mevans7 Go to original post
      • 60. Re: How to call a remote EJB without a property file?
        sumitsu

        Radek Rodak wrote:

         

        I know what you mean, but it's not fault of static method.... problem is setting SELECTOR and performe lookup is not atomic.

        Well, you could make the case that non-atomicity is the root problem, but to me that would seem to suggest a resolution consisting of synchronizing on the EJBClientContext class for the full setSelector-lookup-invoke sequence for every invocation, to lock out changes by other threads for the duration.  That would be thread-safe, but it would also effectively serialize all of the EJB invocations from the JVM in question -- probably not a good approach from a performance standpoint.

         

        I'd rather suggest an approach where SELECTOR is maintained in a one-instance-per-thread manner (perhaps using ThreadLocal), or one in which the selector is maintained in the instance variable hierarchy somewhere.  I'd lean towards the latter, but I haven't really had time to investigate thoroughly as yet.

        • 61. Re: How to call a remote EJB without a property file?
          rodakr

          there is many ways...another would be just past SELECTOR Object ( not static ) as Parameter in Hashtable to new InitialContext, on which you call lookup...

          • 62. Re: How to call a remote EJB without a property file?
            bmaxwell

            > If your remote client application is portable before using this API, then yes, I agree.. Here is what Jason had to say about portability https://community.jboss.org/message/637476#637476

             

            • 63. Re: How to call a remote EJB without a property file?
              bernd.koecke

              It was some time ago when I started this thread. But I haven't said what solved my issue. It was one of the suggestions provided here. I would like to thank Jaikiran Pai, Stuart Douglas, John E. Bailey and all the others I can't figure out for their work on jboss-remote-naming. There is a wiki page (https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project) about it. I tried it and it helps me a lot by migrating from JBossAS 4.2.x to JBossAS 7.

              • 64. Re: How to call a remote EJB without a property file?
                thammoud

                Brandon,

                 

                I seem to have hit your exact problem. Had the SELECTOR been a thread local, then wrapping the proxy returned (By implementing InvocationHandler) from context.lookup("ejb") and passing down the selector as a parameter, would have achieved the desired behavior. I do hope that you have found a way around this severe limitation. 

                 

                static class RemoteInvocationHandler implements InvocationHandler {


                        static Object globalLock = new Object();

                 

                        private ContextSelector<EJBClientContext> selector;

                        private Object                                                        remoteProxy;

                 

                        public RemoteInvocationHandler(ContextSelector<EJBClientContext> selector, Object remoteProxy) {

                            this.selector         = selector;

                            this.remoteProxy = remoteProxy;

                        }

                 

                        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                            synchronized(globalLock) { //THERE WILL BE NO REASON TO DO THIS IF IT WAS A THREAD LOCAL

                                EJBClientContext.setSelector(selector);

                                Object result = method.invoke(remoteProxy,  args);

                                return result;

                            }

                       }

                }

                • 65. Re: How to call a remote EJB without a property file?
                  rodakr

                  I like your elegant way to work arround !!!

                  • 66. Re: How to call a remote EJB without a property file?
                    thammoud

                    I hope you are joking,

                     

                    It is pretty disgusting for a framework to force you to do hacks like this.

                    • 67. Re: How to call a remote EJB without a property file?
                      rodakr

                      O course you right...

                      just from technical point of view if you have no choice :-) , I'm running right now in same issue...

                       

                      I see some scenarion where you could still get problem...

                      Your scenarion will only work if all calls in same jvm runs over your RemoteInvocationHandler... if there is some calls which also set EJBClientContext   synchronisation will not work...

                      I'm thinking about, if synchronized(EJBClientContext.class) would be better or worse ...???

                      • 68. Re: How to call a remote EJB without a property file?
                        thammoud

                        You are correct. Any proxy created in the same VM will need to be wrapped by the RemoteInvocationHandler for the code to work properly. If your intention is to wrap, then whatever global lock that you decide to use is an implementation detail. I just did not want callers to remote methods to invoke the "setSelector" code. i.e Wanted the code to simulate a true remote proxy with no knowledge of a target. I am still scratching my head about the 7x implementation.

                        • 69. Re: How to call a remote EJB without a property file?
                          bmaxwell

                          See feature:

                          Allow Map based InitialContext configuration for ejb:

                          https://issues.jboss.org/browse/EJBCLIENT-34

                          • 70. Re: How to call a remote EJB without a property file?
                            thammoud

                            It will be interesting to see the solution. I did start another disucssion a while ago, somehow related to this issue. Did not get very far. Hopefully someone will address this as we will not move to 7.x with this implementation.

                             

                            https://community.jboss.org/message/759595#759595

                            • 71. Re: How to call a remote EJB without a property file?
                              rodakr

                              I put my comment :-)

                              • 72. Re: How to call a remote EJB without a property file?
                                rodakr

                                You right this work arround can't be used as work arround, if sombody cares about performance!!!

                                All remote calls are executed in synchronized sequence, never in parallel. If there is one long running EJB call, all calls will get blocked until end of this call!

                                 

                                I hope smart guys from AS7 core developers team will not let this be lake this long time, all parts of AS7 should be lightning fast.

                                • 73. Re: How to call a remote EJB without a property file?
                                  jaikiran

                                  I have been staying off this thread for some time now since this has gone way too long and since I wanted to get that EJBCLIENT-34 feature ready before recommending any other workarounds/solutions. I plan to have that feature (an Alpha version of it) available in AS7 upstream by either this weekend or early next week. So please be patient for a few more days and then give it a try. I'll be opening a separate thread with the details once that's ready.

                                   

                                  Tarek, EJBCLIENT-34 should allow you to get past your issue in that other thread.

                                  • 74. Re: How to call a remote EJB without a property file?
                                    bernd.koecke

                                    I started another thread, too (https://community.jboss.org/thread/203479). Because I got issues when I used jboss-remote-naming in a clustered environment. Jaikiran asked for a stacktrace. And issue EJBCLIENT-34 sounds like it will be a perfect solution.

                                     

                                    I think I can build a small lib for my special case. But it will only work when a bean on an old JBossAS 4.2.3 cluster wants to call another one on a JBossAS 7 cluster. Its not a general solution for all mentioned things from this thread. But I will need a few additional weeks until I have time to work on it. I'm really happy that Jaikiran is so kind to work on a new lib for these client calls. I will give it a try and hopefully it will replace my own one .