可能是你的jndi的环境设置有错。
解决方案 »
- jsp中如何对对foreach进行循环,itmes要怎么写才行
- 求救(急):java poi导出word 如何设置word模式为页面视图
- SSH框架保存时报MultipleHiLoPerTableGenerator:176 - could not read or init a hi value
- 关于审核的不通过的情况 求思路
- struts2 启动tomcat 报错!The ResourceConfig instance does not contain any root resour
- 求助!!!玩过分布式数据库的专家,请指点数据库连接池的方法如何配置数据源
- 怎样在dos命令地运行一个,java应用程序,这个应用程序调用已写好的ejb? 在线等?
- 怎样提高lucence搜索精度?
- 请问如何用Java来实现趋势图和饼图?给200分
- 一个关于EJBde问题
- 关于调用EJB的疑问?
- 急!编译EJB时候出错。
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "192.168.0.133:1099");
props.put("java.naming.rmi.security.manager", "yes");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
Context context = new InitialContext(props);
这是jboss3.0.0jndi的初始化,还有你必须把,它的一个clinet的jar放到
tomcat的classpath中。
参考上面的代码,检查自己的代码。
<%!
private Converter converter = null; public void jspInit() {
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:comp/env/ejb/TheConverter");
ConverterHome home = (ConverterHome)PortableRemoteObject.narrow(objRef, ConverterHome.class);
converter = home.create();
} catch (RemoteException ex) {
System.out.println("Couldn't create converter bean."+ ex.getMessage());
} catch (CreateException ex) {
System.out.println("Couldn't create converter bean."+ ex.getMessage());
} catch (NamingException ex) {
System.out.println("Unable to lookup home: "+ "TheConverter "+ ex.getMessage());
}
} public void jspDestroy() {
converter = null;
}
%>
<html>
<head>
<title>Converter</title>
</head><body bgcolor="white">
<h1><b><center>Converter</center></b></h1>
<hr>
<p>Enter an amount to convert:</p>
<form method="get">
<input type="text" name="amount" size="25">
<br>
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form><%
String amount = request.getParameter("amount");
if ( amount != null && amount.length() > 0 ) {
BigDecimal d = new BigDecimal (amount);
%>
<p>
<%= amount %> dollars are <%= converter.dollarToYen(d) %> Yen.
<p>
<%= amount %> Yen are <%= converter.yenToEuro(d) %> Euro.
<%
}
%></body>
</html>