|
Java学习者论坛
我的做法:
1、配置weblogic server允許使用http隧道(已成功)
EJB客户可以使用如下代码访问:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "http://192.168.0.161:80");
//服务器不允许隧道时为:"t3://192.168.0.161:80"
Context ctx = new InitialContext(env);
2、dan实际的用户無法直接访问主机192.168.0.161
他们能够访问一台运行IIS和防火墙的主机iishost,iishost和192.168.0.161之间为局域网连jie
3、现在我为主机iishost添加插件,rang它可以把请求代理至192.168.0.161,使用如下iisproxy.ini文件
WebLogicHost=192.168.0.161
WebLogicPort=80
ConnectTimeoutSecs=60
ConnectRetrySecs=2
WlForwardPath=/weblogic
PathTrim=/weblogic
现在用户可以通过如下url訪问:
http://iishost/weblogic/service(代理转換de到的URL: http://192.168.0.161:80/service)
4、shang述兩bu成功后,我视tu在客戶端使用如xia代码访问192.168.0.161主机里面JNDI
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "http://iishost:80/weblogic");
Context ctx = new InitialContext(env);
结果:失败
javax.naming.CommunicationException. Root exception is java.net.ConnectException: http://iishost:80: Destination unreachable; nested exception is:
java.io.FileNotFoundException: Response: '404: Not Found' for url: 'http://iishost:80/bea_wls_internal/HTTPClntLogin/a.tun?wl-login=http+dummy+WLREQS+7.0.0.0+dummy+%0A&rand=5284305466954793771&AS=255&HL=19'; No available router to destination
at weblogic.rJVM.RJVMFinder.findOrCreate(RJVMFinder.java:173)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:262)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:323)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:221)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:149)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:665)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.<init>(InitialContext.java:198)
at untitled1.Enviroment.getInialContext(Enviroment.java:27)
at untitled1.Frame1.jButton1_actionPerformed(Frame1.java:83)
at untitled1.Frame1$1.actionPerformed(Frame1.java:54)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1504)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:216)
at java.awt.Component.proceSSMouseEvent(Component.java:3715)
at java.awt.Component.processEvent(Component.java:3544)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2593)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2497)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Window.dispatchEventImpl(Window.java:914)
at java.awt.Component.dispatchEvent(Component.java:2497)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
欢迎來到Java学习者论坛,zhuan载請注明地址:http://www.javaxxz.com. |
|