8 Replies Latest reply on Sep 20, 2006 9:16 PM by vashistvishal

    SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.4.GA

      Hi
      I have started playing EJB 3.0 and i found this problem with SLSB local interface inovcation from client. Though my remote interface client works fine its only when i
      invoke local client i get an exception. Any ideas.


      This o/p is for remote interface which is working fine

      [java] Name : $Proxy0
       [java] log4j:WARN No appenders could be found for logger (org.jboss.security.SecurityAssociation).
       [java] log4j:WARN Please initialize the log4j system properly.
       [java] Remote Bean: Sum returned from server is 30
      



      This o/p is for local interface which is the problem area.
      
       [java] Name : $Proxy1
       [java] Exception in thread "main" javax.ejb.EJBException: Invalid invocation of local interface (null container)
       [java] at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:75)
       [java] at $Proxy1.add(Unknown Source)
      


      I'm using EjB 3.0 with jboss-4.0.4.GA

      Vishal


        • 1. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.
          alrubinger

          Post up your code for us, Vishal? Implementation class, interfaces, calling code, etc. :)

          S,
          ALR

          • 2. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.

            Thanks for replying ...
            Here we go :)

            This is my Bean

            @Stateless
            
            public class StoreAccessBean implements StoreAccessLocal, StoreAccessRemote {
             public int add (int num1 , int num2) {
             int sum = num1 + num2;
             System.out.println ("I'm at server side Sum is " + sum);
             return sum;
             }
            }
            


            This is my interface
            @Local
            
            public interface StoreAccessLocal {
             public int add (int num1, int num2);
            }
            


            I havent added my remote interface code here.
            This is my calling client.

             public static void main(String [] args)
             {
             try
             {
             Context jndiContext = getInitialContext();
            
             Object ref = jndiContext.lookup("StoreAccessBean/remote");
             System.out.println ("Name : "+ ref.getClass().getName());
             StoreAccessRemote sa = (StoreAccessRemote)ref;
             int sum = sa.add(10, 20);
             System.out.println("Remote Bean: Sum returned from server is " + sum );
             // Until now it works fine
            
             // Problem area.... starts here
             Object reflocal = jndiContext.lookup("StoreAccessBean/local");
             System.out.println ("Name : "+ reflocal.getClass().getName());
             StoreAccessLocal salocal = (StoreAccessLocal)reflocal;
             System.out.println("I 'm fine until now ");
            // Fails here
             int sumlocal = salocal.add(10, 40);
            
             System.out.println("Local Bean: Sum returned from server is " + sumlocal );
            
            


            I hope this helps in nailing down this problem.

            Vishal


            • 3. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.
              alrubinger

              If you're running this client from main, it'll be in its own instance of the JVM, so your client (even if running on the same machine as the EJB) is *not* local. Local refers to "within same JVM" only, and will take advantage of certain in-JVM benefits, like being able to pass objects by reference, etc...

              So in other words, your error isn't actually an error. Use the remote proxy for remote clients. If you want to call your EJB from within another process (perhaps another EJB in the container), then you can use the local interface.

              S,
              ALR

              • 4. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.

                Let me get my understanding here correct
                My understanding is .....

                Remote is when client calls from a different JVM environment to a Bean which is
                in a seperate JVM. This is where Calls By Value comes in as everything has to be
                copied (part of serailization) to be sent across the wire.

                Where as Local means when both Client and Beans are in same JVM which means
                Call by reference is used.
                You can enlighten me please if this is wrong or nor correct.

                As to this error i thought i could change the setting in
                conf/standrdjboss.xml file where invoker proxy binding
                settings are.

                
                <invoker-proxy-binding>
                 <name>entity-rmi-invoker</name>
                 <invoker-mbean>jboss:service=invoker,type=jrmp</invoker-mbean>
                 <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
                 <proxy-factory-config>
                 <client-interceptors>
                 <home>
                 <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor>
                 <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
                 <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
                 <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
                <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
                </home>
                -----
                and some for others as in this category
                
                -----
                 </client-interceptors>
                 </proxy-factory-config>
                 </invoker-proxy-binding>
                
                


                I'm not sure in this version of JBoss which option to modify yet as
                currenty InvokerInterceptor is set to call by value, where as if i go by
                my understanding than if i change it to false than it should work as my
                client for both Remote and Local are in same JVM.

                Vishal



                • 5. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.
                  alrubinger

                   

                  "vashistvishal" wrote:


                  Remote is when client calls from a different JVM environment to a Bean which is
                  in a seperate JVM. This is where Calls By Value comes in as everything has to be
                  copied (part of serailization) to be sent across the wire.



                  True.

                  "vashistvishal" wrote:


                  Where as Local means when both Client and Beans are in same JVM which means
                  Call by reference is used.
                  You can enlighten me please if this is wrong or nor correct.



                  By default, true. You could configure local JNDI lookups to use call-by-value, but as this is much slower due to the unnecessary serialization, you typically wouldn't unless you has good reason. Check out the bottom of http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration.

                  "vashistvishal" wrote:


                  As to this error i thought i could change the setting in
                  conf/standrdjboss.xml file where invoker proxy binding
                  settings are.

                  I'm not sure in this version of JBoss which option to modify yet as
                  currenty InvokerInterceptor is set to call by value, where as if i go by
                  my understanding than if i change it to false than it should work as my
                  client for both Remote and Local are in same JVM.



                  I'm not understanding what you're trying to accomplish. When you say, "my client for both Remote and Local are in same JVM" ... you mean you're accessing the remote and local interfaces from within the same JVM instance? Or that your client is in the same JVM as the EJBs?

                  I can't say I've ever tried to access a local EJB from an outside JVM regardless of the "call-by-value" semantics. Why not just use the local interface when in the container, and the remote from remote clients?

                  S,
                  ALR

                  • 6. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.

                    Thanks for yr prompty reply:) that clarifies something.
                    When i say i'm accesing remote ejb interface and local ejb interface from a same cleint.
                    I mean i have the same (only one) JVM on my pc and i'm accesing this from my pc.

                    What i think is different is that my jboss is running inside Eclipse, which means it gets its own instnace of JVM. Where as my client runs from a command shell which means when it runs it uses or it gets a different instance of JVM. In that sense my shell based client becomes a remote (client) to jboss running in different jvm instance inside Eclipse.

                    Is this right understanding. And if thsi is correct than my local ejb interface client will not run talk until i run both JBoss and Client in same JVM instance. ....

                    Thanks for raising this and look forward to yr repsonse.

                    Vishal



                    • 7. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.
                      alrubinger

                       

                      "vashistvishal" wrote:


                      What i think is different is that my jboss is running inside Eclipse, which means it gets its own instnace of JVM. Where as my client runs from a command shell which means when it runs it uses or it gets a different instance of JVM. In that sense my shell based client becomes a remote (client) to jboss running in different jvm instance inside Eclipse.



                      Almost. Doesn't matter where the JVM is running from or how many versions of the JVM you've installed on your machine. When I say "instance of the JVM", I mean "separate process". Launch JBoss, that's one process. Launch another from your client's main method, that's another. You can list your processes (Linux "ps -aux", Windows CTL-ALT-DEL > Task Manager > Processes). And processes cannot pass references to one another.

                      So unless your EJBs are being invoked by something that's also within the container, it's a separate process and will need to be remote. :)

                      S,
                      ALR

                      • 8. Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.

                         

                        So unless your EJBs are being invoked by something that's also within
                        the container, it's a separate process and will need to be remote. :)

                        Thats is what is a happening. Thanks for yr help.