发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 CQRS 扩展性 并发编程 事件溯源 分布式 SOA

jboss-4.0.2下部署Duke's bank出现数据库连接的错误(内详),捆饶了我很久了,希望斑竹能帮忙看一看

2005-08-06 21:17
赞助商链接

版本jboss-4.0.2,
1、编译duke bank如下
ant -f jboss-build.xml package-ejb
prepare:

compile:
[javac] Compiling 63 source files to F:\j2eetutorial14\examples\bank\build
[jrc] Compiling 2 report design files.
[jrc] log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
[jrc] log4j:WARN Please initialize the log4j system properly.
[jrc] File : F:\j2eetutorial14\examples\bank\web\reports\BankStatementReport.jrxml ... OK.
[jrc] File : F:\j2eetutorial14\examples\bank\web\reports\AccountHistoryReport.jrxml ... OK.
2、使用BMP方式,数据库采用自带的HSQL,修改hsqldb-ds.xml三处:
注释掉<connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url>
增加 <connection-url>jdbc:hsqldb:hsql://localhost:1701</connection-url>
注释掉<mbean code="org.jboss.jdbc.HypersonicDatabase"
name="jboss:service=Hypersonic,database=localDB">
<attribute name="Database">localDB</attribute>
<attribute name="InProcessMode">true</attribute>
</mbean>
增加 <mbean code="org.jboss.jdbc.HypersonicDatabase"
name="jboss:service=Hypersonic">
<attribute name="Port">1701</attribute>
<attribute name="Silent">true</attribute>
<attribute name="Database">default</attribute>
<attribute name="Trace">false</attribute>
<attribute name="No_system_exit">true</attribute>
</mbean>
注释掉<jndi-name>DefaultDS</jndi-name>
增加 <jndi-name>jdbc/BankDB</jndi-name>
3、启动jboss,只出现一个error
15:46:50,859 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- MBeans waiting for other MBeans ---
............
............
............
ObjectName: jboss:database=localDB,service=Hypersonic
State: NOTYETINSTALLED
Depends On Me:
jboss.jca:name=jdbc/BankDB,service=ManagedConnectionFactory


15:46:51,078 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
15:46:51,343 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
15:46:51,375 INFO [JkMain] Jk running ID=0 time=0/63 config=null
15:46:51,390 INFO [Server] JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)] Started in 21s:500ms
5、跑数据库教本没出现错误
F而且,从jmx-cosole中startDatabaseManager可以看到已经存在的数据表,用SQL语句也可以读出数据
6、部署JBossDukesBank.ear没有出现error
7、打开http://localhost:8080/bank/main,用200/j2ee登陆出现错误:
6:03:50,703 INFO [STDOUT] Debug: Creating bean manager.
6:03:51,281 INFO [STDOUT] Debug: CustomerControllerBean ejbCreate
6:03:51,328 INFO [STDOUT] Debug: AccountControllerBean ejbCreate
6:03:51,359 INFO [STDOUT] Debug: TxControllerBean ejbCreate
6:03:51,390 INFO [STDOUT] Debug: /main
6:03:51,406 INFO [STDOUT] Debug: Forwarding to template.
6:03:53,812 INFO [STDOUT] Debug: AccountControllerBean getAccountsOfCustomer
6:03:53,890 INFO [STDOUT] Debug: AccountBean setEntityContext
6:03:53,890 INFO [STDOUT] Debug: AccountBean ejbFindByCustomerId
6:03:53,890 INFO [STDOUT] Debug: AccountBean selectByCustomerId
6:03:53,890 INFO [STDOUT] Debug: AccountBean makeConnection
6:03:53,890 INFO [STDOUT] Debug: AccountBean unsetEntityContext
6:03:53,906 ERROR [LogInterceptor] EJBException in method: public abstract java.util.Collection com.sun.ebank.ejb.account.Acc
untHome.findByCustomerId(java.lang.String) throws javax.ejb.FinderException:
avax.ejb.EJBException: ejbFindByCustomerId Unable to connect to database. Could not dereference object
at com.sun.ebank.ejb.account.AccountBean.ejbFindByCustomerId(AccountBean.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.plugins.BMPPersistenceManager.callFinderMethod(BMPPersistenceManager.java:615)
at org.jboss.ejb.plugins.BMPPersistenceManager.findEntities(BMPPersistenceManager.java:320)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInterceptor.java:321)
.........
........
(错误是Unable to connect to database,源程序没有动过,连接数据库的为public static final String BANK_DATABASE = "java:comp/env/jdbc/BankDB";
我在hsqlds-ds中也将jndi-name改为jdbc/BankDB,为什么还是连接不上数据库。苦恼了很长时间,想必是自己那里配置的不对,劳驾高手指点。

2005-08-14 18:55

这里有个JNDI细节注意,
你在在hsqlds-ds中也将jndi-name改为jdbc/BankDB,那么直接调用应该是java:/jdbc/BankDB。

如果你希望以java:comp/env/jdbc/BankDB调用,这是一个JDNI reference,你要在调用者的配置配置java:comp/env/jdbc/BankDB";
和jdbc/BankDB的对应关系。

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系管理员 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com