8 Replies Latest reply on Dec 28, 2004 6:46 AM by lviz

    Cannot lookup after restart server

    lvhuyen

      I have 2 jboss servers: serverA and serverB. On serverA, I have a SLSB beanA. This SLSB has to call some method of SLSB beanB deployed on serverB.
      I can successfully lookup beanB from beanA, and do my business. But, when I restart serverB, I cannot lookup beanB again from beanA.
      The code segment in beanA that re-lookup beanB is:

      try
      {
       env = new Hashtable();
       env.put(Context.PROVIDER_URL, serverUrl);
       env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       Context ctx = new InitialContext(env);
       Object ref = ctx.lookup(beanBJndiName);
       if (ref == null)
       System.out.println("Got ref object");
       else
       System.out.println("ref is null");
       Object curHome = PortableRemoteObject.narrow(ref, homeClass);
      }
      catch (Exception ex)
      {
       ex.printStackTrace();
      }
      


      and here is what I got on serverA's screen

      10:20:22,546 INFO [STDOUT] ref is null
      10:20:22,546 ERROR [STDERR] java.lang.ClassCastException
      10:20:22,546 ERROR [STDERR] at com.sun.corba.se.internal.javax.rmi.PortableR
      emoteObject.narrow(PortableRemoteObject.java:293)
      10:20:22,546 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(Portabl
      eRemoteObject.java:134)
      10:20:22,546 ERROR [STDERR] at infogate.payment.business.ConnectorSSBBean.Re
      connect(ConnectorSSBBean.java:286)
      10:20:22,546 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      10:20:22,546 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      10:20:22,546 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      10:20:22,546 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$Conta
      inerInterceptor.invoke(StatelessSessionContainer.java:660)
      10:20:22,546 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedCo
      nnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanc
      eInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.i
      nvokeNext(AbstractTxInterceptor.java:107)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWit
      hTransactions(TxInterceptorCMT.java:178)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke
      (TxInterceptorCMT.java:60)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.inv
      oke(SecurityInterceptor.java:130)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(L
      ogInterceptor.java:204)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.invok
      e(StatelessSessionContainer.java:313)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.local.BaseLocalContaine
      rInvoker.invoke(BaseLocalContainerInvoker.java:301)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.local.StatelessSessionP
      roxy.invoke(StatelessSessionProxy.java:81)
      10:20:22,546 ERROR [STDERR] at $Proxy80.Reconnect(Unknown Source)
      10:20:22,546 ERROR [STDERR] at infogate.payment.business.ConnectorMDBBean.on
      Message(ConnectorMDBBean.java:51)
      10:20:22,546 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(
      Native Method)
      10:20:22,546 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(N
      ativeMethodAccessorImpl.java:39)
      10:20:22,546 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      10:20:22,546 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:3
      24)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.MessageDrivenContainer$Containe
      rInterceptor.invoke(MessageDrivenContainer.java:391)
      10:20:22,546 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedCo
      nnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.i
      nvokeNext(AbstractTxInterceptor.java:107)
      10:20:22,546 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptorBM
      T.invokeNext(AbstractTxInterceptorBMT.java:144)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.plugins.MessageDrivenTxIntercep
      torBMT.invoke(MessageDrivenTxInterceptorBMT.java:33)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.plugins.MessageDrivenInstanceIn
      terceptor.invoke(MessageDrivenInstanceInterceptor.java:88)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.plugins.RunAsSecurityIntercepto
      r.invoke(RunAsSecurityInterceptor.java:100)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(L
      ogInterceptor.java:204)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.MessageDrivenContainer.invoke(M
      essageDrivenContainer.java:302)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.plugins.jms.JMSContainerInvoker
      .invoke(JMSContainerInvoker.java:962)
      10:20:22,562 ERROR [STDERR] at org.jboss.ejb.plugins.jms.JMSContainerInvoker
      $MessageListenerImpl.onMessage(JMSContainerInvoker.java:1038)
      10:20:22,562 ERROR [STDERR] at org.jboss.jms.asf.StdServerSession.onMessage(
      StdServerSession.java:243)
      10:20:22,562 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.sessionConsum
      erProcessMessage(SpyMessageConsumer.java:603)
      10:20:22,562 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.addMessage(Sp
      yMessageConsumer.java:417)
      10:20:22,562 ERROR [STDERR] at org.jboss.mq.SpySession.run(SpySession.java:2
      96)
      10:20:22,562 ERROR [STDERR] at org.jboss.jms.asf.StdServerSession.run(StdSer
      verSession.java:178)
      10:20:22,562 ERROR [STDERR] at EDU.oswego.cs.dl.util.concurrent.PooledExecut
      or$Worker.run(PooledExecutor.java:655)
      10:20:22,562 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)
      


        • 1. Re: Cannot lookup after restart server
          lvhuyen

          Please help me resolve this problem.
          Thank you very much!

          • 2. Re: Cannot lookup after restart server
            lviz
            • 3. Re: Cannot lookup after restart server
              lvhuyen

              Dear,
              Thanks for your reply, Lviz. I have followed the link http://www.jboss.org/wiki/Wiki.jsp?page=HotDeployClassCastExceptions , now I can ensure that in my two servers, I have exactly only one copy of those classes that beanA and beanB share (the messages used to communicate, the Home and Remote interface of beanB). But the problem still be there.

              I want to tell that I restarted jboss serverB, not redeploy anything, no new class was uploaded. I simply restart serverB, and I want serverA could automatically reconnect to it again, without have to restart server A
              I think the problem here might not because of classloading (I am not sure, I'm not fully understand the narrow mechanics).

              After this line of code

              Object ref = ctx.lookup(beanBJndiName);/code] the ref object is null (I have shown in my code), so when I narrow it (from null of a class to an object of beanB's Home interface, the ClassCastException is thrown.
              
              Please help me.
              Thanks in advance!


              • 4. Re: Cannot lookup after restart server
                lviz

                hi again
                [back from weekend]
                can you please explain how your beans are packaged, on both servers?
                the include statements of the beanA.

                cheers
                L

                • 5. Re: Cannot lookup after restart server
                  lvhuyen

                  Thanks for your help, Lviz.

                  In serverA, I have package myCompany.business contains home, remote interface and bean class of beanA. These .class files and the deployment descriptor files are packed into ejbA.jar file and I put it in the default/deploy folder of jboss serverA.

                  In serverB, I have package myCompany.beanB contains home and remote interface of beanB. package myCompany.beanB.test contains bean class of beanB. The .class file: beanBBean.class (bean class) and the deployment descriptor files are packed into a .jar file named ejbB.jar and is put in the default/deploy folder of jboss serverB.
                  The 2 .class files: beanB.class (remote interface) and beanBHome.class (home interface) are packed into a jar file named beanBinterface.jar. This file is put into the default/lib folder of both jboss serverB and jboss serverA.

                  in the beanABean.java file, my code looks like:

                  package myCompany.business;
                  import myCompany.beanB.*;
                  

                  There is no reference to beanB in the deployment-descriptor of beanA.

                  Please help me!

                  • 6. Re: Cannot lookup after restart server
                    lvhuyen

                     

                     if (ref == null)
                     System.out.println("Got ref object");
                     else
                     System.out.println("ref is null");


                    Sorry all, I have missed coding at this place. So, my home instance is not null after lookup.
                    I think I'm finding out my problem. I'll reply soon.

                    Sorry for that annoyance.

                    • 7. Re: Cannot lookup after restart server
                      lvhuyen

                      Dear Lviz,
                      Sorry for the annoyance I've made. My problem was using wrong class, but I was confused with that "ref is null" output :<
                      Sorry!

                      • 8. Re: Cannot lookup after restart server
                        lviz

                        hi lvhuyen

                        Sorry for the annoyance I've made.
                        no problem here ;)

                        cheers
                        L