Topic
6 replies Latest Post - ‏2012-12-04T20:38:57Z by SystemAdmin
SystemAdmin
SystemAdmin
14225 Posts
ACCEPTED ANSWER

Pinned topic RAD 8.5 problem running standalone java app that calls EJB and MQ

‏2012-11-27T19:40:52Z |
Hello,
I used to be able to run my standalone java app that calls EJB and MQ using JNDI on RAD 7.5.5. I upgraded to RAD 8.5 and when I tried to run it, I received the error "Failed to create InitialContext using factory specified in hashtable". I'm also using the same WAS 7.0.0.9 for both RAD version so I'm not sure why it's not working now.
Is there anything special that I need to do in RAD 8.5?
This is my bootstrap classpath entries: WAS v7.0 JRE, %WAS_RUNTIME%\com.ibm.ws.ejb.thinclient_7.0.0.jar, WAS v7.0 lib
Below are the lines where I set up the environment (the second line seems to be needed for RAD 8.5):
System.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");
System.setProperty("com.ibm.ws.naming.wsn.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");

Thanks
Updated on 2012-12-04T20:38:57Z at 2012-12-04T20:38:57Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    14225 Posts
    ACCEPTED ANSWER

    Re: RAD 8.5 problem running standalone java app that calls EJB and MQ

    ‏2012-11-29T16:48:48Z  in response to SystemAdmin
    Are you seeing a ClassNotFound in your stack trace? Is the jar containing the factory class included in the classpath of your stand-alone Java app?
    • SystemAdmin
      SystemAdmin
      14225 Posts
      ACCEPTED ANSWER

      Re: RAD 8.5 problem running standalone java app that calls EJB and MQ

      ‏2012-11-30T21:50:58Z  in response to SystemAdmin
      No, I did not get a class not found exception. I got a null pointer exception below:

      2012-11-30 16:50:14,945 main FATAL ram.hs.edi.EDIDaemon(line 183) - Unable to get running status: javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable http://Root exception is java.lang.NullPointerException
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
      at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
      at javax.naming.InitialContext.internalInit(InitialContext.java:295)
      at javax.naming.InitialContext.<init>(InitialContext.java:212)
      at ram.hs.edi.utils.MQReader.open(MQReader.java:85)
      at ram.hs.edi.EDIDaemon.isRunning(EDIDaemon.java:406)
      at ram.hs.edi.EDIDaemon.run(EDIDaemon.java:168)
      at ram.hs.edi.EDIDaemon.main(EDIDaemon.java:898)
      Caused by: java.lang.NullPointerException
      at com.ibm.ws.naming.util.CommonHelpers$2.run(CommonHelpers.java:268)
      at com.ibm.ws.naming.util.CommonHelpers$2.run(CommonHelpers.java:264)
      at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
      at com.ibm.ws.naming.util.CommonHelpers.mergeJndiProviderProperties(CommonHelpers.java:263)
      at com.ibm.ws.naming.util.CommonHelpers.mergeWsnJndiProperties(CommonHelpers.java:159)
      at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:186)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
      ... 8 more
      • SystemAdmin
        SystemAdmin
        14225 Posts
        ACCEPTED ANSWER

        Re: RAD 8.5 problem running standalone java app that calls EJB and MQ

        ‏2012-12-04T16:27:02Z  in response to SystemAdmin
        You might not be setting the initial context factory correctly. You probably should be creating a Hashtable, populating it and passing that to the InitialContext constructor. Check out the following page:

        http://publib.boulder.ibm.com/infocenter/wasinfo/v5r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Frnam_example_prop2.html
        • SystemAdmin
          SystemAdmin
          14225 Posts
          ACCEPTED ANSWER

          Re: RAD 8.5 problem running standalone java app that calls EJB and MQ

          ‏2012-12-04T18:56:25Z  in response to SystemAdmin
          I set those in the system properties and it worked before on RAD 7.5.5, but I will try using a Hashtable. Thanks.
          • SystemAdmin
            SystemAdmin
            14225 Posts
            ACCEPTED ANSWER

            Re: RAD 8.5 problem running standalone java app that calls EJB and MQ

            ‏2012-12-04T20:19:24Z  in response to SystemAdmin
            I tried the hashtable method but no changes in result.
            I played around with the runtime classpath and just have a bare minimum jar files for getting an initial context and I received a different exception. Seems like something else need to set in the hashtable? Any ideas?
            Below is my codes:
            Hashtable ht = new Hashtable();
            ht.put(Context.PROVIDER_URL, "iiop://localhost:2809");
            ht.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
            Context ctx = new InitialContext(ht);

            Below is the exception:
            java.lang.StackOverflowError
            at java.util.Hashtable$Entry.equalsKey(Hashtable.java:129)
            at java.util.Hashtable.getEntry(Hashtable.java:535)
            at java.util.Hashtable.containsKey(Hashtable.java:381)
            at com.ibm.ws.naming.util.CommonHelpers.mergeJndiProviderProperties(CommonHelpers.java:324)
            at com.ibm.ws.naming.util.CommonHelpers.mergeWsnJndiProperties(CommonHelpers.java:159)
            at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:186)
            at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:194)
            at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:194)
            .......
            .......
            .......
            com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:194)
            com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:194)
            at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
            at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
            at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
            at javax.naming.InitialContext.internalInit(InitialContext.java:295)
            at javax.naming.InitialContext.<init>(InitialContext.java:212)
            • SystemAdmin
              SystemAdmin
              14225 Posts
              ACCEPTED ANSWER

              Re: RAD 8.5 problem running standalone java app that calls EJB and MQ

              ‏2012-12-04T20:38:57Z  in response to SystemAdmin
              Hmm, a strange outcome. BTW, the URL I posted is for WAS v5 but if you change the 5 to a 7, you will get basically the same info for WAS v7.

              Perhaps you need to give your app more memory? Check out Diagnosing a java.lang.StackOverflowError