当前位置: 技术问答>java相关
Jboss中的一个问题(十万火急)
来源: 互联网 发布时间:2015-03-29
本文导语: 以下是客户端代码 System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); System.setProperty("java.naming.provider.url", "localhost:1099"); System.out.println("Step 1"); try { //get naming context C...
以下是客户端代码
System.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.provider.url",
"localhost:1099");
System.out.println("Step 1");
try {
//get naming context
Context ctx = new InitialContext();
System.out.println("Step 2");
//look up jndi name
Object ref = ctx.lookup("hello/Hello");
System.out.println("Step 3");
//cast to Home interface
helloHome = (HelloHome) PortableRemoteObject.narrow(ref,
HelloHome.class);
System.out.println("Step 4");
Hello ff=helloHome.create();
System.out.println("Step 5");
System.out.print(ff.helloWorld()) ;
执行时前四步都没有错误,在第五步creat()出错,提示如下:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/jboss/security/SecurityAssociation
at
org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.getPrincipal(Generic
Proxy.java:184)
at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:2
31)
at $Proxy0.create(Unknown Source)
at Client.(Client.java:26)
at Client.main(Client.java:45)
有人知道是怎么回事吗??
System.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.provider.url",
"localhost:1099");
System.out.println("Step 1");
try {
//get naming context
Context ctx = new InitialContext();
System.out.println("Step 2");
//look up jndi name
Object ref = ctx.lookup("hello/Hello");
System.out.println("Step 3");
//cast to Home interface
helloHome = (HelloHome) PortableRemoteObject.narrow(ref,
HelloHome.class);
System.out.println("Step 4");
Hello ff=helloHome.create();
System.out.println("Step 5");
System.out.print(ff.helloWorld()) ;
执行时前四步都没有错误,在第五步creat()出错,提示如下:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/jboss/security/SecurityAssociation
at
org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.getPrincipal(Generic
Proxy.java:184)
at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:2
31)
at $Proxy0.create(Unknown Source)
at Client.(Client.java:26)
at Client.main(Client.java:45)
有人知道是怎么回事吗??
|
你用下面的试试
String url = "localhost:1099";
String contextFactory="org.jnp.interfaces.NamingContextFactory";
String urlPkg="org.jboss.naming:org.jnp.interfaces";
Properties properties = null;
Context ctx=null;
try
{
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
properties.put(Context.PROVIDER_URL, url);
properties.put(Context.URL_PKG_PREFIXES, urlPkg);
ctx=new InitialContext(properties);
}
catch(Exception e)
{
System.out.println("...");
throw e;
}
String url = "localhost:1099";
String contextFactory="org.jnp.interfaces.NamingContextFactory";
String urlPkg="org.jboss.naming:org.jnp.interfaces";
Properties properties = null;
Context ctx=null;
try
{
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
properties.put(Context.PROVIDER_URL, url);
properties.put(Context.URL_PKG_PREFIXES, urlPkg);
ctx=new InitialContext(properties);
}
catch(Exception e)
{
System.out.println("...");
throw e;
}