浏览 2245 次
锁定老帖子 主题:JBOSS 下调用EJB3.0出错
该帖已经被评为隐藏帖
|
|
---|---|
作者 | 正文 |
发表时间:2009-02-12
最后修改:2009-02-12
import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; public class MyTest { public static void main(String[] args) { // System.setProperty("java.security.policy","client.policy"); // if(System.getSecurityManager()==null) // System.setSecurityManager(new RMISecurityManager()); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "localhost:1099"); env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces"); try{ Context ctx=new InitialContext(env); Object ref=ctx.lookup("HaiEJB"); HaiHome home=(HaiHome)PortableRemoteObject.narrow(ref,HaiHome.class); HaiClient user=home.create(); System.out.println(user.sayHai()); }catch(Exception e) { System.out.println(e.getMessage()); } } } 环境: Win XP SP3 JDK 1.6.11 Jboss4.0.3sp1 去掉注释的代码就: javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: java.security.AccessControlException: access denied (java.net.SocketPermission 230.0.0.4 connect,accept,resolve) [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)]] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1399) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572) at javax.naming.InitialContext.lookup(InitialContext.java:347) at ejbs.MyTest.main(MyTest.java:22) Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:254) at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370) ... 4 more Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269) at java.security.AccessController.checkPermission(AccessController.java:401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:524) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1026) at java.net.Socket.connect(Socket.java:446) at java.net.Socket.connect(Socket.java:402) at java.net.Socket.<init>(Socket.java:309) at java.net.Socket.<init>(Socket.java:211) at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69) at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62) at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224) ... 5 more 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |