Topic: 郁闷,jboss连MySQL搞不定

  Print this page

1.郁闷,jboss连MySQL搞不定 Copy to clipboard
Posted by: daiwang
Posted on: 2003-11-13 12:02

各位大哥(虽然好多人年纪比我小),我周围的人都在弄.net,就我一个在尝试j2ee,有些问题对于你们是小儿科,对于我就得郁闷几天,敬请各位帮忙带我上路。

我用xdoclet产生了以下两个文件:
ejb-jar.xml, jboss.xml. 部分内容如下:
<ejb-jar >
......
<enterprise-beans>
<entity >
<ejb-name>EnglishAuction</ejb-name>
<home>test.auction.interfaces.EnglishAuctionHome</home>
<remote>test.auction.interfaces.EnglishAuction</remote>
<local-home>test.auction.interfaces.EnglishAuctionLocalHome</local-home>
<local>test.auction.interfaces.EnglishAuctionLocal</local>

<ejb-class>test.auction.model.EnglishAuctionBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<primkey-field>id</primkey-field>

<ejb-local-ref >
<ejb-ref-name>item</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>test.auction.interfaces.ItemLocalHome</local-home>
<local>test.auction.interfaces.ItemLocal</local>
<ejb-link>Item</ejb-link>
</ejb-local-ref>

<resource-ref >
<res-ref-name>jdbc/auctionSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

</entity>
......
</ejb-jar>

<jboss>
<enterprise-beans>
<entity>
<ejb-name>EnglishAuction</ejb-name>
<jndi-name>ejb/test/EnglishAuction</jndi-name>
<local-jndi-name>EnglishAuctionLocal</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/auctionSource</res-ref-name>
<jndi-name>auctionSource</jndi-name>
</resource-ref>
</entity>
......
</enterprise-bean>
......
</jboss>

我在deploy目录下放了mysql-ds.xml文件,内容如下:
<datasources>
  <local-tx-datasource>
    <jndi-name>auctionSource</jndi-name>
    <connection-url>jdbc:mysql://202.121.218.82:3306/test</connection-url>
    <driver-class>org.gjt.mm.mysql.Driver</driver-class>
    <user-name>root</user-name>
    <password>admin</password>    
  </local-tx-datasource>
</datasources>

在lib目录下放了mysql-connector-java-3.0.9-stable-bin.jar

然后我调试程序,DataSource source =
(DataSource)initCtx.lookup("java:comp/env/jdbc/auctionSource");控制台显示信息如下:
auctionSource not bound
我查了一下, nameException的信息是:
could not dereference object.
所有的系统我都重启过,上面的信息我实在弄不懂。

我查了http://localhost:8080/jmx-console/index.jsp,看到以下条目:
jboss.jca
* name=DefaultDS,service=LocalTxCM
* name=DefaultDS,service=ManagedConnectionFactory
* name=DefaultDS,service=ManagedConnectionPool
* name=JBoss JDBC XATransaction ResourceAdapter,service=RARDeployment
* name=JBoss LocalTransaction JDBC Wrapper,service=RARDeployment
* name=JMS Adapter,service=RARDeployment
* name=JmsXA,service=ManagedConnectionFactory
* name=JmsXA,service=ManagedConnectionPool
* name=JmsXA,service=TxCM
* name=auctionSource,service=LocalTxCM
* name=auctionSource,service=ManagedConnectionFactory
* name=auctionSource,service=ManagedConnectionPool
* service=CachedConnectionManager
* service=ConnectionFactoryDeployer
* service=RARDeployer

我一头雾水。

2.Re:郁闷,jboss连MySQL搞不定 [Re: daiwang] Copy to clipboard
Posted by: daiwang
Posted on: 2003-11-14 11:56

查了一下文档目录下的dtd,将jboss.xml改为:
<jboss>
<enterprise-beans>
<entity>
<ejb-name>EnglishAuction</ejb-name>
<jndi-name>ejb/test/EnglishAuction</jndi-name>
<local-jndi-name>EnglishAuctionLocal</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/auctionSource</res-ref-name>
<jndi-name>java:/auctionSource</jndi-name>
</resource-ref>
</entity>
......
</enterprise-bean>
......
</jboss>
问题解决了,原因在于datasource的jndi名被jboss自动加上java:/前缀。

痛苦的哼一声,我什么时候才能捞到一分,好让我看看ftp上的jboss文档。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923