1 Reply Latest reply on Feb 29, 2012 4:33 PM by 920877

    NullPointerException  when getting InitialContext


      I have a piece of Java code running in the database, which I'm trying to migrate from Oracle 10g to Oracle 11g( on SUSE Linux Enterprise Server 11 (x86_64)) .
      This code is trying to make a call to an EJB in WebLogic server, but the call to get the InitialContext fails with the following exception:

      Exception in thread "Root Thread" java.lang.NullPointerException
      at com.sun.naming.internal.VersionHelper12$InputStreamEnumeration$1.run(VersionHelper12.java:185)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.naming.internal.VersionHelper12$InputStreamEnumeration.getNextElement(VersionHelper12.java:180)
      at com.sun.naming.internal.VersionHelper12$InputStreamEnumeration.hasMore(VersionHelper12.java:200)
      at com.sun.naming.internal.ResourceManager.getApplicationResources(ResourceManager.java:470)
      at com.sun.naming.internal.ResourceManager.getInitialEnvironment(ResourceManager.java)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      at musala.deni.test.QueueHandlerLookup.getBean(QueueHandlerLookup.java:46)
      at musala.deni.test.QueueHandlerLookup.test(QueueHandlerLookup.java:30)

      In the old DB the call was to an OC4J container, so I changed the java.naming.factory.initial property to "weblogic.jndi.WLInitialContextFactory".
      I also loaded wlthint3client.jar into the DB(tried also with wlclient.jar but the result was the same).

      Here is the java implementation that tries to lookup the EJB:
      36> private RL2F2MessageSenderSessionEJB getBean() {
      37>          RL2F2MessageSenderSessionEJB bean = null;
      38> try {
      39>      System.out.println("CREATING CONTEXT PROPS");
      40>      Hashtable props = new Hashtable();
      41> props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      42> props.put(Context.SECURITY_PRINCIPAL, "<user>");
      43> props.put(Context.SECURITY_CREDENTIALS, "<password>");
      44> props.put(Context.PROVIDER_URL, "t3://<host>:<port>");
      46> context = new InitialContext(props);
      47> RL2F2MessageSenderSessionEJBHome beanHome = (RL2F2MessageSenderSessionEJBHome)(context).lookup("ejb/RL2F2MessageSenderSessionEJB");
      50> bean = beanHome.create();
      51> } catch (RemoteException e) {
      52>      System.out.println(e.getMessage());
      53> e.printStackTrace();
      54> } catch (CreateException e) {
      55>      System.out.println(e.getMessage());
      56> e.printStackTrace();
      57> } catch (NamingException e) {
      58>      System.out.println(e.getMessage());
      59> e.printStackTrace();
      60> }
      62> return bean;
      63> }

      When I run the same code from the OS of the database using the java found under: <ORACLE_HOME>/dbhome_1/jdk/bin/java the code executes successfully!

      Please let me know what could be wrong?

      Edited by: user1068926 on Feb 29, 2012 8:34 AM