JBoss中的Bank例子运行出错了?

abue 2004-10-28 11:31:23
AccountBean部分源码:
private void makeConnection() {
Debug.print("AccountBean makeConnection");

try {
InitialContext ic = new InitialContext();
System.out.println("Before calling lookup()");
DataSource ds = (DataSource) ic.lookup(CodedNames.BANK_DATABASE);
//BANK_DATABASE = "java:comp/env/jdbc/BankDB"

System.out.println("Before connecting");
con = ds.getConnection();
} catch(NamingException nex)
{
Debug.print("NamingException "+nex.getMessage());

} catch (Exception ex) {
throw new EJBException("Unable to connect to database. " +
ex.getMessage());
}
}
ejb-jar.xml部分内容:
<session>
<ejb-name>AccountControllerBean</ejb-name>
<home>com.sun.ebank.ejb.account.AccountControllerHome</home>
<remote>com.sun.ebank.ejb.account.AccountController</remote>
<ejb-class>com.sun.ebank.ejb.account.AccountControllerBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Bean</transaction-type>
<ejb-local-ref>
<ejb-ref-name>ejb/customer</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.sun.ebank.ejb.customer.CustomerHome</local-home>
<local>com.sun.ebank.ejb.customer.Customer</local>
<ejb-link>CustomerBean</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>ejb/account</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.sun.ebank.ejb.account.AccountHome</local-home>
<local>com.sun.ebank.ejb.account.Account</local>
<ejb-link>AccountBean</ejb-link>
</ejb-local-ref>
<resource-ref>
<res-ref-name>jdbc/BankDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<security-identity>
<use-caller-identity/>
</security-identity>
</session>
当输入用户名200密码j2ee时
异常发生
2004-10-28 10:36:04,500 INFO [STDOUT] Before calling lookup()
2004-10-28 10:36:04,500 INFO [STDOUT] Debug: NamingException Could not dereference object
2004-10-28 10:36:04,531 ERROR [org.jboss.ejb.plugins.LogInterceptor] EJBException in method: public abstract java.util.Collection com.sun.ebank.ejb.account.AccountHome.findByCustomerId(java.lang.String) throws javax.ejb.FinderException:
根据日志问题应该是出现在lookup上了,看了一下tomcat启动日志发现
2004-10-28 10:33:07,843 INFO [org.apache.catalina.startup.Embedded] Catalina naming disabled
2004-10-28 10:33:09,640 INFO [org.apache.catalina.core.StandardHost] XML validation disabled
和这有关系吗
有经验的朋友帮我看看 3u
...全文
61 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
abue 2004-10-28
  • 打赏
  • 举报
回复
Could not dereference object
是什么意思咧?
abue 2004-10-28
  • 打赏
  • 举报
回复
我也试过了,还是不成
Tabalulu 2004-10-28
  • 打赏
  • 举报
回复
在jboss中,数据源名没有前缀的,直接用BankDB吧

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧