Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

SKP's Java/Java EE Gotchas: Manifest Dependencies

DZone's Guide to

SKP's Java/Java EE Gotchas: Manifest Dependencies

If you're using Arqullian, ShrikWrap, Infinispan, and WildFly and find yourself plagued by illegal argument exceptions, your manifest might be your answer.

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

This issue troubled me for almost half a day, so this should be helpful for anyone using Arquillian, ShrinkWrap, and Infinispan with WildFly.

Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: 
Can not set org.infinispan.manager.CacheContainer 
field com.psl.roddy.gw.cache.manager.CacheManager.cacheContainer 
to org.jboss.as.clustering.infinispan.DefaultCacheContainer


Caused by: java.lang.IllegalArgumentException: 
Can not set org.infinispan.manager.CacheContainer 
field com.psl.roddy.gw.cache.manager.CacheManager.cacheContainer 
to org.jboss.as.clustering.infinispan.DefaultCacheContainer


These are the list of steps to be followed to resolve this:

1. Add the MANIFEST.MF to src/test/resources with this content [MANIFEST.MF]:

Dependencies: org.infinispan export

2. Modify the standalone.xml or standalone-full.xml [WILDFLY/INFINISPAN]:

Your standalone-full.xml will already have the following entry:

<subsystem xmlns="urn:jboss:domain:ee:2.0">
...
</subsystem>


Add the following within the <subsystem> tags:

<global-modules> 
    <module name="org.infinispan" slot="main"/>
</global-modules>


3. To the Test Case/Deployment, Add the following  [ARQUILLIAN]

WebArchive res = ShrinkWrap.create(WebArchive.class, "test.war");        
...
res.addAsManifestResource("MANIFEST.MF");


This is the ONLY way to achieve this, though you may find suggestions all over that require you to change the pom.xml (maven-jar-plugin, maven-ejb-plugin,maven-war-plugin) or that suggest the use of adding the string (Dependencies: org.infinispan export) directly to the MANIFEST.MF created by Arquillian Test Case. 

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:
java ,arquillian ,dependency management ,infinispan ,wildfly

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}