11 Replies Latest reply on Nov 23, 2006 5:57 PM by simonw

    @Remote and @Local interface

    igorfie

      Is there anything in EJB3 spec that prevents me from marking an interface as both @Local and @Remote (with proper JNDI bindings, of course)? This does not seem to work with current EJB3 preview, so I wonder whether its a bug or a feature.

        • 1. Re: @Remote and @Local interface
          bill.burke

          I really do not see how one can use clientBindURL without coupling EJB sources with specific JBoss configuration. For example, the most abstract client URL I am able to specify today is "socket://0.0.0.0:3873" which means that I will not be able to deploy my EJBs to JBoss configuration that does not happen to accept socket connections on port 3873. Extremely restrictive if you ask me...

          I think that ideally developers should not worry about environment details like protocols and port numbers. It should be part of server configuration what protocols, ports and other low-level gunk to use to make my @Remote interfaces remotely accessible. All applications deployed into the same server share the same configuration (it tends to be one app per server anyways), and if your app has special needs -- just change the server config or define a new configuration.

          And frankly I still have to understand what's the deal with @Remote/@Local. First, these annotations do not seem to belong to interfaces and should be part of EJB source instead (why can't one interface be @Remote for one EJB implementation and @Local for another?). Second, I do not want to care about @Local/@Remote at all. My EJB has one or more *business* interfaces, and whether these interfaces should be made remotely available or local only is really not that big a deal for me.

          • 2. Re: @Remote and @Local interface
            bill.burke

            Looks like we have our first bug :) AFAIK, marking the same interface as @Remote and @Local should work, you'll just have to specify the LocalBinding and RemoteBinding as per the documentation. Please let me know if the documentation sufficiently describes how to do this.

            Thanks,

            Bill

            • 3. Re: @Remote and @Local interface
              igorfie

              Ok, I will look closely at this. I will let you know if I find anything interesting.

              Btw, there is a typo in Remote Interface JNDI Binding example (jndi.html). It says "jndiName=..." instead "jndiBinding=..." for @RemoteBinding which totally breaks copy&paste reuse :-)

              • 4. Re: @Remote and @Local interface
                igorfie

                There are few problems with @RemoteBinding.

                To start with, the following patch fixes instantiation exception in ProxyDeployer. I hope it's ok to post patches here.


                Index: ProxyDeployer.java
                ===================================================================
                RCS file: /cvsroot/jboss/jboss-ejb3/src/main/org/jboss/ejb3/ProxyDeployer.java,v
                retrieving revision 1.3
                diff -u -r1.3 ProxyDeployer.java
                --- ProxyDeployer.java 3 Sep 2004 19:57:16 -0000 1.3
                +++ ProxyDeployer.java 12 Oct 2004 19:30:53 -0000
                @@ -67,7 +67,7 @@
                {
                Class factoryClass = list.factory();
                if (factoryClass.equals(RemoteProxyFactory.class)) factoryClass = getDefaultRemoteProxyFactory();
                - RemoteProxyFactory factory = (RemoteProxyFactory)list
                .factory().newInstance();
                + RemoteProxyFactory factory = (RemoteProxyFactory)factoryClass.newInstance();
                factory.setRemoteBinding(list);
                factory.setContainer(container);
                factory.start();


                Then, clientBindUrl seems to require real hostname for the binding to work (i.e. "localhost" does not work), but this deserves it's own topic ;-)



                • 5. Re: @Remote and @Local interface
                  igorfie

                  I really do not see how one can use clientBindURL without coupling EJB sources with specific JBoss configuration. For example, the most abstract client URL I am able to specify today is "socket://0.0.0.0:3873" which means that I will not be able to deploy my EJBs to JBoss configuration that does not happen to accept socket connections on port 3873. Extremely restrictive if you ask me...

                  I think that ideally developers should not worry about environment details like protocols and port numbers. It should be part of server configuration what protocols, ports and other low-level gunk to use to make my @Remote interfaces remotely accessible. All applications deployed into the same server share the same configuration (it tends to be one app per server anyways), and if your app has special needs -- just change the server config or define a new configuration.

                  And frankly I still have to understand what's the deal with @Remote/@Local. First, these annotations do not seem to belong to interfaces and should be part of EJB source instead (why can't one interface be @Remote for one EJB implementation and @Local for another?). Second, I do not want to care about @Local/@Remote at all. My EJB has one or more *business* interfaces, and whether these interfaces should be made remotely available or local only is really not that big a deal for me.

                  • 6. Re: @Remote and @Local interface
                    bill.burke

                    That will be the bane of annotations. Its the XML vs. annotation debate...Most of the time, users will not have a need to set the clientBindUrl. There will eventually be XML overrides as well.

                    As for @Remote/@Local, basically it really means, pass by value or pass by reference. You actually do care about PBV or PBR when coding your application.

                    Bill

                    • 7. Re: @Remote and @Local interface
                      igorfie

                      I almost buy it... however I still think that @Remote/@Local belong to EJB class, not to interfaces. Consider the following snippet

                      @Stateless
                      @Remote(iface=MyIface.class)
                      @Local(iface=MyIface.class)
                      public class MyEjb {
                      ...
                      }
                      


                      I am not sure if it possible to extend @interface, but if it is, then it will be really nice to provide JBoss specific bindings as an extension to generic @Local/@Remote.

                      Anyways, I guess the current proposal is already "good enough" so let's not spoil it :-)


                      • 8. Re: @Remote and @Local interface
                        bill.burke

                         

                        "igorfie" wrote:
                        I almost buy it... however I still think that @Remote/@Local belong to EJB class, not to interfaces. Consider the following snippet

                        @Stateless
                        @Remote(iface=MyIface.class)
                        @Local(iface=MyIface.class)
                        public class MyEjb {
                        ...
                        }
                        


                        I am not sure if it possible to extend @interface, but if it is, then it will be really nice to provide JBoss specific bindings as an extension to generic @Local/@Remote.

                        Anyways, I guess the current proposal is already "good enough" so let's not spoil it :-)


                        I think a similar proposal was debated in the EG. The thing is, we want to encourage users to use and implement interfaces.

                        • 9. Re: @Remote and @Local interface
                          bill.burke

                           

                          "igorfie" wrote:
                          There are few problems with @RemoteBinding.

                          To start with, the following patch fixes instantiation exception in ProxyDeployer. I hope it's ok to post patches here.


                          Index: ProxyDeployer.java
                          ===================================================================
                          RCS file: /cvsroot/jboss/jboss-ejb3/src/main/org/jboss/ejb3/ProxyDeployer.java,v
                          retrieving revision 1.3
                          diff -u -r1.3 ProxyDeployer.java
                          --- ProxyDeployer.java 3 Sep 2004 19:57:16 -0000 1.3
                          +++ ProxyDeployer.java 12 Oct 2004 19:30:53 -0000
                          @@ -67,7 +67,7 @@
                          {
                          Class factoryClass = list.factory();
                          if (factoryClass.equals(RemoteProxyFactory.class)) factoryClass = getDefaultRemoteProxyFactory();
                          - RemoteProxyFactory factory = (RemoteProxyFactory)list
                          .factory().newInstance();
                          + RemoteProxyFactory factory = (RemoteProxyFactory)factoryClass.newInstance();
                          factory.setRemoteBinding(list);
                          factory.setContainer(container);
                          factory.start();


                          Then, clientBindUrl seems to require real hostname for the binding to work (i.e. "localhost" does not work), but this deserves it's own topic ;-)



                          Fixed in CVS.

                          Bill

                          • 10. Re: @Remote and @Local interface
                            zhangjboss

                            hi, could u please tell me if jboss4 requires enterprise java beans all have local interfaces? because i found that my ejb deployed well in jboss3 but many exceptions occured in jboss4. the exceptions are as following:

                            2006-07-03 09:19:39,489 DEBUG [org.jboss.ejb.plugins.local.BaseLocalProxyFactory]MyEjb cannot be Bound, doesn't have local and local home interfaces

                            thanks a lot

                            • 11. Re: @Remote and @Local interface
                              simonw

                               

                              "zhangjboss" wrote:
                              2006-07-03 09:19:39,489 DEBUG [org.jboss.ejb.plugins.local.BaseLocalProxyFactory]MyEjb cannot be Bound, doesn't have local and local home interfaces


                              I realise this is a bit of a long shot, but did you resolve this issue?

                              I've encountered the same error whilst following http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossSimpleExample guide from the JBoss wiki.

                              2006-11-23 22:45:58,122 DEBUG [org.jboss.ejb.plugins.local.BaseLocalProxyFactory] Interest cannot be Bound, doesn't have local and local home interfaces
                              2006-11-23 22:45:58,146 DEBUG [org.jboss.proxy.ejb.ProxyFactory] (re-)Binding Home interest/Interest
                              2006-11-23 22:45:58,172 INFO [org.jboss.proxy.ejb.ProxyFactory] Bound EJB Home 'Interest' to jndi 'interest/Interest'