我在Eclipse 写了个简单的ejb3.0 sessionBean Stateless.部署到jboss4.2.2.GA 出现not bound问题.是jboss的要有什么设置吗?具体代码如下
1.
package beans.fortunetelling.remotelocal;import javax.ejb.Remote;@Remote
public interface FortuneTellingRemote {
public String getResult( String yourName );
}2.
package beans.fortunetelling.remotelocal;import javax.ejb.Local;@Local
public interface FortuneTellingLocal {
public String getResult( String yourName );
}3.
package beans.fortunetelling.remotelocal;import javax.ejb.Stateless;
import javax.ejb.Local;
import javax.ejb.Remote;
import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.annotation.ejb.RemoteBinding;
@Stateless
@Local({FortuneTellingLocal.class})
@LocalBinding(jndiBinding="FortuneTelling/Local")@Remote({FortuneTellingRemote.class})
@RemoteBinding(jndiBinding="FortuneTelling/Remote")public class FortuneTelling implements FortuneTellingLocal,
FortuneTellingRemote {
private int count = 0; public String getResult(String yourName) {
System.out.println("开始骗人");
this.count++;
System.out.println("有个叫" + yourName + "的家伙上当了。");
System.out.println("共有" + this.count + "个傻冒中咱招了。");
return yourName + ",好名字!皇帝命呐...";
}
}4.
package beans.fortunetelling.cheat;import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import beans.fortunetelling.remotelocal.*;
import java.util.Properties;
public class Cheat { /**
 * @param args
 */
public String toCheat(String name){
//  取得服务器的上下文
InitialContext ctx;
try{
ctx = getInitialContext();

System.out.println("FortuneTelling/Remote");
FortuneTellingRemote ftr = (FortuneTellingRemote) ctx.lookup("FortuneTelling/Remote");
String result = ftr.getResult(name); System.out.println(result);
return result;
}catch(Exception e)
{
return e.getMessage();
}
}
public static InitialContext getInitialContext() throws NamingException{ 
Properties   prop   =   new   Properties(); 
// 下面是JBOSS的JNDI上下文 
prop.put(Context.INITIAL_CONTEXT_FACTORY,   "org.jnp.interfaces.NamingContextFactory"); 
prop.put(Context.URL_PKG_PREFIXES,   "org.jboss.naming:org.jnp.interfaces"); 
prop.put(Context.PROVIDER_URL,   "jnp://localhost:1099"); 
return   new   InitialContext(prop); 
}}5.在jsp中调用Cheat中的toCheat方法谢谢大家指教