偶也是菜鸟一只,不知道说得对不对:在InitailContext中需要放入一些参数,因为你的程序不是直接用在jsp页面里面的,如在weblogic中
Hashtable env=new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://localhost:80")
ctx=new InitailContext(env);这之后才能从ctx中取得所要的数据
Hashtable env=new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://localhost:80")
ctx=new InitailContext(env);这之后才能从ctx中取得所要的数据
解决方案 »
- 关于Eclipse开发WEB项目的问题(求指教)
- 我们爱分享-jfreechart官方demo
- getHibernateTemplate().save(ad)奇怪情况,无语了。
- 关于System.out.print的性能问题
- java.net.SocketTimeoutException: Read timed out
- applet问题
- 关于在hibernate中更新数据的问题。
- apache怎么配置可以只输入http://192.168.0.1就可以访问到我的首页?
- 在程序中用jdbc的一个问题
- 怎样清除内存里面指定的内容
- 字符串的替换问题, 请帮忙!
- 年初到杭州比较大的一家软件公司实习,请个位前辈指教!!
{ public static void main(String[] args)
{
try
{
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://happy:7001"); InitialContext ic = new InitialContext(p);
//InitialContext ic = new InitialContext(); Object lookup = ic.lookup("beanjndi");
TestHome home = (TestHome)PortableRemoteObject.narrow(lookup, TestHome.class);
TestObj bean1 = home.create();
System.out.println(bean1.getTotal(new double[]{10,20,30})); TestObj bean2 = home.create();
System.out.println(bean2.getTotal(new double[]{34,56,78})); TestObj bean3 = home.create();
System.out.println(bean3.getTotal(new double[]{12.34,56.78,90.12})); System.out.println(bean3.getName("6380"));
System.out.println(bean3.getEnv());
}
catch (Exception err)
{
System.out.println(err.getMessage());
}
}
}
不是WEBLOGIC,就是j2ee1.3我想也是部署之后的问题,应该还有一步没做???
就是不知道是哪一步???请高手指点
Object objref = initial.lookup
("java:comp/env/ejb/SimpleConverter"); ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(objref,
ConverterHome.class); Converter currencyConverter = home.create();
当客户端ConverterClient调用lookup方法,它传递企业Bean的Home接口的引用绑定名字给方法:
Object objref = myEnv.lookup("ejb/SimpleConverter");
设置该引用名字的步骤如下:
1. 在deploytool工具左边的树视图中选择ConverterClient节点
2. 选择右边的EJB Refs选项页
3. 点击Add按钮
4. 在Coded Name列输入ejb/SimpleConverter
5. 在Type列选择Session
6. 在Interfaces列选择Remote
7. 在Home Interface列输入ConverterHome
8. 在Local/Remote Interface列输入Converter
以下步骤建立引用名和JNDI名的映射:
1. 在树视图中选择ConverterApp节点
2. 选择JNDI Name选项页
3. 在Application表格中选中ConverterEJB组件,在JNDI Name列中输入MyConverter作为ConverterEJB的JNDI名
4. 在References表格中每一行的JNDI Name列中都输入上面的JNDI名
[email protected]