Jboss 7 - Oracle 数据源不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12532024/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:07:12  来源:igfitidea点击:

Jboss 7 - Oracle Datasource not working

oraclepersistencedatasourcejboss7.xojdbc

提问by RicardoS

I'm working on a Web App with just one WAR project. It uses JPA and has a DataSource that I need to configure to run on JBOSS 7. The database is Oracle.

我正在开发一个只有一个 WAR 项目的 Web 应用程序。它使用 JPA 并有一个 DataSource,我需要对其进行配置才能在JBOSS 7上运行。数据库是Oracle

I'm getting this error:

我收到此错误:

JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.resources.jboss.jdbc.batchAdminDB

I've followed instructions for using dataSource on Jboss. So I have these configurations:

我已按照在 Jboss 上使用 dataSource 的说明进行操作。所以我有这些配置:

{JBOSS_HOME}/modules/com/oracle/ojdbc6/main/module.xml:

{JBOSS_HOME}/modules/com/oracle/ojdbc6/main/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"/>
    </resources>
    <dependencies>
        <module name="javax.api" />
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>
</module>

ojdbc6.jar exists and the name is correct.

ojdbc6.jar 存在且名称正确。

standalone.xml

独立文件

<datasources>

                <datasource jndi-name="java:jboss/jdbc/batchAdminDB" pool-name="batchAdminDB" enabled="true" use-java-context="true">
                    <connection-url>jdbc:oracle:thin:@HOST:PORT/xe</connection-url>
                    <driver>oracle</driver>
                    <security>
                        <user-name>USER</user-name>
                        <password>PASSW</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="oracle" module="com.oracle.ojdbc6">
                        <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

On the application: META-INF/persistence.xml:

在应用程序上:META-INF/ persistence.xml:

<persistence-unit name="batchAdminEM" transaction-type="JTA">
    <jta-data-source>java:jboss/jdbc/batchAdminDB</jta-data-source>

    <class>...</class>
 ...</persistence-unit>

When Jboss starts (without the app) it get to read(bound) the datasource. The error comes when I try to deploy the app, it doesn't run.

当 Jboss 启动(没有应用程序)时,它会读取(绑定)数据源。当我尝试部署应用程序时出现错误,它没有运行。

More of StackTrace to help:

更多的 StackTrace 帮助:

15:57:46,888 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/jdbc/batchAdminDB]
...
15:57:52,356 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-2) HHH000204: Processing PersistenceUnitInfo [
    name: batchAdminEM
    ...]
15:57:53,649 ERROR [org.jboss.as] (MSC service thread 1-1) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 13255ms - Started 325 of 568 services (165 services failed or missing dependencies, 76 services are passive or on-demand)
15:57:53,861 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "BatchAdmin.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.BatchAdmin.BatchAdmin.env.jboss.jdbc.batchAdminDBjboss.naming.context.java.jboss.resources.jboss.jdbc.batchAdminDBMissing[jboss.naming.context.java.module.BatchAdmin.BatchAdmin.env.jboss.jdbc.batchAdminDBjboss.naming.context.java.jboss.resources.jboss.jdbc.batchAdminDB]"]}
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.resources.jboss.jdbc.batchAdminDB (missing) dependents: [service jboss.naming.context.java.module.BatchAdmin.BatchAdmin.env.jboss.jdbc.batchAdminDB] 

15:57:53,934 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.BatchAdmin.BatchAdmin.env.jboss.jdbc.batchAdminDBjboss.naming.context.java.jboss.resources.jboss.jdbc.batchAdminDBMissing[jboss.naming.context.java.module.BatchAdmin.BatchAdmin.env.jboss.jdbc.batchAdminDBjboss.naming.context.java.jboss.resources.jboss.jdbc.batchAdminDB]"]}}}

采纳答案by RicardoS

After a long time I found what was the problem.

找了好久才发现问题出在哪。

web.xmlcontains a configuration that was used before, on Tomcat.

web.xml包含之前在 Tomcat 上使用的配置。

<resource-ref>
  <description>DB Connection</description>
  <res-ref-name>jboss/jdbc/batchAdminDB</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>

This configuration was probally confusing Jboss. It's not necessary anymore.

这个配置可能让 Jboss 感到困惑。已经没有必要了。

The solution:
Just comment or remove that part (resource-ref).

解决方案:
只需评论或删除该部分(资源引用)。

A helpful link (in portuguese):
http://www.guj.com.br/java/256103-resolvido-seam-3--hibernate-4--jbossas7-erro-de-datasource

一个有用的链接(葡萄牙语):http:
//www.guj.com.br/java/256103-resolvido-seam-3--hibernate-4--jbossas7-erro-de-datasource

回答by RGO

You have used wrong connection URL format. With xeas SID, you must either use:

您使用了错误的连接 URL 格式。对于xeSID,您必须使用:

jdbc:oracle:thin:@HOST:PORT:xe

or

或者

jdbc:oracle:thin:@//HOST:PORT/xe

Check herefor more information.

点击这里获取更多信息。

ADD

添加

You also have to change one line in your module.xml file in this way:

您还必须以这种方式更改 module.xml 文件中的一行:

<module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6">