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

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>

Related

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

How do I tell Wildfly that I want to use the Wildfly module when deploying an EAR?

I'm using Wildfly 11 with Java 8. Previously I was building a WAR file, which required the dom4j JAR file. Rather than including it in the WAR's WEB-INF/lib directory, I linked to the Wildfly modules JAR by adding an entry in the WEB-INF/jboss-deployment-structure.xml. Now I want to package this WAR as part of an EAR. So I created a jboss-deploymebnt-structure.xml file at teh root of the EAR, with these lines
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<sub-deployment name="myapp.war">
<dependencies>
...
<module name="org.dom4j" />
Now when I deploy the EAR, the WAR is failing to deploy with errors like
service jboss.undertow.deployment.default-server.default-host./myapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./orgsclient: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/spring/infrastructure.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/STAXEventReader
What else do I need to do to tell the EAR file that the WAR is using the Wildly module dom4j as opposed to one I'm packaging with the EAR itself?
Check if your jboss-deploymebnt-structure.xml is correctly placed in META-INF subfolder (beside with application.xml) of your built ear package. If you're using maven ear plugin you should put the xml file in:
ear/src/main/application/META-INF/jboss-deploymebnt-structure.xml
Please note the application folder is default resource folder for ear plugin.
If you still have a problem with NoClassDefFound, try to redeclare the dependency as 'ear global' and set it as exported
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.dom4j" slot="main" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
If you still have a problem then declare the module as a global module in wildlfy config (under the ee subsystem). Then you can get rid off the the jboss deployment descriptor at all.
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<global-modules>
<module name="org.dom4j">
</global-modules>
...

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

How to use JBoss 7 jar libraries in my web application?

I'm running JBoss 7.1.1 and I can see that one of the libraries I need to use is already included in JBoss (I see it in /jboss-as-7.1.1/modules/org/codehaus/jackson/jackson-core-asl/main/jackson-core-asl-1.9.2.jar). How can I access it from my web app if it's not in web-inf/lib? Do I need to declare it in one of the xml files?
Check out Class Loading in AS7 you either need a jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.codehaus.jackson.jackson-core-asl" />
</dependencies>
</deployment>
</jboss-deployment-structure>
or a header in your MANIFEST.MF
Dependencies: org.codehaus.jackson.jackson-core-asl

Classloading with multiple EARs

I have a couple of EARs deployed in JBoss 7 AS.
App1.ear serves as a library to other EARs.
App2.ear has following deployment XML,
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="deployment.app1.ear" export="true" />
</dependencies>
</deployment>
<sub-deployment name="app2_ejb1.jar">
<dependencies>
<!-- Is it required ??? -->
<module name="deployment.app1.ear" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
JBoss throws following exception while deploying the applications.
Failed to load module: deployment.app2.ear.app2_ejb1.jar:main
Caused by: org.jboss.modules.ModuleLoadException: Could not load module deployment.app1.ear:main as corresponding module spec service deployment.app1.ear:main was not found.
If childEAR depends on parentEAR and if the dependencies are specified accordingly in the XML, I would expect subdeployments of childEAR to wait untill parentEAR is successfully & completely deployed.
Does my understanding contradicts the JBoss 7 classloading architecture ?
Can someone provide a solution ?