5 Replies Latest reply on Feb 15, 2008 12:24 PM by 666705

    Cannot look up EJB deployed to different managed server in same cluster

    666705
      **I had previously posted this problem to the clustering forum but received no response, so I am hoping to have better luck in this forum.**

      I'm experiencing some problems with clustered EJBs in WLS 9.2 MP 1. I have a cluster of 5 managed servers, and I am attempting to establish communication between some EJBs that are targeted to managed servers 1, 2, 3, and 4 and a separate application that is targeted only to managed server 5. Based on what I have read in the WLS 9.2 documentation, my understanding is that objects bound to the JNDI tree in a clustered environment are replicated to all servers in the cluster, so I did not expect this to present a problem. However, when I attempt the JNDI lookup from the app running on managed server 5, it fails with the exception below. I have no problem looking up other types of resources (e.g., data sources, JMS resources, mail sessions) that aren't targeted to the same servers as my calling app; the problem appears to be limited to EJB lookups. Is this configuration not supported for EJBs, or is there a configuration step that I've missed? Any help would be greatly appreciated.
      Regards,
      Sabrina

      Caused by: javax.naming.LinkException: [Root exception is javax.naming.NamingException: unable to find primary representative]; Link Remaining Name: 'TestBean'
      at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:103)
      at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:884)
      at weblogic.jndi.internal.ApplicationNamingNode.resolveObject(ApplicationNamingNode.java:174)
      at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:856)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:209)
      at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:130)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
      at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:130)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
      at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:130)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
      at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:130)
      at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:269)
      at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:362)
      at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
      at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at test.util.TestServiceLocator.getRemoteHome(TestServiceLocator.java:248)
      ... 13 more
      Caused by: javax.naming.NamingException: unable to find primary representative
      at weblogic.rmi.cluster.ClusterableRemoteObject.getReferent(ClusterableRemoteObject.java:131)
      at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:95)
      at weblogic.jndi.internal.ServerNamingNode.resolveObject(ServerNamingNode.java:348)
      at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:856)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:209)
      at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:269)
      at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:362)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:101)
      ... 30 more
        • 1. Re: Cannot look up EJB deployed to different managed server in same cluster
          666705
          Did you find a solution for this exception? I'm having the same problem. Thanks!
          • 2. Re: Cannot look up EJB deployed to different managed server in same cluster
            666705
            Unfortunately, I was not able to find a desirable solution to this problem. Based on some things I have read in the WLS documentation and several other forum posts, I believe that the root cause of the problem is the fact that WLS will not dynamically load the required stub classes over the network for server-side clients. (I have no problem accessing my EJBs from remote standalone clients regardless of how they are targeted.) A couple posters who had experienced simliar problems claimed to have solved them by adding the EJB's remote interface class to the server's classpath, but that did not work for me and the solution would not have been feasible anyway due to the fact that any updates to that interface would require that the server be recycled. After trying many different things, I finally gave up and just deployed my server-side clients to one of the managed servers hosting the target EJBs.
            Regards,
            Sabrina
            • 3. Re: Cannot look up EJB deployed to different managed server in same cluster
              666705
              I am encountering the same error but it is intermittent and it's happening with EJBs targetted at the cluster and one that is targetted at only one of the managed servers.

              The other difference is that I'm making the call outside of Webogic from a servlet so it's not from EJB to EJB.

              Once the error appears I have to restart the cluster to rectify the problem.

              This is the only place that I can find reference to "unable to find primary representative" apart from your other post in the Cluster forum Sabrina.

              I am using WebLogic 9.2 MP2.

              Any suggestions?

              Many thanks,

              Shane
              • 4. Re: Cannot look up EJB deployed to different managed server in same cluster
                666705
                Hi Shane,
                Is it possible that your problem is being caused by the URL you're using to connect to the target WebLogic cluster? For EJBs that are targeted to the cluster, you should be using the cluster address so that WebLogic can internally distribute the requests as appropriate. But if one of your EJBs is targeted to a single server in the cluster, you need to explicitly connect to that server. This info might help if you have not already seen it: http://e-docs.bea.com/wls/docs92/jndi/jndi.html#wp475689.
                Regards,
                Sabrina
                • 5. Re: Cannot look up EJB deployed to different managed server in same cluster
                  666705
                  Hi Sabrina,

                  Thanks for taking the time to respond. I understand now the problem with the pinned EAR and the URL for the jndi lookup.

                  I think I also understand the reason why it is happening with the EAR targetted at the cluster. It appears that the EAR fails to initialise properly on one of the managed servers. An instance variable in a Stateless Session Bean is throwing a RuntimeException. From the WebLogic console it appears that the EAR has deployed however if you drill down to the EJBs you see that it's only deployed on one of the managed servers. I've changed my code to initialise the instance variable in one of the EJB methods.

                  I need to do further testing to verify that this will fix it but initial indications are looking good. I would have expected a deployment error in the WebLogic managed server logs.

                  Thanks again,

                  Shane