程序清单:
import javax.naming.*;
import java.util.Properties;
public class JNDITest{
public static void main(String ar[]){
Context ctx=null;
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
try{ ctx=new InitialContext(p);
String test="JNDI Test example";
ctx.bind("name",test);
String s=(String)ctx.lookup("name");
System.out.println(s);
String str="welcome to you";
ctx.rebind("name",str);
s=(String)ctx.lookup("name");
System.out.println(s);
}catch(NamingException e){System.out.println(e.toString());}
}
}运行后显示错误:
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.
WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: web
logic.jndi.WLInitialContextFactory]
服务器是weblogic,然后在记事本里写的程序。把weblogic.jar放到jre\lib\ext下面后出现错误:
Exception in thread "main" java.lang.AssertionError: An error occurred while re
rieving the network addresses for this machine. The most likely cause is an err
r in the network configuration of this machine.
at weblogic.server.channels.AddressUtils$AddressMaker.getAllAddresses(A
dressUtils.java:63)
at weblogic.server.channels.AddressUtils$AddressMaker.<clinit>(AddressU
ils.java:46)
at weblogic.server.channels.AddressUtils.getLocalHost(AddressUtils.java
84)
at weblogic.server.channels.ServerChannelImpl.update(ServerChannelImpl.
ava:533)
at weblogic.server.channels.ServerChannelImpl.<init>(ServerChannelImpl.
ava:469)
at weblogic.server.channels.ServerChannelImpl.<init>(ServerChannelImpl.
ava:426)
at weblogic.server.channels.ServerChannelImpl.createDefaultServerChanne
(ServerChannelImpl.java:702)
at weblogic.servlet.internal.ProtocolHandlerHTTP$ChannelInitializer.<cl
nit>(ProtocolHandlerHTTP.java:31)
at weblogic.servlet.internal.ProtocolHandlerHTTP.getDefaultServerChanne
(ProtocolHandlerHTTP.java:36)
at weblogic.protocol.ServerChannelManager$SingletonMaker$1.getOutboundS
rverChannel(ServerChannelManager.java:339)
at weblogic.protocol.ServerChannelManager.findOutboundServerChannel(Ser
erChannelManager.java:243)
at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.jav
:238)
at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:202)
at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:22
)
at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:189)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:154)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIn
tialContextFactoryDelegate.java:349)
at weblogic.jndi.Environment.getContext(Environment.java:307)
at weblogic.jndi.Environment.getContext(Environment.java:277)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialCon
extFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at JNDITest.main(JNDITest.java:11)
Caused by: java.net.UnknownHostException: ??0??2
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressFromNameService(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at weblogic.server.channels.AddressUtils$AddressMaker.getAllAddresses(A
dressUtils.java:51)
... 24 more
请大侠不吝赐教啊!
import javax.naming.*;
import java.util.Properties;
public class JNDITest{
public static void main(String ar[]){
Context ctx=null;
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
try{ ctx=new InitialContext(p);
String test="JNDI Test example";
ctx.bind("name",test);
String s=(String)ctx.lookup("name");
System.out.println(s);
String str="welcome to you";
ctx.rebind("name",str);
s=(String)ctx.lookup("name");
System.out.println(s);
}catch(NamingException e){System.out.println(e.toString());}
}
}运行后显示错误:
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.
WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: web
logic.jndi.WLInitialContextFactory]
服务器是weblogic,然后在记事本里写的程序。把weblogic.jar放到jre\lib\ext下面后出现错误:
Exception in thread "main" java.lang.AssertionError: An error occurred while re
rieving the network addresses for this machine. The most likely cause is an err
r in the network configuration of this machine.
at weblogic.server.channels.AddressUtils$AddressMaker.getAllAddresses(A
dressUtils.java:63)
at weblogic.server.channels.AddressUtils$AddressMaker.<clinit>(AddressU
ils.java:46)
at weblogic.server.channels.AddressUtils.getLocalHost(AddressUtils.java
84)
at weblogic.server.channels.ServerChannelImpl.update(ServerChannelImpl.
ava:533)
at weblogic.server.channels.ServerChannelImpl.<init>(ServerChannelImpl.
ava:469)
at weblogic.server.channels.ServerChannelImpl.<init>(ServerChannelImpl.
ava:426)
at weblogic.server.channels.ServerChannelImpl.createDefaultServerChanne
(ServerChannelImpl.java:702)
at weblogic.servlet.internal.ProtocolHandlerHTTP$ChannelInitializer.<cl
nit>(ProtocolHandlerHTTP.java:31)
at weblogic.servlet.internal.ProtocolHandlerHTTP.getDefaultServerChanne
(ProtocolHandlerHTTP.java:36)
at weblogic.protocol.ServerChannelManager$SingletonMaker$1.getOutboundS
rverChannel(ServerChannelManager.java:339)
at weblogic.protocol.ServerChannelManager.findOutboundServerChannel(Ser
erChannelManager.java:243)
at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.jav
:238)
at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:202)
at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:22
)
at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:189)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:154)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIn
tialContextFactoryDelegate.java:349)
at weblogic.jndi.Environment.getContext(Environment.java:307)
at weblogic.jndi.Environment.getContext(Environment.java:277)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialCon
extFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at JNDITest.main(JNDITest.java:11)
Caused by: java.net.UnknownHostException: ??0??2
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressFromNameService(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at weblogic.server.channels.AddressUtils$AddressMaker.getAllAddresses(A
dressUtils.java:51)
... 24 more
请大侠不吝赐教啊!
解决方案 »
- struts2两个Action之间传参
- An attempt by a client to checkout a Connection has timed out.
- 谁帮忙分析下调用存储过程和spring的HibernateDaoSupport
- 在线等,<html:select> value的问题
- 谁有jtonsoft这个项目程序的数据内容啊
- 用spring rmi封装的事务管理的一个棘手问题
- servlet调用web service封装的借口问题。。。。急。各位大虾帮帮忙
- 请给个spring+struts+hibernate简单例子
- J2EE架构是什么?
- 关于hibernate主键生成策略报错
- UT Case 是什么啊
- crimson write (Writer out, String encoding)方法的使用
WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: web
logic.jndi.WLInitialContextFactory]
WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: web
logic.jndi.WLInitialContextFactory]
无法初始化类(主要是因为找不到类weblogic.jndi.WLInitialContextFactory)
Exception in thread "main" java.lang.AssertionError: An error occurred while re
rieving the network addresses for this machine. The most likely cause is an err
r in the network configuration of this machine.
在重获本机网络地址时出错,可能是本机网络地址配置出错
weblogic.jar , wsclient81.jar放如环境变量即可
这个名字是8.1版本的对应的9 或 10 的自己找jar包路径是一样的 前提是你weblogic已经启动
所有权归————寂寞沙冷