确认你的Context属性(Context.INITIAL_CONTEXT_FACTORY和Context.PROVIDER_URL)
设置正确
确认JBOSS启动了1099端口监听,而且是配合jnp协议?

解决方案 »

  1.   

    Context.INITIAL_CONTEXT_FACTORY和Context.PROVIDER_URL在jboss集成的tomcat里运行就没有问题,Context.INITIAL_CONTEXT_FACTORY应该设置没错,然后我又是调用的本机的jboss-ejb,Context.PROVIDER_URL也应该这样设置吧。
    jboss已经启动了,我用netstat查看1099端口已经建立了监听,你说的配合jnp协议,具体怎么配置呀?
      

  2.   

    独立的tomcat,他和jboss不在同一个jvm进程内,那么就不能用local接口,而应当用remote接口
      

  3.   

    我的Interest.class如下,他是实现了remote接口的,package org.jboss.docs.interest;import java.rmi.RemoteException;
    import javax.ejb.EJBObject;public interface Interest
        extends EJBObject
    {
            public abstract double calculateCompoundInterest(double d, double d1, double d2)
            throws RemoteException;
    }jboss-web.xml里内容是这样的:
    <?xml version="1.0" encoding="UTF-8"?><jboss-web>
        <ejb-ref>
            <ejb-ref-name>ejb/Interest</ejb-ref-name>
            <jndi-name>interest/Interest</jndi-name>
        </ejb-ref>
    </jboss-web>应该也是定义的一个remote接口吧,
    但我调用还是不行,我改用Object ref  = jndiContext.lookup("ejb/Interest");  又出现这个错误
    javax.naming.NameNotFoundException: Interest not bound
    org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
    org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
    org.jnp.server.NamingServer.getObject(NamingServer.java:509)
    org.jnp.server.NamingServer.lookup(NamingServer.java:282)
    org.jnp.server.NamingServer.lookup(NamingServer.java:256)   还望牛人们帮忙指点指点出现这种错误是什么原因呀。
      

  4.   

    解决了,借助JNDIViewer ,找到jndi名,用Object ref  = jndiContext.lookup("interest/Interest");
    就成功了。谢谢大家的帮助呀,