通过 jndi 配置数据源时启动 jboss 服务器时出错

Posted

技术标签:

【中文标题】通过 jndi 配置数据源时启动 jboss 服务器时出错【英文标题】:Getting error starting jboss server when datasource is configured through jndi 【发布时间】:2012-12-19 23:16:13 【问题描述】:

我正在尝试通过 jboss 中的 jndi 配置数据源。

启动服务器时出现以下错误

    2013-01-06 00:18:01,078 ERROR [ProfileServiceBootstrap] (Thread-2) Failed to load profile:: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

    *** DEPLOYMENTS MISSING DEPLOYERS: Name

    vfs:///D:/downloads/jboss-6.1.0.Final/server/default/deploy/jboss-local-jdbc.rar

    DEPLOYMENTS MISSING DEPENDENCIES:
      Deployment "jboss-switchboard:appName=practice,module=practice" is missing the following dependencies:
        Dependency "java:/DefaultDS" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'java:/DefaultDS' **")
      Deployment "jboss.web.deployment:war=/practice" is missing the following dependencies:
        Dependency "jboss-switchboard:appName=practice,module=practice" (should be in state "Installed", but is actually in state "Create")
      Deployment "jboss:service=KeyGeneratorFactory,type=HiLo" is missing the following dependencies:
        Dependency "jboss.jca:name=DefaultDS,service=DataSourceBinding" (should be in state "Create", but is actually in state "** NOT FOUND Depends on 'jboss.jca:name=DefaultDS,service=DataSourceBinding' **")

    DEPLOYMENTS IN ERROR:
      Deployment "java:/DefaultDS" is in error due to the following reason(s): ** NOT FOUND Depends on 'java:/DefaultDS' **
      Deployment "jboss.jca:name=DefaultDS,service=DataSourceBinding" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.jca:name=DefaultDS,service=DataSourceBinding' **
      Deployment "vfs:///D:/downloads/jboss-6.1.0.Final/server/default/deploy/oracle-ds.xml" is in error due to the following reason(s): java.lang.IllegalStateException: No ConnectorMetaData found for mdf rarName: jboss-local-jdbc.rar

        at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1228) [:2.2.2.GA]
        at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:905) [:2.2.2.GA]
        at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:87) [:6.1.0.Final]
        at org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry.checkAllComplete(ProfileDeployerPluginRegistry.java:107) [:0.2.2]
        at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:135) [:6.1.0.Final]
        at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.1.0.Final]
        at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6]
        at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6]
        at java.lang.Thread.run(Thread.java:662) [:1.6.0_31]

    2013-01-06 00:18:01,156 INFO  [org.apache.coyote.http11.Http11Protocol] (Thread-2) Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
    2013-01-06 00:18:01,171 INFO  [org.apache.coyote.ajp.AjpProtocol] (Thread-2) Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
    2013-01-06 00:18:01,171 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] (Thread-2) JBossAS [6.1.0.Final "Neo"] Started in 2m:57s:984ms

下面是$JBOSS_HOME\server\default\deploy目录下的oracle-ds.xml文件

oralce-ds.xml ..................................................... ...................................

    <datasources>
      <local-tx-datasource>
        <jndi-name>DefaultDS</jndi-name>
        <connection-url>jdbc:oracle:thin:@localhost:1521:myDB</connection-url>
        <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
        <user-name>user_name</user-name>
        <password>pwd</password>
        <min-pool-size>5</min-pool-size>
        <max-pool-size>20</max-pool-size>
        <!-- Checks the Oracle error codes and messages for fatal errors -->
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

         <metadata>
             <type-mapping>Oracle9i</type-mapping>
          </metadata>
      </local-tx-datasource>

    </datasources>

web.xml 的内容

    web.xml
    ....................................................
    <resource-ref>
          <description>Oracle DS</description>
          <res-ref-name>jdbc/DefaultDS</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
    </resource-ref>

jboss-web.xml 的内容

  jboss-web.xml
    ..................................................
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web>
        <resource-ref>
            <res-ref-name>jdbc/DefaultDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <jndi-name>java:/DefaultDS</jndi-name>
        </resource-ref>
    </jboss-web>


Any help will be appreciated.

【问题讨论】:

【参考方案1】:

JBoss 使用 DefaultDS。您必须将“DefaultDS”更改为另一个名称。

【讨论】:

我确实将 DEFAULTDS 更改为 ORACLEDS 但仍然出现相同的错误。 此错误日志位于服务器启动结束时。您能否在启动时提供错误信息。【参考方案2】:

您的部署中缺少jboss-local-jdbc.rar,尝试获取它并将其放在部署文件夹中。

【讨论】:

以上是关于通过 jndi 配置数据源时启动 jboss 服务器时出错的主要内容,如果未能解决你的问题,请参考以下文章

Tomcat,Jboss,Weblogic通过jndi连接数据库

如何通过 JNDI 从 JBoss 检索数据源

如何使用 HikariCP 在 Jboss 中配置 JNDI 数据源?

jboss 服务器已启动。但显示 java.net.bind 异常;地址已被使用

Jboss7.1 MDB - 本地 JNDI 参考与全球 JNDI 参考

JBoss Wildfly 9,JNDI 异常