2 entity beans, 1 session bean - 1 test client


EJB design: 2 entity beans, 1 session bean - 1 test client

  1. 2 entity beans, 1 session bean - 1 test client (5 messages)

    ide -
    i use jdeveloper.

    idea was -
    to create a new stateless session bean that will talk to the two entity beans. although the session bean will expose its method through a remote interface, the communication betweenn the session bean and the entity beans will be through a local interface. the assumptions is that all three ejbs are running in the same JVM.

    so -
    all three ejbs complied properly.

    but -
    when i tried to test with one 'sample test client' then this is the error i get.

    please please -
    can you look into the below error and let me know what possibly i'm doing wrong. i've been trying for last 4 days and can't figure out.

    thanks a lot.

    D:\jdev9052\jdk\bin\javaw.exe -ojvm -classpath D:\jdev9052\jdev\mywork\H&K\EJBApp\classes;D:\jdev9052\j2ee\home\lib\activation.jar;D:\jdev9052\j2ee\home\lib\ejb.jar;D:\jdev9052\j2ee\home\lib\jaas.jar;D:\jdev9052\j2ee\home\lib\jaxp.jar;D:\jdev9052\j2ee\home\lib\jcert.jar;D:\jdev9052\j2ee\home\lib\jdbc.jar;D:\jdev9052\j2ee\home\lib\jms.jar;D:\jdev9052\j2ee\home\lib\jndi.jar;D:\jdev9052\j2ee\home\lib\jnet.jar;D:\jdev9052\j2ee\home\lib\jsse.jar;D:\jdev9052\j2ee\home\lib\jta.jar;D:\jdev9052\j2ee\home\lib\mail.jar;D:\jdev9052\j2ee\home\lib\servlet.jar;D:\jdev9052\j2ee\home\oc4j.jar;D:\jdev9052\opmn\lib\optic.jar;D:\jdev9052\jdev\system9.\oc4j-config\.client;D:\jdev9052\lib\xmlparserv2.jar;D:\jdev9052\lib\xmlcomp.jar TeamStaffSessionEJBClient
    context initialized

    javax.naming.NamingException: Lookup error: java.net.ConnectException: Connection refused: connect; nested exception is:
    java.net.ConnectException: Connection refused: connect [Root exception is java.net.ConnectException: Connection refused: connect]

    at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:153)

    at javax.naming.InitialContext.lookup(InitialContext.java:347)

    at TeamStaffSessionEJBClient.main(TeamStaffSessionEJBClient.java:17)

    Caused by: java.net.ConnectException: Connection refused: connect

    at java.net.PlainSocketImpl.socketConnect(Native Method)

    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)

    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)

    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)

    at java.net.Socket.connect(Socket.java:452)

    at java.net.Socket.connect(Socket.java:402)

    at java.net.Socket.<init>(Socket.java:309)

    at java.net.Socket.<init>(Socket.java:153)

    at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java:2216)

    at com.evermind.server.rmi.RMIConnection.lookup(RMIConnection.java:1692)

    at com.evermind.server.rmi.RMIServer.lookup(RMIServer.java:678)

    at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:134)

    ... 2 more

    Process exited with exit code 0.

    Threaded Messages (5)

  2. Connection refused[ Go to top ]

    Connection refused suggests that the problem is not in the session connection with the entities through local interfaces, but in the client connection with the server. So check if the application deploys correctly, if the IP address and port number you are using in the client are correct, if you have the propper JNDI configuration in the client, and so on.

    Cheers and happy coding,
  3. Connection refused[ Go to top ]

    using jdeveloper 10g
    this is the jndi file which is in D:\jdev9052\jdev\system9.\oc4j-config\.client

    #Sun Jan 23 00:19:11 GMT 2005

    my test client is like this: -

    package hk;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import hk.StaffTeamSessionEJB;
    import hk.StaffTeamSessionEJBHome;
    import javax.naming.NamingException;

    public class StaffTeamSessionEJBClient
      public static void main(String [] args)
        StaffTeamSessionEJBClient staffTeamSessionEJBClient = new StaffTeamSessionEJBClient();
          Context context = getInitialContext();
          StaffTeamSessionEJBHome staffTeamSessionEJBHome = (StaffTeamSessionEJBHome)PortableRemoteObject.narrow(context.lookup("StaffTeamSessionEJB"), StaffTeamSessionEJBHome.class);
          StaffTeamSessionEJB staffTeamSessionEJB;

          // Use one of the create() methods below to create a new instance
          staffTeamSessionEJB = staffTeamSessionEJBHome.create();

          // Call any of the Remote methods below to access the EJB
           staffTeamSessionEJB.newProjectTeam( "1", "java", "sujan" );
          staffTeamSessionEJB.newStaff("1","ram","noGrade","someAdd","noNo","1" );

        catch(Throwable ex)


      private static Context getInitialContext() throws NamingException
        // Get InitialContext for Embedded OC4J.
        // The embedded server must be running for lookups to succeed.
        return new InitialContext();

    can u please tell me what i'm missing.
    thank you very very much.
  4. Connection refused[ Go to top ]

    The file must be called "jndi.properties", and the directory that contains it must be the client's runtime classpath. Also, check that the "java.naming.factory.initial" property has the correct class name for your application server.

    Cheers and happy coding,
  5. Connection refused[ Go to top ]

    as i did everything in jdeveloper where i didn't have to create those files manually, so i was just wondering how it went wrong as i'm just unable to figure out where the problem is.
    but anyway thanks a lot for al
  6. Connection refused[ Go to top ]

    That's the problem when you use a tool: everything's fine untill everything's wrong.
    Try to build your app be yourself, from the ground up, and when you have it working compare with the non-working, JBuilder-generated one. That's what I do when something's so screwed up I don't even know where I'm standing.

    Cheers and happy conding,