D
David Shen
I have 2 questions regarding the weblogic.
In a nutshell, here is my question.
I encounter NoInitialContextException and need some suggestion.
I would like to write code to view JNDI tree. Is it possible?
(how should I do it?)
1) question 1:
I run the following code and receive the following error?
Can you give me some suggestion?
// code
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.rmi.RemoteException;
import java.util.*;
public class Book {
public static void main(String[] args) {
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://127.0.0.1:7302");
ht.put(Context.SECURITY_PRINCIPAL, "system");
ht.put(Context.SECURITY_CREDENTIALS, "security");
try {
ctx = new InitialContext(ht);
}
catch (NamingException e) {
e.printStackTrace();
}
finally {
try {
ctx.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}
// get the following exception
javax.naming.NoInitialContextException: Cannot instantiate class:
weblogic.jndi.WLInitialContextFactory. Root exception is
java.lang.ClassNotFoundException:
weblogic.jndi.WLInitialContextFactory
at java.net.URLClassLoader$1.run (URLClassLoader.java:195) (pc
69)
at java.security.AccessController.doPrivileged(java.security.PrivilegedExceptionAction,java.security.AccessControlContext)
(AccessController.java)
at java.net.URLClassLoader.findClass (URLClassLoader.java:183) (pc
13)
at java.lang.ClassLoader.loadClass(java.lang.String,boolean)
(ClassLoader.java:306) (pc 43)
at sun.misc.Launcher$AppClassLoader.loadClass (Launcher.java:281) (pc
36)
at java.lang.ClassLoader.loadClass(java.lang.String)
(ClassLoader.java:262) (pc 3)
at java.lang.Class.forName0 (Class.java)
at java.lang.Class.forName(java.lang.String,boolean,java.lang.ClassLoader)
(Class.java:190) (pc 32)
at com.sun.naming.internal.VersionHelper12.loadClass(java.lang.String)
(VersionHelper12.java:40) (pc 8)
at javax.naming.spi.NamingManager.getInitialContext
(NamingManager.java:647) (pc 48)
at javax.naming.InitialContext.getDefaultInitCtx
(InitialContext.java:241) (pc 12)
at javax.naming.InitialContext.init (InitialContext.java:217) (pc
21)
at javax.naming.InitialContext.<init>(java.util.Hashtable)
(InitialContext.java:193) (pc 33)
at Book.main (Book.java:22) (pc
51)
java.lang.NullPointerException
at Book.main (Book.java:30) (pc
83)
2) My goal for the above code is to view the JNDI tree
e.g.
javax
jms
QueueConnectionFactory
com
dstsystem
JDBC
Can you give me some suggestion on how to write code to view the JNDI
tree in weblogic?
I really appreciate your help
David
In a nutshell, here is my question.
I encounter NoInitialContextException and need some suggestion.
I would like to write code to view JNDI tree. Is it possible?
(how should I do it?)
1) question 1:
I run the following code and receive the following error?
Can you give me some suggestion?
// code
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.rmi.RemoteException;
import java.util.*;
public class Book {
public static void main(String[] args) {
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://127.0.0.1:7302");
ht.put(Context.SECURITY_PRINCIPAL, "system");
ht.put(Context.SECURITY_CREDENTIALS, "security");
try {
ctx = new InitialContext(ht);
}
catch (NamingException e) {
e.printStackTrace();
}
finally {
try {
ctx.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}
// get the following exception
javax.naming.NoInitialContextException: Cannot instantiate class:
weblogic.jndi.WLInitialContextFactory. Root exception is
java.lang.ClassNotFoundException:
weblogic.jndi.WLInitialContextFactory
at java.net.URLClassLoader$1.run (URLClassLoader.java:195) (pc
69)
at java.security.AccessController.doPrivileged(java.security.PrivilegedExceptionAction,java.security.AccessControlContext)
(AccessController.java)
at java.net.URLClassLoader.findClass (URLClassLoader.java:183) (pc
13)
at java.lang.ClassLoader.loadClass(java.lang.String,boolean)
(ClassLoader.java:306) (pc 43)
at sun.misc.Launcher$AppClassLoader.loadClass (Launcher.java:281) (pc
36)
at java.lang.ClassLoader.loadClass(java.lang.String)
(ClassLoader.java:262) (pc 3)
at java.lang.Class.forName0 (Class.java)
at java.lang.Class.forName(java.lang.String,boolean,java.lang.ClassLoader)
(Class.java:190) (pc 32)
at com.sun.naming.internal.VersionHelper12.loadClass(java.lang.String)
(VersionHelper12.java:40) (pc 8)
at javax.naming.spi.NamingManager.getInitialContext
(NamingManager.java:647) (pc 48)
at javax.naming.InitialContext.getDefaultInitCtx
(InitialContext.java:241) (pc 12)
at javax.naming.InitialContext.init (InitialContext.java:217) (pc
21)
at javax.naming.InitialContext.<init>(java.util.Hashtable)
(InitialContext.java:193) (pc 33)
at Book.main (Book.java:22) (pc
51)
java.lang.NullPointerException
at Book.main (Book.java:30) (pc
83)
2) My goal for the above code is to view the JNDI tree
e.g.
javax
jms
QueueConnectionFactory
com
dstsystem
JDBC
Can you give me some suggestion on how to write code to view the JNDI
tree in weblogic?
I really appreciate your help
David