Deploy JAR as a module on JBoss 7.1.1

2019-09-04 05:46发布

问题:

I have a problem using deployed jars on jboss as modules.

I know that I should create a global module by: creating a subfolder of JBOSS_HOME/modules, copy the jar and create the module.xml file, but here http://blog.tier2consulting.com/2013/04/02/understanding-modules-in-jboss-enterprise-application-platform-6/ and, more officially, here https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Development_Guide/chap-Class_Loading_and_Modules.html, I read, verbatim,

Dynamic Modules are created and loaded by the application server for each JAR or WAR deployment (or subdeployment in an EAR). The name of a dynamic module is derived from the name of the deployed archive.

Still, when I deploy my JAR, I can only see in the JBOSS log file:

16:06:18,698 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "Test.jar" 16:06:18,964 INFO [org.jboss.as.server] (HttpManagementService-threads - 14) JBAS018559: Deployed "Test.jar"

while in the log file of the example on the first site I linked, there is one more line, i.e.:

Register module: Module "deployment.utils.jar:main" from Service Module Loader

Is it something available only on EAP 6 or is it possible to achieve such a result also on JBOSS AS 7.1.1-Final or on JBOSS AS 7.1.1-Final you're compelled to use the folder JBOSS_HOME/modules?

回答1:

OK. I just figured it out. JBOSS AS 7.1.1-Final just doesn't write anything about deployment as a module, but it does is deployed as a module. To reference it as a dependence in another project, in the MANIFEST.MF file you have to add Dependencies: deployment.Test.jar, i.e. just like when you reference a global module, but pre-pending deployment and using the entire archive name as module name.

The deployed jar doesn't need to have any particular MANIFEST file neither it needs to embed a module.xml file.