Jboss AS7 - How to create module.xml for external libraries? - jboss7.x

I have multiple .ear projects which use multiple libraries. So I need to make those as common and add those in the module. So Is there any easy way to create module.xml as I need to create module.xml for each library?
Also do I need to define the dependency for each library in module.xml?
Please let me know if there is any easy way to handle this?

No need to create 'module.xml' for each library.
Create a single module and put all libraries there and mention it in resource-root. Also mention any module dependencies (if no, ignore it).
Example module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.test.myownresteasy">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="activation-1.1.jar"/>
<resource-root path="httpcore-4.1.2.jar"/>
<resource-root path="jettison-1.3.1.jar"/>
<resource-root path="resteasy-jaxrs-2.3.2.Final.jar"/>
<resource-root path="scannotation-1.0.3.jar"/>
<resource-root path="httpclient-4.1.2.jar"/>
<resource-root path="jaxrs-api-2.3.2.Final.jar"/>
<resource-root path="jul-to-slf4j-stub-1.0.0.Final.jar"/>
<resource-root path="resteasy-jaxb-provider-2.3.2.Final.jar"/>
<resource-root path="resteasy-jettison-provider-2.3.2.Final.jar"/>
</resources>
<dependencies>
<!-- Insert dependencies here -->
</dependencies>
</module>
Copy your modules to '$JBOSS/modules' directory which makes it as global module.
Refer:
How can I use the external jars on JBoss 7?

Related

Can't register AWS-SDK on Jboss modules correctly

I found the dependency aws-java-sdk was being compiled on a legacy code, having as result a very heavy EAR.
I declared this dependency as provided and wanted to put it as part of the Jboss modules, but no matter where I put it, I'm still having the ClassNotFound issue.
Here is my module.xml:
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-1.11.584.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.stream.api"/>
<module name="javax.xml.bind.api"/>
<module name="com.fasterxml.jackson"/>
<module name="org.joda.time"/>
</dependencies>
</module>
And the error:
Caused by: java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials
The problem was on the JAR file, needed sdk-core. Check your JARs always.

Can keycloak JavaScript based policy calls remote REST API?

Can I call remote REST API from keycloak's JavaScript based policy? I need this because the current version of keycloak does not support custom attributes for resources according to this answer. Thus I created a special server that contains all required metadata for making decisions about granting access to resources.
1.You can make jar and copy it into modules dir. Make it like other modules, create module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="io.geewit.keycloak.provider">
<resources>
<resource-root path="keycloak-mock-module-1.0.0.jar"/>
</resources>
<dependencies>
<module name="sun.jdk"/>
<module name="sun.scripting"/>
<module name="org.keycloak.keycloak-core"/>
<module name="org.keycloak.keycloak-server-spi"/>
<module name="org.keycloak.keycloak-server-spi-private"/>
</dependencies>
</module>
2.You edit the "keycloak-services" module.xml
<dependencies>
<module name="sun.scripting"/>
<module name="io.geewit.keycloak.provider"/>
</dependencies>

How to share common libraries in Jboss7

Hi friends,
i have more than one WAR in my server, each war has some common libraries(.jar). How to share the common libraries in JBoss7. please anybody help me..
Created a directory : mkdir -p JBoss_HOME/modules/com/common/lib/main
Placed all jars inside main dir
Created module.xml under main dir.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.common.lib">
<resources>
<resource-root path="JarName-1.0.1.jar"/>
</resources>
</module>
Created jboss-deployment-structure under WEB-INF & packed the war deployment file.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.comman.lib"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
You can create custom module of common jar files and add application dependency(war) on custom module through jboss-deployment-structure.xml file

issues interating jboss eap6 with ActiveMQ 5.9

I have the activeMQ server running in the jvm at tcp://localhost:61616
then i place the activemq-rar-5.9.0.redhat-610379 unzipped
adaptor
in the
\runtimes\jboss-eap\modules\system\layers\base\org\apache\activemq\main
in the adaptor i have the Meta-INF
in the jboss EAP6 , standalone.xml i have specified the
But when i start the server ... i get the below error
**
12:05:39,910 ERROR [org.jboss.as.controller.management-operation]
(ServerService Thread Pool -- 40) JBAS014612: Operation ("add") failed
- address: ([
("subsystem" => "resource-adapters"),
("resource-adapter" => "activemq-rar.rar") ]) - failure description: "JBAS010473: Failed to load module for RA
[org.apache.activemq]"
**
Your question is missing some information, but in reviewing what you have typed it sounds like you are missing the module.xml that needs to go in your module directory (\runtimes\jboss-eap\modules\system\layers\base\org\apache\activemq\main)
For ActiveMQ RAR version 5.9 a module.xml would look like the following
<module xmlns="urn:jboss:module:1.1" name="org.apache.activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<resources>
<resource-root path="."/>
<resource-root path="activemq-broker-5.9.0.jar"/>
<resource-root path="activemq-client-5.9.0.jar"/>
<resource-root path="activemq-jms-pool-5.9.0.jar"/>
<resource-root path="activemq-kahadb-store-5.9.0.jar"/>
<resource-root path="activemq-openwire-legacy-5.9.0.jar"/>
<resource-root path="activemq-pool-5.9.0.jar"/>
<resource-root path="activemq-protobuf-1.1.jar"/>
<resource-root path="activemq-ra-5.9.0.jar"/>
<resource-root path="activemq-spring-5.9.0.jar"/>
<resource-root path="aopalliance-1.0.jar"/>
<resource-root path="commons-pool-1.6.jar"/>
<resource-root path="commons-logging-1.1.3.jar"/>
<resource-root path="hawtbuf-1.9.jar"/>
<resource-root path="spring-aop-3.2.4.RELEASE.jar"/>
<resource-root path="spring-beans-3.2.4.RELEASE.jar"/>
<resource-root path="spring-context-3.2.4.RELEASE.jar"/>
<resource-root path="spring-core-3.2.4.RELEASE.jar"/>
<resource-root path="spring-expression-3.2.4.RELEASE.jar"/>
<resource-root path="xbean-spring-3.14.jar"/>
</resources>
<exports>
<exclude path="org/springframework/**"/>
<exclude path="org/apache/xbean/**"/>
<exclude path="org/apache/commons/**"/>
<exclude path="org/aopalliance/**"/>
<exclude path="org/fusesource/**"/>
</exports>
<dependencies>
<module name="javax.api"/>
<module name="org.slf4j"/>
<module name="javax.resource.api"/>
<module name="javax.jms.api"/>
<module name="javax.management.j2ee.api"/>
</dependencies>
</module>
Also, you should really not create custom modules under \modules\system\layers\base\ as this is used by JBoss and could be modified during patches and new releases. You are best to either create your own layer or simply create you module directly under the /modules folder.
As previous answer has noted, especially in a standalone setup it might be easier to just directly deploy the RAR instead.
I am having trouble reading your question. In general, I would recommend deploying the A-MQ JCA rar file via either the command line CLI or via the web UI and not as a module. Just go to the web UI, find the "Deployments" page and deploy the A-MQ JCA.
I had the same problem when I followed the tutorial http://www.mastertheboss.com/jboss-frameworks/ironjacamar/configuring-a-resource-adapter-for-activemq-on-jbosswildfly.
I'm using a JBoss EAP 6.3.x and in my case the problem was in reference to the META-INF/ra.xml file. If I comment out the config-property below the note
<!-- NOTE disable the following property if you do not wish to deploy an embedded broker -->
I got the same error like you. If I removed the config-property the problem was solved and it's working as expected.

JBoss 7.1.1 Final Jasperreports 4.0.2 as a module

I am trying this new class loading feature of JB7, witch sounds pretty good and i want to implement in a new project, but i am kinda stuck at this point... this is what i got:
<module xmlns="urn:jboss:module:1.1" name="net.sourceforge.jasperreports">
<resources>
<resource-root path="commons-javaflow-20060411.jar"/>
<resource-root path="iText-2.1.0.jar"/>
<resource-root path="jasperreports-4.0.2.jar"/>
<resource-root path="jcommon-1.0.15.jar"/>
<resource-root path="jfreechart-1.0.14.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.apache.commons.beanutils"/>
<module name="org.apache.commons.collection"/>
<module name="org.apache.commons.digester" slot="1.7"/>
<module name="org.apache.commons.logging"/>
</dependencies>
</module>
Without the <module name="org.apache.commons.logging"/> dependency, the trace stack was showing an error of it being missing, even when this particular jar is already being deployed with the application by default, so i took out the jar from the app java libs folder and made a module for it, now my application hangs when the module net.sourceforge.jasperreports is needed, is there something am i missing?
This is the JBoss-deployment-structure if needed:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.apache.commons.collections"/>
<module name="org.apache.commons.logging"/>
<module name="net.sourceforge.jasperreports"/>
<module name="org.apache.log4j"/>
</dependencies>
<resources>
<resource-root path="."/>
</resources>
</deployment>
</jboss-deployment-structure>
Its a Java EE project deploying as a war.
I have <module name="org.apache.commons.collection"/>
And sould be <module name="org.apache.commons.collections"/>
And that was it... "-.-
Its weird because, when a module in Jboss sctructure fails to load, the war deployment fails and shows an error in the console, in this case it should be something about "org.apache.commons.collection not found" but somehow, my app was running normally, and any jasper report sevlet used was hanging eternally because of this missing module dependency.
Edit: Jboss doesn't show any error when a dependency is missing, it just hangs in that line. But it does show an error when a module fails to load resources.