1 Reply Latest reply on Jan 16, 2003 7:29 AM by triathlon98

    exception when using JUnit

    triathlon98

      I have a set of beans which are deployed in JBoss 3.0.4 and a client which can be used standalone (main method) or as a JUnit testcase. When I run it standalone, everything works just fine, however, as a JUnit testcase it gives a java.lang.ClassCastException.


      java.lang.ClassCastException

      at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)

      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)

      at org.ictrace.test.EJBTest.setUp(EJBTest.java:55)

      at junit.framework.TestCase.runBare(TestCase.java:125)

      at junit.framework.TestResult$1.protect(TestResult.java:106)

      at junit.framework.TestResult.runProtected(TestResult.java:124)

      at junit.framework.TestResult.run(TestResult.java:109)

      at junit.framework.TestCase.run(TestCase.java:118)

      at junit.framework.TestSuite.runTest(TestSuite.java:208)

      at junit.framework.TestSuite.run(TestSuite.java:203)

      at junit.swingui.TestRunner$16.run(TestRunner.java:623)


      The class code is as follows


      public class EJBTest extends TestCase {

      public static void main(String[] args) {

      try {

      EJBTest e=new EJBTest();

      e.setUp();

      e.testMultipleField();

      } catch (Exception e) {

      SaveException.saveException(e);

      }

      }


      private BatchHome batchHome;


      public void setUp() throws Exception {

      InitialContext jndi = new InitialContext();


      batchHome=(BatchHome)PortableRemoteObject.narrow(jndi.lookup("IC-trace/Batch"), BatchHome.class);

      }


      public void testMultipleField() throws Exception {

      Batch batch = batchHome.create(Batch.TYPE_MeatBatch);

      batch.setAnimalReference("BE12345678");

      batch.addBreedingCountry("BE");

      }

      }


      Thanks for any help,
      Joachim