【问题标题】:MySQL + WildFly 10.0 - One or more services were unable to startMySQL + WildFly 10.0 - 一项或多项服务无法启动
【发布时间】:2016-07-06 00:33:37
【问题描述】:

我在部署时尝试连接数据库,但遇到了一些麻烦,这是代码和堆栈跟踪:

 02:19:32,740 ERROR [org.jboss.as.controller.management-operation]  (ServerService Thread Pool -- 45) WFLYCTL0013: Operation ("add") failed -  address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver   [org.mysql]"
02:19:32,814 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path 'C:\Users  \Damian\wildfly-10.0.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
02:19:32,839 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
 02:19:32,840 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
02:19:32,925 INFO  [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
02:19:32,925 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
02:19:33,157 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "FiranyCRM.war" (runtime-name: "FiranyCRM.war")
02:19:33,171 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "mysql-connector-java-5.1.37.jar" (runtime-name: "mysql-connector-java-5.1.37.jar")
02:19:33,186 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\Damian\wildfly-10.0.0.Final\standalone\deployments
02:19:33,232 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-6) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
 02:19:33,506 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
 02:19:33,771 INFO  [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4) 
02:19:33,827 INFO  [org.jboss.as.jpa] (MSC service thread 1-8) WFLYJPA0002: Read persistence.xml for firanyDS
02:19:33,880 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
02:19:33,882 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
02:19:33,916 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.37.jar_com.mysql.jdbc.Driver_5_1
02:19:33,917 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.37.jar_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
02:19:34,213 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "FiranyCRM.war")]) - failure description: {
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "jboss.persistenceunit.\"FiranyCRM.war#firanyDS\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jdbc.firanyDS]",
    "jboss.persistenceunit.\"FiranyCRM.war#firanyDS\" is missing [jboss.naming.context.java.jdbc.firanyDS]"
],
"WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => {
    "Services that were unable to start:" => [
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.faces.webapp.FacesServlet\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.faces.webapp.FacetTag\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"managed-bean.com.firanycrm.controller.CurtainBean\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".component.\"managed-bean.com.firanycrm.controller.LoginBean\".START",
        "jboss.deployment.unit.\"FiranyCRM.war\".deploymentCompleteService",
        "jboss.deployment.unit.\"FiranyCRM.war\".jndiDependencyService",
        "jboss.naming.context.java.module.FiranyCRM.FiranyCRM.DefaultDataSource",
        "jboss.undertow.deployment.default-server.default-host./FiranyCRM",
        "jboss.undertow.deployment.default-server.default-host./FiranyCRM.UndertowDeploymentInfoService"
    ],
    "Services that may be the cause:" => [
        "jboss.jdbc-driver.mysql",
        "jboss.naming.context.java.jdbc.firanyDS"
    ]
}
}
02:19:34,214 ERROR [org.jboss.as.controller.management-operation]   (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "firanyDS")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.firanyDS is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/firanyDS is missing  [jboss.jdbc-driver.mysql]"
]}
02:19:34,216 ERROR [org.jboss.as.controller.management-operation]  (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "firanyDS")
]) - failure description: {
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
    "org.wildfly.data-source.firanyDS is missing [jboss.jdbc-   driver.mysql]",
    "jboss.driver-demander.java:jboss/datasources/firanyDS is missing   [jboss.jdbc-driver.mysql]",
    "org.wildfly.data-source.firanyDS is missing [jboss.jdbc- driver.mysql]"
],
"WFLYCTL0288: One or more services were unable to start due to one or    more indirect dependencies not being available." => {
    "Services that were unable to start:" => [
        "jboss.data-source.reference-factory.firanyDS",
        "jboss.naming.context.java.jboss.datasources.firanyDS"
    ],
    "Services that may be the cause:" => [
        "jboss.jdbc-driver.mysql",
        "jboss.naming.context.java.jdbc.firanyDS"
    ]
}
}

standalone.xml:

<subsystem xmlns="urn:jboss:domain:datasources:4.0">
        <datasources>
            <datasource jndi-name="java:jboss/datasources/firanyDS" pool-name="firanyDS">
                <connection-url>jdbc:mysql://127.0.0.1:3307/firanycrm</connection-url>
                <driver>mysql</driver>
                <pool>
                    <min-pool-size>10</min-pool-size>
                    <max-pool-size>20</max-pool-size>
                    <prefill>true</prefill>
                </pool>
                <security>
                    <user-name>root</user-name>
                    <password>root</password>
                </security>
            </datasource>
            <drivers>
                <driver name="mysql" module="org.mysql">
                    <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

module.xml(在模块文件夹中,modules/org/mysql):

<module xmlns="urn:jboss:module:1.0" name="org.mysql.driver"> 
<resources> 
<resource-root path="mysql-connector-java-5.1.37.jar"/> 
</resources> 
<dependencies> 
 <module name="javax.api"/> 
 <module name="javax.transaction.api"/> 
</dependencies> 
</module> 

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="firanyDS" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/jdbc/firanyDS</jta-data-source>
    <properties>
        <property name="hibernate.dialect"  value="org.hibernate.dialect.MySQL5Dialect" />
    </properties>
</persistence-unit>
</persistence>

我在哪个地方做错了?

【问题讨论】:

    标签: mysql xml jboss wildfly


    【解决方案1】:

    你至少有两个问题:

    1. 在standalone.xml中,在datasources子系统下,将驱动模块设置为“org.mysql”,但是module.xml中的模块名称是“org.mysql.driver”。

    2. persistence.xml 中的 jta-data-source 元素应该是数据源的 jndi 名称:java:jboss/datasources/firanyDS。另外,由于你使用的是JTA,所以transaction-type必须是“JTA”。

    <persistence ...>
        <persistence-unit name="firanyDS" transaction-type="JTA">
            <jta-data-source>java:/jdbc/firanyDS</jta-data-source>
            <properties>
                <property name="hibernate.dialect"  value="org.hibernate.dialect.MySQL5Dialect" />
            </properties>
        </persistence-unit>
    </persistence>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      • 1970-01-01
      • 1970-01-01
      • 2017-06-17
      相关资源
      最近更新 更多