问题配置JBoss使用JNDI [英] problem configure JBoss to work with JNDI

查看:111
本文介绍了问题配置JBoss使用JNDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的JBoss上运行的应用程序中使用JNDI绑定到数据库的连接。我做了以下事情:

I am trying to bind connection to the DB using JNDI in my application that runs on JBoss. I did the following:


  1. 我创建了数据源文件 oracle-ds.xml 用相关的xml填充它要素:

  1. I created the datasource file oracle-ds.xml filled it with the relevant xml elements:




<datasources>
   <local-tx-datasource>
     <jndi-name>bilby</jndi-name>
     ...
    </local-tx-datasource>
</datasources>


并将其放在文件夹\server\default中\\ deploy

and put it in the folder \server\default\deploy


  1. 添加了相关的oracle jar文件

  1. Added the relevant oracle jar file

比我在我的申请表中所做的那样:

than in my application I performed:




JndiObjectFactoryBean factory = new
JndiObjectFactoryBean();

JndiObjectFactoryBean factory = new JndiObjectFactoryBean();

 factory.setJndiName("bilby");
 try{
     factory.afterPropertiesSet();
     dataSource = factory.getObject();
 }
 catch(NamingException ne) {
     ne.printStackTrace();
 }


这导致错误:

javax.naming.NameNotFoundException:
bilby未结合

javax.naming.NameNotFoundException: bilby not bound

然后在输出发生此错误后我看到了这一行:

then in the output after this error occured I saw the line:


18: 37:56560 INFO
[ConnectionFactoryBindingService]
结合的ConnectionManager 'JB
oss.jca:服务= DataSourceBinding,名字= bilby'
键JNDI名称的Java:bilby'

18:37:56,560 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb oss.jca:service=DataSourceBinding,name=bilby' to JNDI name 'java:bilby'

那么我的配置问题是什么?我认为可能是JBoss首先加载并运行我的应用程序的.war文件,然后才加载包含我的数据源定义的oracle-ds.xml。
问题是它们都位于同一个文件夹中。
有没有办法定义加载它们的优先级,或者这根本不是问题。

So what is my configuration problem? I think that it may be that JBoss first loads and runs the .war file of my application and only then it loads the oracle-ds.xml that contain my data-source definition. The problem is that they are both located in the same folder. Is there a way to define priority of loading them, or maybe this is not the problem at all.

有什么想法吗?

推荐答案

你应该使用这种结构来调用Datasource:java:bilby。

You should use such construction to call Datasource: java:bilby.

您可以在此处详细了解:

You can read more about that here:

命名和目录(JNDI) - JBOSS jndi数据源:jdbc未绑定

这篇关于问题配置JBoss使用JNDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆