0

I am trying to create a java program which will just receive the name of initial context factory in Weblogic Server.

You may find below the java source code that i am trying to execute :

import java.io.IOException; 
import java.io.Serializable; 
import java.rmi.MarshalledObject; 
import java.util.Hashtable; 
import java.util.Map.Entry; 
import javax.naming.Binding; 
import javax.naming.CommunicationException; 
import javax.naming.ConfigurationException; 
import javax.naming.Context; 
import javax.naming.InvalidNameException; 
import javax.naming.Name; 
import javax.naming.NameClassPair; 
import javax.naming.NameParser; 
import javax.naming.NamingEnumeration; 
import javax.naming.NamingException; 
import javax.naming.Reference; 
import javax.naming.Referenceable; 
import javax.naming.Context;
import javax.naming.InitialContext;

public class GetInitialContextClass
{
    public static void main(String[] args) {
        Hashtable env = new Hashtable(5);
        Context ctx = getInitialContext(env);
        System.out.println(ctx);
    }
}

But i have received the bellow error :

symbol  : method getInitialContext(java.util.Hashtable)
    location: class GetInitialContextClass
            Context ctx = getInitialContext(env);
                          ^

Please for your help.

NickName
  • 313
  • 2
  • 9
  • 25

2 Answers2

0

receive the name of initial context factory in Weblogic Server

means nothing.If you need to connect to the WebLogic Server jndi tree use the following code :

   Hashtable env = new Hashtable(5);
   env.put(Context.INITIAL_CONTEXT_FACTORY,
           "weblogic.jndi.WLInitialContextFactory");
   env.put(Context.PROVIDER_URL,
           "t3://weblogicServer:7001");
   Context ctx = new InitialContext(env);
Emmanuel Collin
  • 2,556
  • 2
  • 10
  • 17
0

Change the PROVIDER_URL env variable while preparing the Initial Context as follows:

private static Context getInitialContext() throws NamingException { 
    Hashtable env = new Hashtable(); 
    // WebLogic Server 10.x/12.x connection details
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); 
    env.put(Context.PROVIDER_URL, "t3://oc-144-21-91-92.compute.oraclecloud.com:9073"); 
    return new InitialContext(env); 
}

Please note the host:port combination should be as follows:WebLogic Server Config page

Mohammed Mukhtar
  • 1,731
  • 20
  • 18