Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在jboss中连接mongodb失败_Java_Mongodb_Jdbc_Jboss - Fatal编程技术网

Java 在jboss中连接mongodb失败

Java 在jboss中连接mongodb失败,java,mongodb,jdbc,jboss,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" =&g

在部署连接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中的datasouorce如下所示:

<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>
<driver name="mongoDriver" module="com.mongodb">
    <xa-datasource-class>com.mongodb.jdbc.Driver</xa-datasource-class>
</driver>

jdbc:mongodb://localhost:27017/test
蒙哥德河
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>
<driver name="mongoDriver" module="com.mongodb">
    <xa-datasource-class>com.mongodb.jdbc.Driver</xa-datasource-class>
</driver>

com.mongodb.jdbc.Driver

错误显示了可能的原因:“=>[“jboss.jdbc driver.mongoDriver”],我的mongodb jdbc驱动程序配置正确吗?

问题在于您的部署
moc-public-api-1.0\u SNAPSHOT.war
。您的部署需要resteasy类,但它们不在类装入器范围内

您可以通过以下方式添加依赖项:创建依赖项,并将其与部署一起发布

jboss部署结构示例.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>

您是否试用过最新的驱动程序?