2 Replies Latest reply on Dec 17, 2008 2:15 PM by Josh Britton

    Problem Migrating to AS5 with rmi

    Josh Britton Newbie

      I am testing an app using JBoss and Eclipse. Remoting code that was working in JBoss 4.2 stopped working when I recently moved to 5.0. Now my clients get a ClassCastException when trying to access remote interfaces. Do I need to change jndi properties?

      Here is jndi.properties:

      ### JBossNS properties
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://localhost:1099
      java.naming.factory.url.pkgs=org.jboss.naming\:org.jnp.interfaces


      Here's code:

      Object o = ic.lookup("BigMathEAR/Login/remote");
      LoginRemote lr = (LoginRemote) PortableRemoteObject.narrow(o, LoginRemote.class);
      



      and here's the stack:

      Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
      at com.getmoremath.login.Controller.login(Controller.java:43)
      at com.getmoremath.login.View$6.actionPerformed(View.java:271)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
      at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
      at javax.swing.AbstractButton.doClick(AbstractButton.java:337)
      at com.getmoremath.util.ViewUtil$3.actionPerformed(ViewUtil.java:166)
      at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
      at javax.swing.JComponent.processKeyBinding(JComponent.java:2849)
      at javax.swing.JComponent.processKeyBindings(JComponent.java:2884)
      at javax.swing.JComponent.processKeyEvent(JComponent.java:2812)
      at java.awt.Component.processEvent(Component.java:5818)
      at java.awt.Container.processEvent(Container.java:2058)
      at java.awt.Component.dispatchEventImpl(Component.java:4413)
      at java.awt.Container.dispatchEventImpl(Container.java:2116)
      at java.awt.Component.dispatchEvent(Component.java:4243)
      at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
      at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:697)
      at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:962)
      at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:834)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
      at java.awt.Component.dispatchEventImpl(Component.java:4285)
      at java.awt.Container.dispatchEventImpl(Container.java:2116)
      at java.awt.Window.dispatchEventImpl(Window.java:2440)
      at java.awt.Component.dispatchEvent(Component.java:4243)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
      Caused by: java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.omg.CORBA.Object
      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
      ... 35 more

      Thanks for any advice.

        • 1. Re: Problem Migrating to AS5 with rmi
          Andrew Rubinger Master

           

          Caused by: java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.omg.CORBA.Object


          A cast from a naming reference is a red flag you don't have the EJB3 proxy classes in your client classpath. Check that you're got jbossall-client.jar on there.

          Also, with EJB3 business interfaces there's no need for the PortableRemoteObject nonsense, just d a plain cast. EJB2.x is a different story. ;)

          S,
          ALR

          • 2. Re: Problem Migrating to AS5 with rmi
            Josh Britton Newbie

            Thanks. You were right: I needed the jbossall-client.jar in my client's path.

            Also, I didn't know we could shed the 'narrowing' business -- I am a confused muddle of ejb2 and 3, having entered the scene with JBoss 4.2 and tried to use ejb 3 as much as possible. So thanks for the bonus point!

            jb