同一个容器和不同容器的方法应该不一样吧,能介绍下吗,讲下大概用到的技术和原理就OK
解决方案 »
- 关于刷新网页的问题
- 如何生成dll依赖关系图
- 工作时遇到的问题
- tomcat报错:DBCP object created 2006-01-10 16:41:33 by the following code was never closed,是什么原因呀
- 求《Tomcat与Java Web开发技术详解》的随书光盘
- 没有响应啊~~ajax请求servlet~~就是请求不到servlet~
- 关于算术的奇怪问题
- AOP在SpringMVC的Controller里无效的问题
- 怎样才能最简单的解决jsp的中文问题呢
- 各位帮忙看看,拜托拉!
- 我这里有两个JAVABEAN的程序但无法编译请高人帮助
- 关于struts页面初始化赋值
如果都是java的也可以用ejb,rmi
我用了ejb3.0来实现
projectA中:CommandCalculate.class
package clientapp;
public interface CommandCalculate {
public void test();
}CommandCalculateRemote.class
package clientapp;
import javax.ejb.Remote;
@Remote
public interface CommandCalculateRemote extends CommandCalculate{
}CommandCalculateBean.class
package clientapp;
import javax.ejb.Stateless;
@Stateless
public class CommandCalculateBean implements CommandCalculateLocal,CommandCalculateRemote{
public void test(){
System.out.println("xxx");
}
}CommandCalculate.class和CommandCalculateRemote.class打成了jar导入了projectBprojectB中:try {
Properties props = System.getProperties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming");
props.put(Context.STATE_FACTORIES,"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.put(Context.PROVIDER_URL, "iiop://22.117.79.139:3700");
InitialContext ctx = new InitialContext(props);
System.out.println(CommandCalculateRemote.class.getName());
CommandCalculate cc = (CommandCalculate) ctx.lookup(CommandCalculateRemote.class.getName());
cc.test();
} catch (Exception e) {
e.printStackTrace();
}
本人用的glassfish,问题来了,本机(同一个容器中)测试通过,确实可以调到打印出"xxx",但projectB部署到另一台机器后就报出如下错误:
javax.naming.NameNotFoundException: com.jas.clientapp.CommandCalculateRemote not found
不知何解,赐教~~
对!!速度快加上缓存配置,速度根本不差,webservice多慢呀!那是一个方法级别的。如果不是,http就可以了返回JSON字符就可以数据通信了!
我用了ejb3.0来实现
projectA中: CommandCalculate.class
package clientapp;
public interface CommandCalculate {
public void test();
} CommandCalculateRemote.class
package clientapp;
import javax.ejb.Remote;
@Remote
public interface CommandCalculateRemote extends CommandCalculate{
} CommandCalculateBean.class
package clientapp;
import javax.ejb.Stateless;
@Stateless
public class CommandCalculateBean implements CommandCalculateLocal,CommandCalculateRemote{
public void test(){
System.out.println("xxx");
}
} CommandCalculate.class和CommandCalculateRemote.class打成了jar导入了projectB projectB中: try {
Properties props = System.getProperties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming");
props.put(Context.STATE_FACTORIES,"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.put(Context.PROVIDER_URL, "iiop://22.117.79.139:3700");
InitialContext ctx = new InitialContext(props);
System.out.println(CommandCalculateRemote.class.getName());
CommandCalculate cc = (CommandCalculate) ctx.lookup(CommandCalculateRemote.class.getName());
cc.test();
} catch (Exception e) {
e.printStackTrace();
}
本人用的glassfish,问题来了,本机(同一个容器中)测试通过,确实可以调到打印出"xxx",但projectB部署到另一台机器后就报出如下错误:
javax.naming.NameNotFoundException: com.jas.clientapp.CommandCalculateRemote not found
不知何解,赐教~~