How to share common libraries in Jboss7 - jboss7.x

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

Related

JCache with Infinispan in Wildfly 14 generate Unsatisfied dependencies for type InfinispanExtensionEmbedded with qualifiers #Default

I'm following some guide to set JCache in Wildfly 14 enviroment using as provider Infinispan.
I followed these steps :
- I downloaded the wildfly module version 9.4.14 from Infinispan website
- I copied the content of the zip in the module dir of Wildfly
- I added to my application the file jboss-deployment-structure.xml
- I added the interceptors to the beans.xml file on my application
- I add the annotation #CacheResult to a function
- I start Wildfly and I get the following error
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type InfinispanExtensionEmbedded with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject private org.infinispan.cdi.embedded.AdvancedCacheProducer.infinispanExtension
I add information that can be useful. The application that I'm deploying on wildfly is an ear ant this is the structure that I'm using :
ear file
lib
META-INF
JAR library file
META-INF
beans.xml file
jboss-deployment-structure.xml
WAR file
jboss-deployment-structure.xml :
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="org.infinispan" slot="ispn-9.4" services="export"/>
<module name="org.infinispan.cdi.embedded" slot="ispn-9.4" services="export"/>
<module name="org.infinispan.jcache" slot="ispn-9.4" services="export"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
beans.xml :
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
<interceptors>
<class>org.infinispan.jcache.annotation.InjectedCacheResultInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCachePutInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCacheRemoveEntryInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCacheRemoveAllInterceptor</class>
<class>org.infinispan.jcache.annotation.CacheResultInterceptor</class>
<class>org.infinispan.jcache.annotation.CachePutInterceptor</class>
<class>org.infinispan.jcache.annotation.CacheRemoveEntryInterceptor</class>
<class>org.infinispan.jcache.annotation.CacheRemoveAllInterceptor</class>
</interceptors>
</beans>
With this standard configuration, I expect the interceptor start to defined in the beans.xml start to function, so I can use a default cache container in the application
org.infinispan.cdi.embedded and org.infinispan.jcache modules have SPI extensions inside them (jar/META-INF/services folder). Just add services="export" in module dependencies in jboss-deployment-structure.xml to enable them.
Here is mine jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<module-alias name="deployment.magic-blog" />
<dependencies>
<module name="org.infinispan.cdi.embedded" slot="ispn-9.4" export="true" services="export" />
<module name="org.infinispan.jcache" slot="ispn-9.4" export="true" services="export" />
<module name="javax.cache.api" slot="ispn-9.4" export="true"/>
</dependencies>
</deployment>

logger in custom module of widfly is not working

I am working on web application project in wildfly. I have a web-application project which has dependency on authentication jar file. Instead of placing the authentication jar file in WEB-INF/lib, the authentication jar file placed in wildfly custom module says "com.example.authentication"
The authentication project does have log4j propery file for the logger, however, log4j jar file has been invoked common module says "com.example.logger" having log4j.jar file.
I expect the logger to be working in authentication project but the logger is not working for authentication module. NO errors or warnings on this.
Webapplication - WEB-INF/jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<module name="com.example.authentication"/>
</deployment>
</jboss-deployment-structure>
com.example.authentication - module.xml
<module xmlns="urn:jboss:module:1:3" name="com.example.authentication">
<resources>
<resource-root path="authentication.jar"
</resources>
<dependencies>
<module name="com.example.logger" export="true"/>
</dependencies>
</module>
com.example.logger - module.xml

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>

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

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?

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.