5 Replies Latest reply on Sep 19, 2002 5:38 AM by cobraflow

    ClassCastException using JUnit/Swing client

    terry_ray

      Hi,

      I'm having an odd problem testing with JUnit3.7. I am using JBoss3.0.0alpha on Win2000, Sun JDK 1.3.1_01. Basically, I can test with the text JUnit, no problem. The following code in the test client works fine:

      junit.textui.TestRunner.run(MyStuffTest.class);

      It successfully does the JNDI lookup, narrows home interface, does the create, life is good.

      But, when I attempt to use the JUnit TestRunner swingui or awtui class, I get a ClassCastException where I try to narrow the EJBHome.

      Test client:

      junit.swingui.TestRunner.run(MyStuffTest.class);

      or

      junit.awtui.TestRunner.run(MyStuffTest.class);

      The top of the stack trace:
      java.lang.ClassCastException
      at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
      at javax.rmi.PortableRemoteObject.narrow(Unknown Source)

      indicates that the Sun reference ORB is coming into the picture here. Is that normal for a JBoss client?

      I realize this may be a better question for JUnit instead of JBoss but I'm wondering if someone else has seen this? Or worse, that this is a Swing or AWT issue with the JDK (maybe loading the reference ORB... but why???)

      This was orignially working with just jboss-client.jar and jboss-j2ee.jar in my classpath, but I added most of the other jars in the client dir hoping it would fix this (no luck).

      If interested, here is the source snippet throwing the exception. This is a generic Service Locator, hence the lack of specific home interface class:

      try {
      Object obj = ic.lookup(jndiName);
      home = (EJBHome)PortableRemoteObject.narrow(obj,
      className);
      return home;
      } catch (NamingException ne) {
      ne.printStackTrace();
      } catch (Exception e) {
      e.printStackTrace();
      }

      Any advice is much appreciated. Thanks,

      Terry