1

Can anyone please guide me on how to use Arquillian with WildFly 10. I have recently migrated my application from JBoss 7 to WildFly 10. Arquillian used to work with JBoss 7, but the same configuration is not working on WildFly 10.

I am able to integrate now, however my EJBs with JNDI names as "java:global/xyz/xyzEMFactor" is failing with following error:

Caused by: java.lang.Exception: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.test.test.env.\"com.xyz.abc.poc.knowledge_ba‌​se.ontology.DBContex‌​tBean\".emFactory is missing [jboss.naming.context.java.global.xyz_dal.xyzpEMFactory‌​]"]} at org.jboss.as.controller.client.helpers.standalone.impl.Serve‌​rDeploymentPlanResul‌​tFuture.getActionRes‌​ult(ServerDeployment‌​PlanResultFuture.jav‌​a:134)

Following is my class:

@AccessTimeout(5 * 60 * 60 * 1000)
@StatefulTimeout(-1)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class DBContextBean<T> {
    @Inject
    @EJB(lookup = "java:global/xyz_dal/xyzEMFactory")
    private xyzEMFactory emFactory;
}
Purnendu Rath
  • 45
  • 1
  • 11
  • You need to show your test, arquillian.xml file and any errors that you're encountering – Steve C Aug 09 '17 at 10:12
  • The thing is that this is a big change, for example CDI is quite different spec. Have you tried running same WAR in Wildfly 10 and check if it works? – lordofthejars Aug 09 '17 at 21:29

2 Answers2

0

I don't know how this could work in JBoss7 but: either @EJB or @Inject, I presume @Inject, is superfluous. In my experience wildfly is sometimes more rigorous than jboss7 when looking at unclear constructs.

@Inject
@EJB(lookup = "java:global/xyz_dal/xyzEMFactory")
xyzEMFactory emFactory;

CDI can't inject ejbs. What we do sometimes is:

@Produces
@EJB(lookup = "java:global/xyz/xyzEMFactory")
xyzEMFactory emFactory;

Then you can use at other places

@Inject
xyzEMFactory emFactory;

because the ejb-injected bean can be used as Producer-Field.

Purnendu Rath
  • 45
  • 1
  • 11
aschoerk
  • 3,333
  • 2
  • 15
  • 29
0

It was because, The testable war file, i was creating a jar as,

@Deployment(name = "xyz_dal", order = 3)
public static Archive<?> createDeployment() {
    JavaArchive jar = ShrinkWrap.create(JavaArchive .class, "xyz_dal.jar")
            .addClasses(xyzEMFactory.class, DBContextBean.class, xyzDao.class)
            .addPackages(true, "com.xyz.abc.poc.entities")
            .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml").setManifest(new Asset() {
                @Override
                public InputStream openStream() {
                    // dependency management
                    return ManifestBuilder.newInstance()
                            .addManifestHeader("Dependencies", "xyz,javax.api,deployment.abc_common.jar")
                            .openStream();
                }
            });
    return jar;
}

It worked when i changed it to

@Deployment(name = "xyz_dal", order = 3)
public static Archive<?> createDeployment() {
    WebArchive jar = ShrinkWrap.create(WebArchive.class, "xyz_dal.war")
            .addClasses(xyzpEMFactory.class, DBContextBean.class, xyzDao.class)
            .addPackages(true, "com.xyz.abc.poc.entities")
            .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml").setManifest(new Asset() {
                @Override
                public InputStream openStream() {
                    // dependency management
                    return ManifestBuilder.newInstance()
                            .addManifestHeader("Dependencies", "xyz,javax.api,deployment.abc_common.jar")
                            .openStream();
                }
            });
    return jar;
}

It was because when i was creating a testable jar,the container wraps the jar in a test.war, and hence the context "java:global/xyz/xyzEMFactory" was not available.

Purnendu Rath
  • 45
  • 1
  • 11