SOS!!! EJB client problem. Thanks in advance

Discussions

EJB programming & troubleshooting: SOS!!! EJB client problem. Thanks in advance

  1. SOS!!! EJB client problem. Thanks in advance (2 messages)

    Hi All,

      I've spent a whole week and still have little clue to solve this problem. Sorry I have to write a lot to describe it clearly.
       
      This is a stand alone java application that will use several EJBs deployed in WebSphere3.5 on NT machine. It runs well on an NT machine (using either java or jre come with WebSphere3.5) but fails if I run it from an AIX machine (using IBM JRE 1.2.2)to access the same NT server.

    Here is the code piece:

    String providerURL = "iiop://172.21.159.169:900";
    String initCtxtFactory = "com.ibm.ejs.ns.jndi.CNInitialContextFactory";

    Properties namingProps = new Properties();
    namingProps.put(javax.naming.Context.PROVIDER_URL, providerURL);
    namingProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,initCtxtFactory);
    InitialContext initContext = null;

    // Create an Initial Context.
    try {
    System.out.println("providerURL="+ providerURL+";factory=" + initCtxtFactory);
    initContext = new InitialContext(namingProps);
    }
    }
    catch (javax.naming.NamingException ne) {
    System.err.println ("Could not retrieve initial context - all EJB lookups will fail." + ne.getMessage());
    }

    NamingEnumeration nu = null;

    try {
    nu = initContext.list(s);
    }// Add this to see if it can retrieve JNDI names
    catch (NotContextException e) {
    System.out.println("point 1.");
    e.printStackTrace();
    }

    When I run it from AIX I got:
    javax.naming.NotContextException
    at com.ibm.ejs.ns.jndi.CNContextImpl.doList(CNContextImpl.java:1233)
    at com.ibm.ejs.ns.jndi.CNContextImpl.list(CNContextImpl.java:511)
    at javax.naming.InitialContext.list(InitialContext.java:422)
    at com.tomax.distributedservices.AixScheduler.<init>(AixScheduler.java)
    at com.tomax.distributedservices.AixScheduler.main(AixScheduler.java)
    Exception in thread "P=838303:O=0:CT" java.lang.NullPointerException
    at com.tomax.distributedservices.AixScheduler.<init>(AixScheduler.java)
    at com.tomax.distributedservices.AixScheduler.main(AixScheduler.java)

    If I try to lookup the EJB directly (comment out list(s)) I get:
    javax.naming.NamingException: Error during resolve. Root exception is java.lang
    .NullPointerException
    at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:739)
    at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:585)
    at javax.naming.InitialContext.lookup(InitialContext.java:349)
    at com.tomax.distributedservices.AixScheduler.<init>(AixScheduler.java)
    at com.tomax.distributedservices.AixScheduler.main(AixScheduler.java)

      Interestingly, if I use com.sun.jndi.cosnaming.CNCtxFactory to replace com.ibm.ejs.ns.jndi.CNInitialContextFactory, it still works well on NT machine, and it finds the needed EJBs even from the AIX machine now. But whenever I call a EJB method that has a class object as parameter (implements Serializable), the following error message is thrown:

    org.omg.CORBA.MARSHAL: minor code: 0 completed: No
            at java.lang.Class.newInstance0(Native Method)
            at java.lang.Class.newInstance(Class.java:254)
            at com.sun.rmi.iiop.ReplyMessage.getSystemException(ReplyMessage.java:75
    )
            at com.sun.rmi.iiop.ClientResponseImpl.getSystemException(ClientResponse
    Impl.java:85)
            at com.sun.rmi.corba.ClientDelegate.invoke(ClientDelegate.java:198)
            at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:250)
            at com.tomax.wfm.ejb.schedule._SiteResourceRequest_BaseStub.isRequestCan
    celled(_SiteResourceRequest_BaseStub.java)
            at com.tomax.wfm.ejb.schedule._SiteResourceRequest_Stub.isRequestCancell
    ed(_SiteResourceRequest_Stub.java)
            at com.tomax.distributedservices.AixScheduler.isCancelled(AixScheduler.j
    ava)
            at com.tomax.distributedservices.AixScheduler.foreverRun(AixScheduler.ja
    va)
            at com.tomax.distributedservices.AixScheduler.main(AixScheduler.java)

      The thing is: The code is exactly the same but behaves differently. I read that we need IBM's JDK to talk to WebSphere but it also worked when I use Sun's context factory.

      I will be truly appreciative for any comments.

      PC
  2. Hi

    Have u included the client jar file in ur classpath when ur calling it from the AIX based machine.

    Try putting it in the classpath.

    Gaurav.
  3. Have you considered how the WebSphere classpaths tiers work?

    JVM classpath
    EJB classpath
    Web Application classpath

    Check this out -
    WebSphere Classpaths

    Stephen