0 Replies Latest reply on Jan 1, 2004 5:38 AM by pstrotmann

    Testing an EJB under JBoss 3.2.3

    pstrotmann

      Hi,

      Im trying to test an entity bean under 3.2.3, but there seems to be some naming problem, I get the following stack trace:

      Buildfile: /home/strotmann/eclipse/workspace/gp/build.xml

      gpTest:
      [junit] .E
      [junit] Time: 0,707
      [junit] There was 1 error:
      [junit] 1) testAdresse(org.strotmann.gp.GpTest)
      [junit] javax.naming.NameNotFoundException: ejb not bound
      [junit] at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      [junit] at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      [junit] at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      [junit] at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [junit] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      [junit] at sun.rmi.transport.Transport$1.run(Transport.java:148)
      [junit] at java.security.AccessController.doPrivileged(Native Method)
      [junit] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      [junit] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      [junit] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      [junit] at java.lang.Thread.run(Thread.java:534)
      [junit] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      [junit] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      [junit] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      [junit] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      [junit] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      [junit] at javax.naming.InitialContext.lookup(InitialContext.java:347)
      [junit] at net.sourceforge.junitejb.EJBTestCase.getEJBTestRunner(EJBTestCase.java:162)
      [junit] at net.sourceforge.junitejb.EJBTestCase.runBare(EJBTestCase.java:109)
      [junit] at net.sourceforge.junitejb.EJBTestCase.run(EJBTestCase.java:95)
      [junit] FAILURES!!!
      [junit] Tests run: 1, Failures: 0, Errors: 1
      BUILD FAILED: file:/home/strotmann/eclipse/workspace/gp/build.xml:23: Java returned: -1
      Total time: 2 seconds
      -------------------------------------------
      I'm starting the following ant:

      <?xml version="1.0" encoding="UTF-8"?>

      <!-- Get the location of the jboss home directory from the environment -->



      <!-- internal build locations -->



































      -------------------------------------------
      org.strotmann.gp.GpTest looks as follows:

      package org.strotmann.gp;


      import java.util.Iterator;
      import org.strotmann.gp.interfaces.*;

      import javax.naming.InitialContext;

      import junit.framework.Test;
      import junit.framework.TestSuite;
      import net.sourceforge.junitejb.EJBTestCase;

      public class GpTest extends EJBTestCase
      {

      public static Test suite() {
      TestSuite testSuite = new TestSuite("GpTest");
      testSuite.addTestSuite(GpTest.class);
      return testSuite;
      }

      public GpTest(String name) {
      super(name);
      }

      private OrgaLocalHome orgaHome;
      private GpLocalHome gpHome;
      private AdresseLocalHome adresseHome;


      public void setUp() throws Exception {
      System.out.println("Start setUp");
      InitialContext jndi = new InitialContext();
      try {
      orgaHome = (OrgaLocalHome) jndi.lookup("java:ejb/local/Orga");
      } catch (Exception e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      }
      adresseHome = (AdresseLocalHome) jndi.lookup("java:ejb/local/Adresse");
      gpHome = (GpLocalHome) jndi.lookup("local/Gp");
      orgaHome.create("Jamaica Steamboat Company");
      adresseHome.create(new Integer(1), 12345, "Nassau", "Bahamas", 'p');
      }
      /** Teste die Adressen */
      public void testAdresse() throws Exception {
      System.out.println("Start testAdresse");
      Iterator adressen = adresseHome.findAll().iterator();
      while(adressen.hasNext()) {
      AdresseLocal adresse = (AdresseLocal)adressen.next();
      System.out.println(adresse.getAdresseId()+" "+
      adresse.getPlz()+" "+
      adresse.getOrt()+" "+
      adresse.getAdrZusatz()+" "+
      adresse.getAdrTyp());
      }
      }
      }
      ----------------------------------------------------------

      from jmx-console I get that the ejbs are binded to jndi-names local/Orga and local/Adresse

      By the way I don't see any reaction on my try block and on the display in my source code .

      peter