Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Application Server » JBoss  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 配置jboss与ORACLE的DATASOURCE ?
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-09-05 15:46 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1。安装jdk1.41和jboss-3.2.1_tomcat-4.1.24
2。启动RUN.BAT,服务器启动,访问http://localhost:8080/jmx-console出现页面证明JBOSS好使
3。配置C:\jboss-3.2.1_tomcat-4.1.24\server\default\deploy\oracle-ds.xml
内容:
<datasources>
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@192.168.0.28:1521:home</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>police</user-name>
<password>police</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</local-tx-datasource>

</datasources>


并且修改transaction-service.xml文件:


<!-- The configurable Xid factory. For use with Oracle, set pad to true -->
<mbean code="org.jboss.tm.XidFactory"
   name="jboss:service=XidFactory">
<!--attribute name="Pad">true</attribute-->
<attribute name="Pad">true</attribute>
</mbean>


4.拷贝classes12.zip 到server/default/lib 下,重新启动JBOSS

5。做测试程序
测试程序可以是JSP、SERVLET、SESSION BEAN 但不能是CLIENT程序


jameszhang edited on 2004-09-06 18:27

"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:配置jbos的DATASOURCE ? [Re:jameszhang]
linux_china



版主


发贴: 752
积分: 240
于 2004-09-05 16:03 user profilesend a private message to usersend email to linux_chinasearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
两点疑问:
1 你的测试代码是在jboss中运行还是客户端程序?如果是客户端程序,这样获取数据库连接肯定是不正确的。
2 test.getInitialContext()的代码是什么,如果连接到远程的jboss,肯定也是不行的。

数据库连接不同于EJB组件,客户端程序去引用数据库连接,肯定是不行的,这个连接池只能为容器所用。



作者 Re:配置jbos的DATASOURCE ? [Re:linux_china]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-09-05 19:20 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
linux_china wrote:
两点疑问:
1 你的测试代码是在jboss中运行还是客户端程序?如果是客户端程序,这样获取数据库连接肯定是不正确的。
2 test.getInitialContext()的代码是什么,如果连接到远程的jboss,肯定也是不行的。

数据库连接不同于EJB组件,客户端程序去引用数据库连接,肯定是不行的,这个连接池只能为容器所用。

先谢谢大象。我这个测试程序是客户端程序代码是

package testejb;

import javax.naming.*;
import java.util.Hashtable;
import javax.rmi.PortableRemoteObject;
import javax.ejb.EJBMetaData;
import javax.ejb.HomeHandle;
import javax.ejb.Handle;

public class MyTestClient
{
public MyTestClient()
{
}

private Context getInitialContext() throws NamingException
{
Hashtable environment = new Hashtable();

environment.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");

return new InitialContext(environment);
}

public static void main(String[] args)
{
MyTestClient test = new MyTestClient();
try
{
Context context = test.getInitialContext();
Object ref = context.lookup("java:/OracleDS");
java.sql.Connection con = ( (javax.sql.DataSource) ref).getConnection();

}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
}

}


我用他测试SESSION BEAN可以找到,但lookup DataSource却怎么也找不到,请大象帮忙呀!!Sad


jameszhang edited on 2004-09-05 19:34

"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:配置jbos的DATASOURCE ? [Re:jameszhang]
linux_china



版主


发贴: 752
积分: 240
于 2004-09-05 19:44 user profilesend a private message to usersend email to linux_chinasearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
客户端是不能使用容器的数据库连接池,这是不合法的。而且容器中的数据库连接不能传递客户端,有以下几个原因:
1 Connection未实现Serializable,也未实现Remote,如何传到客户端
2 数据库是基于Socket的,服务器端建立连接,是无法传给客户端的
3 即使以上信息是可以的,由于网络原因,同样客户端程序不可能访问数据库服务器的(防火墙),只允许应用服务器访问数据库服务器的。

所以不要试图通过客户端程序访问容器的数据库连接池,这不同于EJB组件,EJB组件是满足以上条件的。以上属于个人知识范畴,一家言。 Smile



作者 Re:配置jbos的DATASOURCE ? [Re:jameszhang]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-09-05 19:51 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Post is deleted

jameszhang edited on 2004-09-07 08:42

"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:配置jbos的DATASOURCE ? [Re:jameszhang]
linux_china



版主


发贴: 752
积分: 240
于 2004-09-05 20:05 user profilesend a private message to usersend email to linux_chinasearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这个配置文件没错啊,如果没有同jmx-console还未查到这个数据库连接,那你的检查是否将oracle驱动拷贝到server\default\lib目录下啦。其他我就不知道啦! Smile


作者 Re:配置jbos的DATASOURCE ? [Re:jameszhang]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-09-05 20:07 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
郁闷的说我把CLASSES12.ZIP拷到了server\default\lib目录下,郁闷Cry


"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:配置jbos的DATASOURCE ? [Re:linux_china]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-09-06 16:19 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
linux_china wrote:
客户端是不能使用容器的数据库连接池,这是不合法的。


我直接创建CMP,部署后

16:24:16,843 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss
-3.2.1_tomcat-4.1.24/server/default/deploy/MyEJB.jar
16:24:17,265 INFO [EjbModule] Creating
16:24:17,281 INFO [EjbModule] Deploying ZhLink
16:24:17,375 INFO [EjbModule] Deploying MySession
16:24:17,375 INFO [EntityContainer] Creating
16:24:17,390 INFO [EntityInstancePool] Creating
16:24:17,390 INFO [EntityInstancePool] Created
16:24:17,390 INFO [EntityContainer] Created
16:24:17,390 INFO [StatelessSessionContainer] Creating
16:24:17,390 INFO [StatelessSessionInstancePool] Creating
16:24:17,390 INFO [StatelessSessionInstancePool] Created
16:24:17,390 INFO [StatelessSessionContainer] Created
16:24:17,390 INFO [EjbModule] Created
16:24:17,390 INFO [EjbModule] Starting
16:24:17,390 INFO [EntityContainer] Starting
16:24:17,640 ERROR [EntityContainer] Starting failed
org.jboss.deployment.DeploymentException: Error: can't find data source: OracleD
S; - nested throwable: (javax.naming.NameNotFoundException: OracleDS not bound)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.<init>(JDBCEnt
ityBridge.java:115)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBC
StoreManager.java:438)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
r.java:372)



"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:配置jbos的DATASOURCE ? [Re:jameszhang]
linux_china



版主


发贴: 752
积分: 240
于 2004-09-06 16:31 user profilesend a private message to usersend email to linux_chinasearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是java:OracleDS吧? 使用jmx-console查看改资源是否绑定,只需查看该jndi名称是否存在即可!


作者 Re:配置jbos的DATASOURCE ? [Re:linux_china]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-09-06 18:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
linux_china wrote:
是java:OracleDS吧? 使用jmx-console查看改资源是否绑定,只需查看该jndi名称是否存在即可!

太感谢大象了,已经OK,我仔细的琢磨了你说的只能在服务器端用,真的只能在服务器端,CLINET 想引用JBOSS的CONNECT POOL 是不行的,但是在WLS中是可以的!



"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"


flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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