如果不介意,把你的代码作些简化(能出现故障),贴出来或发邮件,让大家看看,
我用的是jboss3+jb9
没出现你所说的不稳定现象
倒没试过jboss4

解决方案 »

  1.   

    1、远程接口
    package ejbjboss;import javax.ejb.*;
    import java.util.*;
    import java.rmi.*;public interface Enterprise1 extends javax.ejb.EJBObject {
      public void getMessage(String msg) throws RemoteException;
    }2、bean类package ejbjboss;import javax.ejb.*;public class Enterprise1Bean implements SessionBean {
      SessionContext sessionContext;
      public void ejbCreate() throws CreateException {
        /**@todo Complete this method*/
      }
      public void ejbRemove() {
        /**@todo Complete this method*/
      }
      public void ejbActivate() {
        /**@todo Complete this method*/
      }
      public void ejbPassivate() {
        /**@todo Complete this method*/
      }
      public void setSessionContext(SessionContext sessionContext) {
        this.sessionContext = sessionContext;
      }
      public void getMessage(String msg) {
        /**@todo Complete this method*/
         System.err.println(msg);
      }
    }
    3、home接口
     package ejbjboss;import javax.ejb.*;
    import java.util.*;
    import java.rmi.*;public interface Enterprise1Home extends javax.ejb.EJBHome {
      public Enterprise1 create() throws CreateException, RemoteException;
    }
      

  2.   

    该session bean(stateless) 编译、配置都没问题,在jbuilder9 配置成功,测试没问题;可下次再在jbuilder启动jboss server,再用原来的测试程序,测试就有如上的错误;这时如果再重新“redeploy”一下,再测又好了,太怪了???4、测试程序
    package ejbjboss;import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    public class Enterprise1TestClient1 extends Object {
      private static final String ERROR_NULL_REMOTE = "Remote interface reference is null.  It must be created by calling one of the Home interface methods first.";
      private static final int MAX_OUTPUT_LINE_LENGTH = 100;
      private boolean logging = true;
      private Enterprise1Home enterprise1Home = null;
      private Enterprise1 enterprise1 = null;  //Construct the EJB test client
      public Enterprise1TestClient1() {
        initialize();
      }  public void initialize() {
        long startTime = 0;
        if (logging) {
          log("Initializing bean access.");
          startTime = System.currentTimeMillis();
        }    try {
          //get naming context      java.util.Hashtable JNDIParm = new java.util.Hashtable();
          JNDIParm.put(Context.PROVIDER_URL, "localhost:1099");
          JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");      Context context = new InitialContext(JNDIParm);
          //look up jndi name
          Object ref = context.lookup("Enterprise1");
          //look up jndi name and cast to Home interface
          enterprise1Home = (Enterprise1Home) PortableRemoteObject.narrow(ref, Enterprise1Home.class);
          if (logging) {
            long endTime = System.currentTimeMillis();
            log("Succeeded initializing local bean access through Local Home interface.");
            log("Execution time: " + (endTime - startTime) + " ms.");
          }
        }
        catch(Exception e) {
          if (logging) {
            log("Failed initializing bean access.");
          }
          e.printStackTrace();
        }
      }  //----------------------------------------------------------------------------
      // Methods that use Home interface methods to generate a Remote interface reference
      //----------------------------------------------------------------------------  public Enterprise1 create() {
        long startTime = 0;
        if (logging) {
          log("Calling create()");
          startTime = System.currentTimeMillis();
        }
        try {
          enterprise1 = enterprise1Home.create();
          if (logging) {
            long endTime = System.currentTimeMillis();
            log("Succeeded: create()");
            log("Execution time: " + (endTime - startTime) + " ms.");
          }
        }
        catch(Exception e) {
          if (logging) {
            log("Failed: create()");
          }
          e.printStackTrace();
        }    if (logging) {
          log("Return value from create(): " + enterprise1 + ".");
        }
        return enterprise1;
      }  public void executeRemoteCallsWithDefaultArguments() {
        if (enterprise1 == null) {
          System.out.println("Error in executeRemoteCallsWithDefaultArguments(): " + ERROR_NULL_REMOTE);
          return ;
        }
      }  //----------------------------------------------------------------------------
      // Utility Methods
      //----------------------------------------------------------------------------  private void log(String message) {
        if (message == null) {
          System.out.println("-- null");
          return ;
        }
        if (message.length() > MAX_OUTPUT_LINE_LENGTH) {
          System.out.println("-- " + message.substring(0, MAX_OUTPUT_LINE_LENGTH) + " ...");
        }
        else {
          System.out.println("-- " + message);
        }
      }
      //Main method  public static void main(String[] args) {
        Enterprise1TestClient1 client = new Enterprise1TestClient1();
        // Use the client object to call one of the Home interface wrappers
        // above, to create a Remote interface reference to the bean.
        // If the return value is of the Remote interface type, you can use it
        // to access the remote interface methods.  You can also just use the
        // client object to call the Remote interface wrappers.
       Enterprise1 enterprise=client.create();
       try{
          enterprise.getMessage("您好Jboss");
          }catch(java.rmi.RemoteException e ){
              e.printStackTrace();
          }
      }
    }
      

  3.   

    ^_^,你的代码应该没有错,如果错了在jbuilder下就不会成功。可能是你的操作步骤不正确。
      

  4.   

    看看你的培植文件好了,里面的jndi名字和你代码中的不一样
      

  5.   

    我觉得是jboss的bug吧,下载一个稳定版本的jboss用吧。
      

  6.   

    jbuilder is too complex,please use notepad+ant