学习EJB3遇到错误,进展不下去了,求高人指点~~
错误及代码如下:
EJBTest.jar 部署到jboss中,里面有 接口Hello,HelloBean
jboss里查看jndi为:
+- HelloBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy65 implements interface com.dj.ejb.Hello,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
在Eclipse中新建的另外一个项目中调用EJB
代码如下:
接口 Hello
客户端:public class HelloClient {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
Properties prop=new Properties();
FileInputStream is=new FileInputStream( "D:\\jndi.properties ");
prop.load(is);
Context ctx=new InitialContext(prop);
System.out.println(ctx.getEnvironment());
Hello hello=(Hello)ctx.lookup( "HelloBean/remote ");//这一行报错
System.out.println(hello.hello());
}
}
按照教程,ctx.lookup( "HelloBean/remote ");是正确的,可是我运行的时候出现错误:
Exception in thread "main "
java.lang.NoSuchFieldError: TRACE
at org.jboss.logging.Log4jLoggerPlugin.isTraceEnabled(Log4jLoggerPlugin.java:85)
at org.jboss.logging.Logger.isTraceEnabled(Logger.java:122)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:622)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.dj.ejb.HelloClient.main(HelloClient.java:23)
百思不得其解啊,望明白人给指点一下,不胜感激!
------解决方案--------------------