服务端有两个接口两个方法 分别是使用有状态Session Bean和无状态的 javax.ejb.NoSuchEJBException: No such EJB[appname=,modulename=EJB_T7,distinctname=,beanname=CartBean,viewclassname=com.yi.sessionful.Cart] at org.jboss.ejb.client.remoting.NoSuchEJBExceptionResponseHandler.processMessage(NoSuchEJBExceptionResponseHandler.java:64) at org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver.handleMessage(ChannelAssociation.java:395) at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:437) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Exception in thread "main" java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:EJB_T7,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@26aee at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) at org.jboss.ejb.client.EJBClientInvocationContext.retryRequest(EJBClientInvocationContext.java:206) at org.jboss.ejb.client.EJBReceiverInvocationContext.retryInvocation(EJBReceiverInvocationContext.java:95) at org.jboss.ejb.client.remoting.NoSuchEJBExceptionResponseHandler.processMessage(NoSuchEJBExceptionResponseHandler.java:78) at org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver.handleMessage(ChannelAssociation.java:395) at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:437) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) at ...asynchronous invocation...(Unknown Source) at org.jboss.ejb.client.remoting.NoSuchEJBExceptionResponseHandler$ResultProducer.getResult(NoSuchEJBExceptionResponseHandler.java:101) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270) at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272) at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260) at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140) at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) at $Proxy0.addProduct(Unknown Source) at com.yi.test.TestFul.main(TestFul.java:30) 调用的方法如下: final Properties jndiProperties = new Properties(); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(jndiProperties); final String appName = ""; //部署的jar文件的名字 final String moduleName = "EJB_T7"; final String distinctName = ""; //实现类的类名 final String beanName = CartBean.class.getSimpleName(); //接口类的全名 final String viewClassName = Cart.class.getName(); String lookupStr="ejb:"+appName+"/"+moduleName+"/"+distinctName+"/"+beanName+"!"+viewClassName; Cart cart = (Cart)context.lookup(lookupStr); //添加 cart.addProduct("one"); cart.addProduct("two"); //查询 System.out.println(cart.getProItem().size()); Cart接口及其CartBean如下: //向购物车中添加商品 public void addProduct(String proName); //显示商品列表 public List<String> getProItem(); //删除商品 public void removeProduct(String proName); //清空购物车 public void clearProduct(); private List<String> proList = new ArrayList<String>(); public void addProduct(String proName) { proList.add(proName); } public List<String> getProItem() { return proList; } public void removeProduct(String proName) { proList.remove(proName); } public void clearProduct() { proList.clear(); } jboss-ejb-client.properties配置文件如下: endpoint.name=client-endpoint remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false remote.connections=default remote.connection.default.host=localhost remote.connection.default.port=4447 remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false remote.connection.default.username=admin remote.connection.default.password=admin 求高手赐教…………….. |
|
String lookupStr=”ejb:”+appName+”/”+moduleName+”/”+distinctName+”/”+beanName+”!”+viewClassName
我从来没这么用过,你是怎么调用ejb的? 如果EJB 应用打包成后缀为*.jar 的发布文件, 默认的JNDI 路径名称是 如果EJB 打包进后缀为*.ear 的J2EE 发布文件,默认的JNDI 路径名称是 |
|
100分 |
是不是没导入 jboss-client.jar包啊
|
我用的是jboss7呀 哥哥 ,之前的版本我也会用啊。。 |
|
获取stateful(有状态):
String name=”ejb:” + appName + “/” + modelName + “/” + distinceName + “/” + beanName + “!” + inerfaceName+”?stateful”; 你没有写最后的stateful |