在jboss中连接mongodb失败了

时间:2015-06-20 18:25:03

标签: java mongodb jdbc jboss

在部署连接到mongodb和jboss的war文件时,我收到以下错误:

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:" => ["jboss.jdbc-driver.mongoDriver"],我的mongodb jdbc驱动配置是否正确?

1 个答案:

答案 0 :(得分:0)

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

您可以通过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>