上面那样完全可以,不过 exercise1RemoteHome = (Exercise1RemoteHome) PortableRemoteObject.narrow(ref, Exercise1RemoteHome.class);
就不需要了!
就不需要了!
解决方案 »
- MyEclipse启动刚配置tomcat报错
- Quartz定时器在linux下不能启动,在window 下正常
- java程序一启动,oracle占cpu100% 高分啊
- 问题:找不到对应的ACTION
- apache整合tomcat后重写路径问题
- 请问关于sql中char和java的转换问题
- 修女重出江湖
- 求解答Source not found for ApplicationFilterChain.internalDoFilter(S
- 关于Jni性能和内存使用,请教各位
- expected ROWID got NUMBER
- 用weblogic的服务器下,在浏览器显示excel是乱码,怎么配置??
- 请问:我想用java做一个“每天定时做某事的程序”应该怎么设计?
ctx.lookup("Exercise");
我已经试过啦
如果是远程接口,写法又不一样。
只要lookup 你的jnid名字即可 !!!
你的那个方法只是为了避免jndi名字重名采用的一种方法,如果确定没有重名,可以不用!楼主出错,不贴出出错信息,没有人知道你哪里的错误...
可能是你的ejb没有发布成功.也可能你的本地接口的问题..
假设有一个SwitchSQL实体Bean:
//SwitchSQLBean
import javax.ejb.*;
import javax.ejb.*;
public class SwitchSQLBean implements SessionBean {
SessionContext sessionContext;
java.lang.String originalSQL;
java.lang.String whereSQL;
java.lang.String[][] where = new String[9][9];
//java.lang.String switchedSQL;
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;
} /**get the value of the array where[i][j]*/
public java.lang.String getWhere(int i, int j) {
return null;
}
/**get the sql statement which has been modified by whereSQLS*/
/*public java.lang.String getSwitchedSQL(String originalSQL,String flagString) {
return originalSQL;
}*/ /**initaialize the array where[][]*/
public void initWhere() { } //get the position of the flagString such as '&1' in the originalString
public java.lang.Integer getIndex(String flagString) {
Integer index;
return null;
}
public java.lang.String getSwitchedSQL(String originalSQL,String flagString) {
return originalSQL;
}
public java.lang.String[][] getWhere() {
return where;
}
}//SwitchSQLLocal
import javax.ejb.*;
import java.util.*;public interface SwitchSQLLocal extends javax.ejb.EJBLocalObject {
public java.lang.String getSwitchedSQL(String originalSQL,String flagString) ;}//SwitchSQLLocalHome
import javax.ejb.*;
import java.util.*;
public interface SwitchSQLLocalHome extends javax.ejb.EJBLocalHome {
public SwitchSQLLocal create() throws CreateException;
}部署SwitchSQL的JNDI名字为:SwitchSQLLocal 则在调用它的Bean里面引用方式为:SwitchSQLLocalHome sqlHomeObject
SwitchSQLLocal sqlLocalObject;
sqlHomeObject = (SwitchSQLLocalHome)ctx.lookup("SwitchSQLLocal");
sqlLocalObject = sqlHomeObject.create();如果还有问题,可以发到我邮件:[email protected]