类似:/*
*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.math.BigDecimal;public class ConverterClient { public static void main(String[] args) {
try {
Context initial = new InitialContext();
Context myEnv = (Context)initial.lookup("java:comp/env");
Object objref = myEnv.lookup("ejb/SimpleConverter"); ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(objref,
ConverterHome.class); Converter currencyConverter = home.create(); BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount = currencyConverter.dollarToYen(param);
System.out.println(amount);
amount = currencyConverter.yenToEuro(param);
System.out.println(amount); System.exit(0); } catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}
*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.math.BigDecimal;public class ConverterClient { public static void main(String[] args) {
try {
Context initial = new InitialContext();
Context myEnv = (Context)initial.lookup("java:comp/env");
Object objref = myEnv.lookup("ejb/SimpleConverter"); ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(objref,
ConverterHome.class); Converter currencyConverter = home.create(); BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount = currencyConverter.dollarToYen(param);
System.out.println(amount);
amount = currencyConverter.yenToEuro(param);
System.out.println(amount); System.exit(0); } catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}
解决方案 »
- string.format日期
- 关于servlet和jsp页面交互的几个问题
- session取得
- 数据权限是基于角色还是用户?
- 现有一JAVA高级群,欢迎各位高手来技术交流(新人勿入)
- hibernate的save问题
- action里调spring配置的bean居然是null.
- 关于tomcat中调用JNI函数是否存在共享冲突的问题……
- 急!!!! webshpere 刷新问题 和 务器日志在那里???????
- System.setProperty("file.encoding", "ISO8859_1");是什么意思?
- jbuilder中ejb怎么是灰色的?
- 用(jb6+wl6.1)开发jsp+servlet+ejb的朋友能留下QQ交流交流
http://java.sun.com/j2ee
另外机子我就不会了
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;public class HelloClient { public HelloClient() {
}
public static void main(String[] args) {
try{
Properties props = System.getProperties(); props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.TengahInitialContextFactory");
props.put(javax.naming.Context.PROVIDER_URL,"t3://localhost:41766"); Context ctx = new InitialContext(props);
Object objref = ctx.lookup("Hello");//Lookup the JNDI name
HelloHome Home = (HelloHome)PortableRemoteObject.narrow(objref, HelloHome.class);
Hello hello = Home.create(); System.out.println(hello.hello());
hello.remove();
}catch(Exception e){
e.printStackTrace();
} }
}
我是这样写的,为什么会不行???
客户端代码(ConverterClient.java):
...
java.util.Hashtable properties = new java.util.Hashtable();
properties.put(Context.PROVIDER_URL, "http://192.168.0.111:9191/");
Context initial = new InitialContext( properties );
Object objref = initial.lookup("MyConverter") ...其中:chenshq 是EJB服务器所在的地址
9191 是监听端口
MyConverter 是在布署时给的JNDI的名字
我是指脱离了weblogic 就不行了啊,
java.lang.UnsupportedOperationException: Method setSessionContext() not yet implemented.
at weblogic.rmi.internal.AbstractOutboundRequest.sendReceive(AbstractOutboundRequest.java:90)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:247)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:225)
at com.tiptopone.user.player.online.HelloBeanEOImpl_WLStub.hello(HelloBeanEOImpl_WLStub.java:143)
at com.tiptopone.user.player.online.HelloClient.main(HelloClient.java:33)
是指哪个类的方法没有实现???
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo: Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbRemove() not yet implemented.");
}
里面的throw去掉的缘故,呵呵