请教,一个怪异的EJB3问题

08-09-04 pushboy
EJB接口:
public interface IBackServiceBean
{
public boolean backMsgBySync(Map msgMap);
}

Remote接口:
@Remote
@Clustered
public interface IBackServiceBeanRemote extends IBackServiceBean
{
}

集群接口:
public @interface Clustered
{
Class loadBalancePolicy() default RoundRobin.class;
String partition() default "test";
}

Bean:
@Stateless
@Clustered
public class BackServiceBean implements IBackServiceBeanRemote
{
public boolean backMsgBySync(Map msgMap)
{
......
}
}

部署在JBoss4.2.3中,从控制台上面看到有以下JNDI
+- BackServiceBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy72 implements interface com.a8.service.back.ejb.IBackServiceBeanRemote,interface org.jboss.ejb3.JBossProxy)
日志中有:
2008-09-04 09:33:46,484 INFO [org.jboss.ejb3.EJBContainer] STARTED EJB: com.service.back.ejb.BackServiceBean ejbName: BackServiceBean

jndi.properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=jboss.naming:org.jnp.interfaces
jnp.partitionName=test

客户端调用:
public class EjbServiceImpl implements IEjbService
{
private static final String EJBNAME = "BackServiceBean/remote";

private void init()
{
try
{
Properties prop = new Properties();
ctx = new InitialContext(prop);
IBackServiceBean iback = (IBackServiceBean) ctx.lookup(EJBNAME);
}
......
}
}

报错:
javax.naming.NameNotFoundException: BackServiceBean/remote
at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:223)
at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

找不到这个EJB接口,请问什么原因啊
我觉得没写错啊,烦死了
谢谢

xmuzyu
2008-09-04 13:43
Context.INITIAL_CONTEXT_FACTORY=org.jnp.interfaces.NamingContextFactory
Context.URL_PKG_PREFIXES=org.jboss.naming
Context.PROVIDER_URL= localhost:1099

这样试试。我是这样做的,1099你没改过的话,就应该是。

pushboy
2008-09-04 15:08
不是这个问题
我之前已经这样试过了
现在的问题是看得到但是调不到接口

banq
2008-09-04 16:57
还是JNDI名称不对,要在Jmx-console下service=JNDIView , Output JNDI info as text的Invoke中看,包括包的名词也要写。

pushboy
2008-09-04 17:15
+- BackServiceBean
| +- remote (proxy: $Proxy72 implements interface com.service.back.ejb.IBackServiceBeanRemote,interface org.jboss.ejb3.JBossProxy)

这个就是在Jmx-console下service=JNDIView , Output JNDI info as text的Invoke中看到的东西

banq的意思是客户端调用中
private static final String EJBNAME = "BackServiceBean/remote";
要写成
private static final String EJBNAME = "com.service.back.ejb.BackServiceBean/remote"; ?

这样也不对,依然报错:
javax.naming.NameNotFoundException: com.a8.service.back.ejb.BackServiceBean/remote
at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:223)
at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:134)
at sun.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.ha.framework.server.HARMIServerImpl.invoke(HARMIServerImpl.java:194)

昨天搞到今天,快疯了:-(

xrmeng
2008-09-08 19:26
包,打成ABC.EAR的时候,找:

ABC/BackServiceBean/remote

为什么的控制台里没有包名...没打包?

tom01
2008-10-24 15:41
客户端调用
IBackServiceBean iback = (IBackServiceBean) ctx.lookup(EJBNAME);
改成
IBackServiceBeanRemote iback = (IBackServiceBeanRemote) ctx.lookup(EJBNAME);
试试