5 Replies Latest reply on Jun 14, 2006 7:09 AM by jerrygauth

    Error on lookup From a clustered SLSB to another clustered S

    pako

      Hello,



      My situation is that I'm using JBoss 4.0.3SP1 and I have SLSB#1 in a cluster trying to connect to SLSB#2 in a different cluster. I can do it find using the regular JNDI, but as soon as I try to use the HA-JNDI it fails to do the lookup with a NameNotFoundException.

      jboss.xml for SLSB#2:

      
       <session>
       <ejb-name>MyStatless</ejb-name>
       <jndi-name>ejb/MyStatless</jndi-name>
      
       <clustered>true</clustered>
      
       </session>
      


      Global JNDI Namespace for SLSB#2

       +- ejb (class: org.jnp.interfaces.NamingContext)
       | +- MyStatless-RemoteInvoker (class: org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxyHA)
       | +- MyStatless-HomeInvoker (class: org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxyHA)
       | +- MyStatless (proxy: $Proxy64 implements interface it.csi.oss.clusterejb.interfaces.MyStatlessHome,interface javax.ejb.Handle)
      


      Code snipit for SLSB#1 :

       InitialContext ic1;
       MyStatlessHome home=null;
       try {
       ic1 = new InitialContext();
       String contextFactory = (String) ic1.lookup("java:comp/env/contextFactory");
       String urlMyStatless = (String) ic1.lookup("java:comp/env/urlMyStatless");
       String jndiMyStatless = (String) ic1.lookup("java:comp/env/jndiMyStatless");
       Properties env =new Properties();
       env.setProperty(Context.INITIAL_CONTEXT_FACTORY,contextFactory);
       env.setProperty(Context.PROVIDER_URL,urlMyStatless);
       System.out.println("+++++++ @ Sono MyStalessClient Iniziato lookup : contextFacry ="+ env.getProperty(Context.INITIAL_CONTEXT_FACTORY)+" url = "+ env.getProperty(Context.PROVIDER_URL) );
       InitialContext ic = new InitialContext(env);
       Object objRef = ic.lookup(jndiMyStatless);
       home = (MyStatlessHome)PortableRemoteObject.narrow(
       objRef, MyStatlessHome.class);
       } catch (NamingException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      
      


      ejb-jar.xml for SLSB#1 :
       <session >
       <description><Description for MyStatlessClient]]></description>
       <display-name>Name for MyStatlessClient</display-name>
      
       <ejb-name>MyStatlessClient</ejb-name>
      
       <home>it.csi.oss.clusterejb.interfaces.MyStatlessClientHome</home>
       <remote>it.csi.oss.clusterejb.interfaces.MyStatlessClient</remote>
       <ejb-class>it.csi.oss.clusterejb.ejb.MyStatlessClientSession</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
      
       <env-entry>
       <env-entry-name>contextFactory</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value><![CDATA[org.jnp.interfaces.NamingContextFactory]]></env-entry-value>
       </env-entry>
       <env-entry>
       <env-entry-name>urlMyStatless</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value><![CDATA[jnp://cst003.csi.it:1200]]></env-entry-value>
       </env-entry>
       <env-entry>
       <env-entry-name>jndiMyStatless</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value><![CDATA[ejb/MyStatless]]></env-entry-value>
       </env-entry>
      
       </session>
      



      StackTrace on context.lookup() :

      2006-05-04 12:48:35,746 INFO [STDOUT] javax.naming.NameNotFoundException: ejb/MyStatless
      2006-05-04 12:48:35,746 INFO [STDOUT] at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:223)
      2006-05-04 12:48:35,747 INFO [STDOUT] at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:134)
      2006-05-04 12:48:35,747 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2006-05-04 12:48:35,747 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      2006-05-04 12:48:35,747 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2006-05-04 12:48:35,747 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      2006-05-04 12:48:35,747 INFO [STDOUT] at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:229)
      2006-05-04 12:48:35,747 INFO [STDOUT] at $Proxy84.lookup(Unknown Source)
      2006-05-04 12:48:35,747 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      2006-05-04 12:48:35,747 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      2006-05-04 12:48:35,747 INFO [STDOUT] at javax.naming.InitialContext.lookup(InitialContext.java:347)
      ..
      ..
      ..
      

      -Thanks


        • 1. Re: Error on lookup From a clustered SLSB to another cluster
          jahlborn

          I had similar problems. Most of the issues were resolved by using distinct partition names between the two servers. See thread here and linked bug:

          http://www.jboss.org/index.html?module=bb&op=viewtopic&t=83207

          • 2. Re: Error on lookup From a clustered SLSB to another cluster
            pako

            thanks, the problem has been resolved using distinct partition name

            • 3. Re: Error on lookup From a clustered SLSB to another cluster
              pako

              Since I can have the high availability between two ejb deployed on distintc clusters making the lookup using JNDI instead of HA-JNDI and since there are some tips to keep in mind in order to use HAJNDi between two cluster,

              which advantages to use HA-JNDI instead that JNDI?

              • 4. Re: Error on lookup From a clustered SLSB to another cluster
                jahlborn

                I'm not sure how you would get "high availability between two ejb deployed on distintc clusters making the lookup using JNDI". the point of HAJNDI is that although you initially contact one box in the cluster (any box, doesn't matter), you'll get back info on the rest of the cluster so that requests can be transparently load balanced as well as transparently failed-over (this is all handled under the hood by the HA invoker). If you just use JNDI, you are only ever talking to one box in the cluster, so you do not get "high availability".

                • 5. Re: Error on lookup From a clustered SLSB to another cluster

                  If you're using JNDI to perform lookups on multiple nodes in a cluster or clusters from a remote client, you'll need to know how to access each node. If your cluster is dynamic, you'll need to know how to detect nodes entering and exiting the cluster if you want to access each one remotely.

                  As jahlborn noted, you only need to access one node via HA-JNDI in order to get load balancing as well as access to all other JNDI data in the cluster. In addition to providing cluster wide lookups, HA-JNDI has its own replicated store. You can bind something in HA-JNDI and have it available locally on all nodes.

                  Note that HA-JNDI operates within a single cluster so a client accessing multiple clusters via HA-JNDI would require different provider urls for each cluster.