Classloading with multiple EARs - jboss7.x

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 ?

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>

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

CDI 1.1 with JBoss

Is it possible to use CDI 1.1 with JBoss 7.1.1?
I have a single test war and would like to deploy this war together with weld 2.0.
I disabled the automatically loading of the weld module with the jboss-deployment-structure File:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.weld.core" />
</exclusions>
</deployment>
</jboss-deployment-structure>
I also tried to add a extra slot in the jboss/module folder:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.weld.core" />
<module name="org.jboss.weld.api" />
<module name="org.jboss.weld.spi" />
</exclusions>
<dependencies>
<module name="org.jboss.weld.core" slot="2.0" />
<module name="org.jboss.weld.api" slot="2.0" />
<module name="org.jboss.weld.spi" slot="2.0" />
</dependencies>
</deployment>
</jboss-deployment-structure>
The deployment failed in both cases because JBoss apparently needs weld for the deployment.
So is it possible to use CDI 1.1 with JBoss 7.1.1 and how?
No, it's not possible. You could try weld-servlet from 2.0 but it won't work with EJB and will get quite confused. The app server integration is different in weld 2.0, so it won't work with AS7.
JBoss Weld community has an installation script to update JBoss AS Weld Subsystem to Weld 2.0;
https://github.com/weld/as7-weld-subsystem . Wildfly is currently in Alpha4 so this may be a better option at this time.

How to determine implemented interfaces for jms connection factories using Spring 3.2.1, Jboss AS7, Aspectj 1.7.1 java 1.7?

We are developing a project in java 1.6 using JBOSS AS7 and we use among others: Aspectj and HornetQ.
We need to upgrade to java 1.7 so we use ASpectj 1.7.1. During the deployment we get the following exception:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'eventsJmsTemplate' defined in class path resource [com/company/project/jms/jms.xml]:
Cannot resolve reference to bean 'jmsConnectionFactory' while setting bean property 'connectionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'jmsConnectionFactory':
Post-processing of the FactoryBean's object failed;
nestedexception is java.lang.IllegalArgumentException:
warning can't determine implemented interfaces of missing type
com.company.project.aspects.MBeanAttributesAdvice [Xlint:cantFindType]
The mbean is:
<jee:jndi-lookup id="jmsConnectionFactory" jndi-name="java:/JmsXA" />
On other project, We had the same exception when we use a JPA datasource:
<jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/table" />
<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
and we manage to solve the issue by adding on jboss-deployment-structure the module depedency: org.jboss.ironjacamar.jdbcadapters
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<module name="org.jboss.ironjacamar.jdbcadapters" />
</dependencies>
</deployment>
</jboss-deployment-structure>
is there any module that we can add in order to pass this exception? or any other way to solve this issue?
I would like to share with you the solution. Add the modules: org.hornetq, org.hornetq.ra , org.jboss.ejb3, org.jboss.ejb-client.
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<module name="org.jboss.ironjacamar.jdbcadapters" />
<module name="org.hornetq" />
<module name="org.hornetq.ra" />
<module name="org.jboss.ejb3" />
<module name="org.jboss.ejb-client" />
</dependencies>
</deployment>
</jboss-deployment-structure>
I would like to document what works for me, even if I'm late to this question.
I'm using JBoss 7.1.1 and Spring 3.2.4:
Using, say, annotation based Aspects in your Spring setup will cause the Aspect-Weaver try to go over all components you have, including those you got via JNDI-lookup. The Weaver will stumble over those components, since (I read that somewhere) the Classloader used to load them (JBoss' ModuleClassLoader in my case) will know nothing about my Aspect (living in my project's classloader) and fail with Xlint:cantFindType.
Proxying those components by something within the realm of the project's Classloader solves this problem.
For JDBC datasources:
<jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/myDS" proxy-interface="javax.sql.DataSource" />
For JMS ConnectionFactory
<jee:jndi-lookup id="connectionFactory" jndi-name="java:/JmsXA" proxy-interface="javax.jms.ConnectionFactory"/>
And so on.
This way I do not have to include any extra modules like org.jboss.ironjacamar.jdbcadapters and such.

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.