1 Reply Latest reply on Jan 2, 2004 8:33 AM by jonlee

    Testing an entityBean under 3.2.3 using Junitejb

    pstrotmann

      Hi Folks

      Welcome to 2004 with this more precise posting of the problem I posted yesterday.

      It seems to be a problem getting acces to EJBTestRunner
      as indicated in the following stacktrace:

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

      gpTest:
      [junit] .E
      [junit] Time: 0,617
      [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
      ------------------------ cut ----------------------------------

      The code snipped to run the test case (adapted from cmp2 example ) is

      ------------------------ cut ----------------------------------









      -------------------------- cut ---------------------------------------

      EJBTestRunnerEJB has been successfully deployed by

      -------------------------- cut ----from jboss.xml-----------------------------------

      <ejb-name>EJBTestRunnerEJB</ejb-name>
      <jndi-name>ejb/EJBTestRunner</jndi-name>

      -------------------------- cut ---------------------------------------
      and
      -------------------------- cut ----from ejb-jar.xml-----------------------------------

      JUnit Session Bean Test Runner
      <ejb-name>EJBTestRunnerEJB</ejb-name>
      net.sourceforge.junitejb.EJBTestRunnerHome
      net.sourceforge.junitejb.EJBTestRunner
      <ejb-class>net.sourceforge.junitejb.EJBTestRunnerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

      ------------------------------ cut ----------------------------------------------
      Deployment results in the following two entries in jmx-console under jboss.j2ee
      jndiName=EJBTestRunnerEJB, plugin=pool,service=ejb
      jndiName=EJBTestRunnerEJB, service=ejb

      peter

        • 1. Re: Testing an entityBean under 3.2.3 using Junitejb
          jonlee

          Yoou are probably making it difficult for people to help you because I don't believe many people have used JUnitEJB. For this reason, it makes it difficult for people to understand which part of your code failed.

          It looks like it is a lookup problem. This could stem from 3 different issues:
          1) The lookup is from a remote client (external to the JVM in which JBoss is executing) and the name used in the lookup is not applicable
          2) The lookup is from a remote client (external to the JVM in which JBoss is executing) and the interface is not available (local interfaces cannot be found from an external search, nor can Datasources)
          3) The name in the lookup has been misspelt

          Normally, a lookup for a jndi-name, ejb/JNDINAME would be:
          ctx.lookup("ejb/JNDINAME")

          Normally, a lookup for a ref-name, ejb/REFNAME would be:
          ctx.lookup("java:comp/env/ejb/REFNAME")


          Other than that, if you could isolate which lookup is failing and show the code fragment that failed, that might help folks pinpoint the problem.