关于EJB实体的问题
我在JBOSS中已经布署好了一个JAR文件,在已经启动的JBOSS中可以查到
+- ItemRmoteImpl (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy71 implements interface com.ccitsoft.remote.ItemRemote,interface org.jboss.ejb3.JBossProxy)
但是,我运行测试类,服务器端会有这样的输出提示错误,请看代码:
javax.naming.NameNotFoundException: ItemRemoteImpl not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
测试类如下:
package com.ccitsoft.client;
import javax.naming.InitialContext;
import
javax.naming.NamingException;
import com.ccitsoft.entity.Item;
import com.ccitsoft.entity.Order;
import com.ccitsoft.remote.ItemRemote;
public class Test {
public static void main(String[] args) {
try {
InitialContext ic = new InitialContext();
ItemRemote ir = (ItemRemote) ic.lookup("ItemRemoteImpl/remote");
Item item = new Item();
item.setName("notebook");
item.setType("dianqi");
item.setPrice(10000);
Order o1 = new Order();
o1.setIdnum("kb951748");
o1.setOrderby("microsoft");
Order o2 = new Order();
o2.setIdnum("kb951749");
o2.setOrderby("sun");
Order o3 = new Order();
o3.setIdnum("kb951750");
o3.setOrderby("orcal");
item.getOrderList().add(o1);
item.getOrderList().add(o2);
item.getOrderList().add(o3);
o1.setItem(item);
o2.setItem(item);
o3.setItem(item);
ir.newItem(item);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
------解决方案--------------------没有在JNDI上注册名字
------解决方案--------------------先要看一下EJB接口类,会话Bean有问题http://blog.csdn.net/tfnew21