【问题标题】:failed connecting mongodb in jboss在jboss中连接mongodb失败
【发布时间】:2015-06-20 18:25:03
【问题描述】:

在将连接到 mongodb 的 war 文件部署到 jboss 时,出现以下错误:

Request
{
    "address" => [("deployment" => "moc-public-api-1.0_SNAPSHOT.war")],
    "operation" => "deploy"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => {
        "JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./public-api/v1" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./public-api/v1: Failed to start service
    Caused by: java.lang.NoClassDefFoundError: org/jboss/resteasy/core/ResourceMethod
    Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.core.ResourceMethod from [Module \"deployment.moc-public-api-1.0_SNAPSHOT.war:main\" from Service Module Loader]"},
        "JBAS014879: 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.\"moc-public-api-1.0_SNAPSHOT.war\".deploymentCompleteService"],
            "Services that may be the cause:" => ["jboss.jdbc-driver.mongoDriver"]
        }
    },
    "rolled-back" => true
}

我的standalone.xml中的数据源是这样的:

<datasource jndi-name="java:/mongoDS" pool-name="mongoDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:mongodb://localhost:27017/test</connection-url>
    <driver>mongoDriver</driver>
    <security>
        <user-name></user-name>
        <password></password>
    </security>
</datasource>

而我的standalone.xml中的驱动是这样的:

<driver name="mongoDriver" module="com.mongodb">
    <xa-datasource-class>com.mongodb.jdbc.Driver</xa-datasource-class>
</driver>

错误显示"Services that may be the cause:" =&gt; ["jboss.jdbc-driver.mongoDriver"],我的mongodb jdbc驱动配置正确吗?

【问题讨论】:

  • 你试过最新的驱动吗?

标签: java mongodb jdbc jboss


【解决方案1】:

问题在于您的部署moc-public-api-1.0_SNAPSHOT.war。您的部署需要 resteasy 类,但它们不在类加载器范围内。

您可以通过 adding entries to the manifest file 或创建 jboss-deployment-structure.xml 并将其与您的部署一起发布来添加依赖项。

示例 jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
    <deployment>
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jaxrs" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

【讨论】:

    猜你喜欢
    • 2015-06-16
    • 2017-02-11
    • 2011-12-29
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多