刚学Jboos用的是Myeclipse,刚写第一个程序就不会了。运行Jboos客户端是出现此异常,请问是我程序错了还是Jboss安的不对啊?
jndi.properties
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost
客户端程序:
package ejb01.client;import javax.naming.InitialContext;import cn.cnmis.ejb.FirstEJB;public class TestEJB {
public static void main(String[] args) throws Exception {
InitialContext context = new InitialContext();
FirstEJB fe = (FirstEJB)context.lookup("FirstEJBBean/remote");
System.out.println("--------"+fe.saySomething("你好,"));
}}
服务端程序:
package cn.cnmis.ejb;(接口)public interface FirstEJB {
public String saySomething(String word);
}package cn.cnmis.ejb;(实现)import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless
@Remote
public class FirstEJBBean implements FirstEJB { public String saySomething(String word) {
return "你好," + word;
}
}

解决方案 »

  1.   

    把jndi设置成如下试试:
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.provider.url=localhost\:1099
    java.naming.factory.url.pkgs=org.jboss.naming
      

  2.   

    刚试过,还是同样的异常
    Exception in thread "main" javax.naming.NameNotFoundException: FirstEJBBean not bound
      

  3.   

    好像根本就没有连接到EJB,服务器端没有异常抛出
      

  4.   

    你的ejb发布成功了,在jboss启动的时候有显示的,你看看有没有
      

  5.   

    你看看有没有发布
    --- Packages waiting for a deployer ---
    org.jboss.deployment.DeploymentInfo@7912d789 { url=file:/D:/java-tools/jboss-4.2.2.GA/server/default/deploy/testejb1.0 }
      deployer: null
      status: null
      state: INIT_WAITING_DEPLOYER
      watch: file:/D:/java-tools/jboss-4.2.2.GA/server/default/deploy/testejb1.0
      altDD: null
      lastDeployed: 1278508211638
      lastModified: 1278508211633
      mbeans:--- Incompletely deployed packages ---
    org.jboss.deployment.DeploymentInfo@7912d789 { url=file:/D:/java-tools/jboss-4.2.2.GA/server/default/deploy/testejb1.0 }
      deployer: null
      status: null
      state: INIT_WAITING_DEPLOYER
      watch: file:/D:/java-tools/jboss-4.2.2.GA/server/default/deploy/testejb1.0
      altDD: null
      lastDeployed: 1278508211638
      lastModified: 1278508211633
      mbeans:
    13:10:11,848 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
    13:10:11,893 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
    13:10:11,918 INFO  [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 30s:592ms
      

  6.   

    我用的是jboss5.1.0GA,可能有点不一样,但这个看来没有发布成功