1 Reply Latest reply on Dec 3, 2002 10:21 AM by slaboure

    ClassLoader problem?

    denagbe

      Hi,

      I have a problem which seems like a bug to me:
      I have two Jboss servers (same version) running on
      different computers, from a Stateless session bean I want to
      access the same session bean located on the second computer.
      The first time I deploy my components every thing works
      fine, but if I modify them and redeploy, I have a ClassCastException
      that correspond to the line where the first session lookup
      the home located in the second computer.
      I even used farming to ensure that I really have exactly the
      same components deployed.
      See code below, and the exception:

      package meetings.implementation;

      import javax.ejb.*;
      import javax.naming.*;
      import meetings.interfaces.*;
      import java.util.*;
      /**
      * Created Oct 25, 2002 4:25:15 PM
      * Code generated by the Forte For Java EJB Builder
      * @author denagbe
      *
      * @ejb:bean
      * name="ClassCastEx"
      * description="ClassCastEx Session Bean"
      * display-name="ClassCastEx"
      * type="Stateless"
      * transaction-type="Container"
      * jndi-name="meetings/ClassCastEx"
      * view-type="remote"
      *
      * @ejb:util
      * generate="physical"
      *
      * @ejb:transaction type="Never"
      *
      * @ejb:permission unchecked="true"
      *
      *
      */
      public class ClassCastExBean implements javax.ejb.SessionBean
      {
      private javax.ejb.SessionContext context;

      /**
      * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
      */
      public void setSessionContext(javax.ejb.SessionContext aContext)
      {
      context = aContext;
      }

      /**
      * @see javax.ejb.SessionBean#ejbActivate()
      */
      public void ejbActivate()
      {
      }

      /**
      * @see javax.ejb.SessionBean#ejbPassivate()
      */
      public void ejbPassivate()
      {
      }

      /**
      * @see javax.ejb.SessionBean#ejbRemove()
      */
      public void ejbRemove()
      {
      }

      /**
      * See section 7.10.3 of the EJB 2.0 specification
      */
      public void ejbCreate() throws CreateException
      {
      }

      /**
      * @ejb:interface-method
      */
      public void contact() throws Exception
      {
      System.out.println("Contacting");
      ResourceBundle resourceBundle = ResourceBundle.getBundle("remoteserver");
      String jndiURL = resourceBundle.getString("jndiURL");

      // Lookup and cache the home references
      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      props.setProperty("java.naming.provider.url", jndiURL);
      Context ic = new InitialContext(props);
      //Look up the Home
      ClassCastExHome classCastExHome = (ClassCastExHome)ic.lookup(ClassCastExHome.JNDI_NAME);
      ic.close();
      ClassCastEx classCastEx = classCastExHome.create();
      classCastEx.hello();
      }

      /**
      * @ejb:interface-method
      */
      public void hello()
      {
      System.out.println("Hello world");
      }

      }


      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerException: RuntimeException; nested exception is:
      java.lang.ClassCastException
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:129)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:111)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy1.contact(Unknown Source)
      at meetings.test.Client.main(Client.java:21)
      Caused by: java.rmi.ServerException: RuntimeException; nested exception is:
      java.lang.ClassCastException
      at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:369)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:207)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:381)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      Caused by: java.lang.ClassCastException
      at meetings.implementation.ClassCastExBean.contact(ClassCastExBean.java:87)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:312)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:203)
      ... 15 more
      Exception in thread "main"
      Java Result: 1

        • 1. Re: ClassLoader problem?
          slaboure

          It is most probably because the remote version of your class is not compatible with the local version (because ejbdoclet changed something). Can you try to redeploy on the remote server but *without* changing the content of the JAR (just touch it so that the timestamp changes)

          Cheers,


          sacha