如果不介意,把你的代码作些简化(能出现故障),贴出来或发邮件,让大家看看,
我用的是jboss3+jb9
没出现你所说的不稳定现象
倒没试过jboss4
我用的是jboss3+jb9
没出现你所说的不稳定现象
倒没试过jboss4
解决方案 »
- weblogic 10g 管理控制器 域结构树为空~
- java 核心机制是什么?
- 本机测试正常。上传到服务器,启动出现错误。求助哇
- struts+hibernate
- xfire和spring2.0不兼容?
- struts如何向hibernate提交数据
- 关于spring的一点问题,请高手帮忙解决
- Weblogic 10 部署 AXIS2 1.6.2
- 实体bean之间的关系描述符中的cmr field 是如何实现两个表之间的关系的!高分相送!
- java菜鸟实习对于为什么Service 和dao 要这样设计理解不是很透彻,希望有大神可以指导一下这样设计的好处,尽量讲的详细一点
- 使用j2sdkee1.3的错误?
- SOS!BMP的findAll()问题.
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;
}
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();
}
}
}