如果将Jboss AS 7中的jdbc部署为Web应用程序,那么模块名称是什么

时间:2013-08-28 03:15:28

标签: java java-ee jdbc jboss ejb

post开始,从Jboss AS7开始,jdbc驱动程序可以作为常规应用程序进行部署。但问题是,其他应用程序如何能够引用此jdbc jar?

这是我尝试的但它不起作用

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
......
<deployment>
    <dependencies>
        <module name="ojdbc6.jar" />
    </dependencies>
</deployment>
.....
</jboss-deployment-structure>

更新

当我部署ojdbc.jar时,控制台有一段日志:

10:56:20,416 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "ojdbc6.jar"
10:56:21,487 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
10:56:21,489 INFO  [org.jboss.as.osgi] (MSC service thread 1-7) JBAS011907: Register module: Module "deployment.ojdbc6.jar:main" from Service Module Loader
10:56:21,499 INFO  [org.jboss.as.server] (HttpManagementService-threads - 6) JBAS018559: Deployed "ojdbc6.jar"

根据日志jdbc模块名称为deployment.ojdbc6.jar:main,但在我更新jboss-deployment-structure.xml

之后
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
......
<deployment>
    <dependencies>
        <module name="deployment.ojdbc6.jar:main" />
    </dependencies>
</deployment>
.....
</jboss-deployment-structure>

它仍然不起作用。以下消息:

10:59:34,448 INFO  [org.jboss.as.server] (HttpManagementService-threads - 7) JBAS015870: Deploy of deployment "MyApp.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"MyApp.war.war\".POST_MODULE Missing[JBAS014861: <one or more transitive dependencies>]","jboss.module.service.\"deployment.MyApp.war.war\".main Missing[jboss.module.spec.service.\"deployment.ojdbc6.jar:main\".main]"]}
10:59:35,198 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment MyApp.war.war in 749ms

1 个答案:

答案 0 :(得分:1)

您可以通过以下方式引用其他部署中的jar:

  <module name="deployment.YourEarOrWar.YourJar.jar" />

其中deployment是对已部署应用程序的引用的通用前缀。 但是,对于像jdbc-driver这样的lib,我建议把它放在JBoss的module-folder中

 <module xmlns="urn:jboss:module:1.1" name="driver.ojdbc">

<resources>
    <resource-root path="ojdbc6.jar"/>      
</resources>

 </module>

然后引用它

  <module name="driver.ojdbc"/>

另见 https://community.jboss.org/thread/169894http://www.mastertheboss.com/jboss-as-7/how-to-install-a-module-on-jboss-as-7