oracle jboss 7 oracle数据源配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12049882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jboss 7 oracle datasource configuration
提问by user1066568
I'm currently migrating from jboss 4.3 to jboss 7.1.1 (Final) and i'm trying to configure an oracle datasource but it's not working. Following is what I've done to setup an oracle datasource
我目前正在从 jboss 4.3 迁移到 jboss 7.1.1(最终版),我正在尝试配置一个 oracle 数据源,但它不起作用。以下是我为设置 oracle 数据源所做的工作
1)Downloaded ojdbc6-11.jar and placed it inside the folder $JBOSS_HOME/modules/com/oracle/ojdbc6/main
1)下载ojdbc6-11.jar,放在$JBOSS_HOME/modules/com/oracle/ojdbc6/main文件夹内
2)Created the file module.xml under $JBOSS_HOME/modules/com/oracle/ojdbc6/main and this is the content of the file
2)在$JBOSS_HOME/modules/com/oracle/ojdbc6/main下创建module.xml文件,这是文件的内容
<module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
3)Added the following driver and datasource inside standalone.xml
3)在standalone.xml中添加了以下驱动和数据源
<drivers>
<driiver name="oracle" module="com.oracle.ojdbc6">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
</drivers>
<datasource jndi-name="java:/Altis" pool-name="Altis" enabled="true" use-java-context="true">
<connection-url>connurl</connection-url>
<driver>oracle</driver>
<security>
<user-name>username</user-name>
<password>passwd</password>
</security>
</datasource>
</datasources>
However, when I deploy my war file, i get the following error
但是,当我部署我的War文件时,我收到以下错误
16:54:43,281 INFO [org.jboss.as.server] (HttpManagementService-threads - 2) JBA
S015870: Deploy of deployment "altisavante.war" was rolled back with failure mes
sage {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.na
ming.context.java.module.altisavante.altisavante.env.Altisjboss.naming.context.j
ava.AltisMissing[jboss.naming.context.java.module.altisavante.altisavante.env.Al
tisjboss.naming.context.java.Altis]"]}
Am I missing anything?
我错过了什么吗?
回答by Teuctzintli
Here's a link about the data source configuration for JBoss 7 that of course work with 7.1
这是一个关于 JBoss 7 的数据源配置的链接,它当然适用于 7.1
https://community.jboss.org/wiki/DataSourceConfigurationInAS7
https://community.jboss.org/wiki/DataSourceConfigurationInAS7
The example is configuring a MySQL example.
This is what i did for an Oracle Driver
该示例正在配置一个 MySQL 示例。
这就是我为 Oracle 驱动程序所做的
<datasource jndi-name="java:/sigap_ws_receiver" pool-name="sigap_ws_receiver" enabled="true">
<connection-url>jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=off)(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.1)(PORT=1524))(CONNECT_DATA=(SERVICE_NAME=profepa)(SERVER=DEDICATED)))</connection-url>
<driver>com.oracle</driver>
<pool>
<min-pool-size>3</min-pool-size>
<max-pool-size>5</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
<validation>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
</datasource>
The driver's section would look like this:
驱动程序部分如下所示:
<drivers>
<driver name="com.oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
</drivers>
My module.xml is under $JBOSS_HOME\modules\com\oracle\main within the jar ojdbc6.jar:
我的 module.xml 位于 $JBOSS_HOME\modules\com\oracle\main 下 jar ojdbc6.jar 中:
<module xmlns="urn:jboss:module:1.0" name="com.oracle">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
回答by Jean-Fran?ois Savard
All of these answers helped me to get it to works, but none of them was the exact solution so I thought I would add mine.
所有这些答案都帮助我让它发挥作用,但它们都不是确切的解决方案,所以我想我会添加我的。
First, note that you can do this either in the JBoss web-console
or by manually configuring the datasource in the xml files. However, I highly suggest that you configure it through the web-console to avoid error such as the one the OP made and that apparently no-one noticed :
首先,请注意,您可以JBoss web-console
在 xml 文件中或通过手动配置 xml 文件中的数据源来执行此操作。但是,我强烈建议您通过网络控制台对其进行配置,以避免出现错误,例如 OP 所做的并且显然没有人注意到的错误:
<drivers>
<driiver name="oracle" module="com.oracle.ojdbc6">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
</drivers>
Notice that the driver declaration contains two i.
请注意,驱动程序声明包含两个 i。
Manual configuration [Not recommended]
手动配置【不推荐】
First of all, you must make sure your Oracle jdbc is configured.
首先,您必须确保您的 Oracle jdbc 已配置。
- Navigate to
$JBOSS_HOME/modules
and if it does not already exists, create folder treeoracle/jdbc/main
. - Navigate to that folder and copy the
odjbc6-11.jar
. - Create module.xml with the following content
- 导航到
$JBOSS_HOME/modules
,如果它不存在,则创建文件夹树oracle/jdbc/main
。 - 导航到该文件夹并复制
odjbc6-11.jar
. - 使用以下内容创建 module.xml
<module> <resources> <!-- make sure the path match the name of the file --> <resource-root path="ojdbc6-11.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
<module> <resources> <!-- make sure the path match the name of the file --> <resource-root path="ojdbc6-11.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
Now that your jdbc is configured, you must edit the standalone.xml
file to specify the driver and datasource properties.
现在您的 jdbc 已配置,您必须编辑该standalone.xml
文件以指定驱动程序和数据源属性。
- Navigate to
$JBOSS_HOME/standalone/configuration
and edit standalone.xml file. - Locate the
drivers
tag and configure your driver as follow :
- 导航到
$JBOSS_HOME/standalone/configuration
并编辑 standalone.xml 文件。 - 找到
drivers
标签并按如下方式配置您的驱动程序:
<driver name="oracle" module="oracle.jdbc"> <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class> </driver>
<driver name="oracle" module="oracle.jdbc"> <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class> </driver>
- Now add the datasource configuration :
- 现在添加数据源配置:
<datasource jndi-name="java:jboss/datasources/Altis" pool-name="Altis" enabled="true"> <connection-url>jdbc:oracle:thin:@255.255.255.255:1521:sid</connection-url> <driver-class>oracle.jdbc.OracleDriver</driver-class> <driver>oracle</driver> <security> <user-name>username</user-name> <password>passwd</password> </security> </datasource>
<datasource jndi-name="java:jboss/datasources/Altis" pool-name="Altis" enabled="true"> <connection-url>jdbc:oracle:thin:@255.255.255.255:1521:sid</connection-url> <driver-class>oracle.jdbc.OracleDriver</driver-class> <driver>oracle</driver> <security> <user-name>username</user-name> <password>passwd</password> </security> </datasource>
Online configuration [Recommended]
在线配置【推荐】
- Navigate to the management console (by default localhost:9990/console)
- Click on Configuration and expand Datasourcesin Connector
- Click on add (first button on right of the datasources table)
- Fill in the Name, in your case
Altis
- Fill in the JNDI name, in your case
java:jboss/datasources/Altis
. Note that JNDI name has to start withjava:/
orjava:jboss/
- Select your driver, it should be in the detected driver if it was properly configured.
- Fill in the connection url as
jdbc:oracle:thin:@255.255.255.255:1521:sid
- Fill in the username and password.
- You can left empty the security domain if you want or specify one.
- Make sure you test the connection before clicking on Done.
- Once the datasource is saved, select it in the table and click on
Enable
- 导航到管理控制台(默认为 localhost:9990/console)
- 点击配置和扩展数据源的连接器
- 单击添加(数据源表右侧的第一个按钮)
- 填写名称,根据您的情况
Altis
- 在您的情况下填写 JNDI 名称
java:jboss/datasources/Altis
。请注意,JNDI 名称必须以java:/
或开头java:jboss/
- 选择您的驱动程序,如果配置正确,它应该在检测到的驱动程序中。
- 填写连接url为
jdbc:oracle:thin:@255.255.255.255:1521:sid
- 填写用户名和密码。
- 如果需要,您可以将安全域留空或指定一个。
- 确保在单击完成之前测试连接。
- 保存数据源后,在表中选择它并单击
Enable
回答by guest
In the module.xml jar, you have path="ojdbc6.jar"
for the resource-root tag, but you said you downloaded ojdbc6-11.jar
在module.xml jar 中,你有path="ojdbc6.jar"
resource-root 标签,但你说你下载了ojdbc6-11.jar
I think you need to have path="ojdbc6-11.jar"
in your module.xml
我认为你需要path="ojdbc6-11.jar"
在你的 module.xml
回答by Amit S
verify $JBOSS_HOME\modules\system\layers\base\com\oracle\ojdbc6\main exists and have ojdbcXX.jar and module.xml Module name="com.oracle.ojdbc" in module.xml should match with module="com.oracle.ojdbc" in standalone.xml
验证 $JBOSS_HOME\modules\system\layers\base\com\oracle\ojdbc6\main 存在并且有 ojdbcXX.jar 和 module.xml module.xml 中的 Module name="com.oracle.ojdbc" 应该与 module="com 匹配.oracle.ojdbc”在standalone.xml
e.g. module.xml -->
例如 module.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="**com.oracle.ojdbc6**">
<resources>
<resource-root path="ojdbc6.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
standalone.xml -->
<datasource jndi-name="java:/abc" pool-name="abc" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:@localhost:1521:orcl</connection-url>
<driver>**oracle**</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<security>
<user-name>a_user</user-name>
<password>pwdXXX</password>
</security>
</datasource>
<drivers>
<driver name="**oracle**" module="**com.oracle.ojdbc6**">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.driver.OracleDriver</xa-datasource-class>
</driver>
</driver>
回答by mohgly
Try using driver-class in the driver as
<driver-class>oracle.jdbc.OracleDriver</driver-class>
尝试在驱动程序中使用 driver-class 作为
<driver-class>oracle.jdbc.OracleDriver</driver-class>
回答by yallam
On top of Jean-Fran?ois Savard's manual solution I as well excluded jars from jboss-deployment-structure.xml, only then i managed to get it up and running. Just logging here as this might help others.Example of my jboss-deployment-structure.xml is below
除了 Jean-Fran?ois Savard 的手动解决方案之外,我还从 jboss-deployment-structure.xml 中排除了 jars,然后我才设法启动并运行它。只是在这里登录,因为这可能会帮助其他人。我的 jboss-deployment-structure.xml 的示例如下
enter code here
enter code here
<!--exclude-subsystems>
<subsystem name="jpa" />
</exclude-subsystems-->
<!--http://mca.intranet.barclays.co.uk/confluence/display/MCA/Changes+required+in+MCA+for+aPaaS-->
<exclusions>
<module name="org.codehaus.Hymanson.Hymanson-core-asl" />
<module name="org.codehaus.Hymanson.Hymanson-mapper-asl" />
<module name="org.apache.log4j" />
<module name="javax.persistence.api" />
<module name="org.hibernate" />
</exclusions>
<dependencies>
<module name="javax.activation.api" export="true"/>
<module name="javax.annotation.api" export="true"/>
<module name="javax.ejb.api" export="true"/>
<module name="javax.el.api" export="true"/>
<module name="javax.enterprise.api" export="true"/>
<module name="javax.enterprise.deploy.api" export="true"/>
<module name="javax.inject.api" export="true"/>
<module name="javax.interceptor.api" export="true"/>
<module name="javax.jms.api" export="true"/>
<module name="javax.jws.api" export="true"/>
<module name="javax.mail.api" export="true"/>
<module name="javax.management.j2ee.api" export="true"/>
<module name="javax.resource.api" export="true"/>
<module name="javax.rmi.api" export="true"/>
<module name="javax.security.auth.message.api" export="true"/>
<module name="javax.security.jacc.api" export="true"/>
<module name="javax.servlet.api" export="true"/>
<module name="javax.servlet.jsp.api" export="true"/>
<module name="javax.transaction.api" export="true"/>
<module name="javax.validation.api" export="true"/>
<module name="javax.ws.rs.api" export="true" services="export"/>
<module name="javax.xml.bind.api" export="true"/>
<module name="javax.xml.registry.api" export="true"/>
<module name="javax.xml.soap.api" export="true"/>
<module name="javax.xml.ws.api" export="true"/>
<module name="org.jboss.as.jmx" />
<!--module name="ibm.mq" /-->
<module name="javax.api" export="true"/>
</dependencies>
</deployment>
回答by Nishat Lakhani
Goto console panel of JBoss AS. Enter the username and password of the user that you have created with the help of adduser.bat. Then a page will appear regarding all the configurations. Now follow the given below steps:
转到 JBoss AS 的控制台面板。输入您在adduser.bat帮助下创建的用户的用户名和密码。然后会出现一个关于所有配置的页面。现在按照以下步骤操作:
1) Go to profile
1) 转到个人资料
2) Select datasources from left hand side pane
2)从左侧窗格中选择数据源
3) Then click on addbutton in datasource section
3)然后单击数据源部分中的添加按钮
4) Provide the details such as name, jndi name, etc.
4) 提供姓名、jndi 名称等详细信息。
- Name: OracleDS
- Jndi: java:jboss/datasources/OracleDS
- 名称:OracleDS
- Jndi:java:jboss/datasources/OracleDS
5) Click on next button
5)点击下一步按钮
6) Chose the driver that you have deployed in jboss with the help of standalone.xml
6)在standalone.xml的帮助下选择你在jboss中部署的驱动
7) Click on next button
7)点击下一步按钮
8) Now fill the details...
8) 现在填写详细信息...
- connection url: jdbc:oracle:thin:@[host]:1521:[sid]
- username: [user]
- password: [pass]
- security domain: leave it blank
- 连接网址:jdbc:oracle:thin:@[host]:1521:[sid]
- 用户名:[用户]
- 密码:[通行证]
- 安全域:留空
9) Click on done.
9)点击完成。
Now a message will appear that "Datasource added successfully".
现在将出现一条消息“数据源添加成功”。
That's it....!!!
就是这样....!!!