0
votes

We have a Maven multi-module project with some ejb and war modules. One of the modules works as an integration tester for the whole platform. We have successfully tested ejbs, including security, dependency injection and transactions by using the embedded EjbContainer.

Now we want to add CDI to the mix and here it is when problems arise.

Problem

According to the doc, in order to activate CDI we simply have to add an empty beans.xml into the META-INF folder of the ejb module in which we want to activate it. Simple as that, right after doing it the embedded server cannot start and therefore we cannot run any integration test.

The exception thrown is:

java.lang.RuntimeException: javax.ejb.EJBException: Failed to deploy EJB modules - see log for details
...
Caused by: javax.ejb.EJBException: Failed to deploy EJB modules - see log for details

The rest of the stackTrace just points to the line in which we try to start the server and provides no useful information.

Two things to note:

  • The startup fails even without having any @Injected bean.
  • CDI works fine when running in the non-embedded glassfish, so our problem is only on testing.

Our system

Maven project structure

myproject
myproject-ear
myproject-domain
myproject-ejb1
myproject-ejb2
myproject-war
myproject-test

Environment
- Glassfish 3.1, 3.2
- TestNG

File[] modules = {
new File("/target/classes"), 
new File("../myproject-ejb1/target/classes"),
new File("../myproject-ejb2/target/classes")
...};
properties.put(EJBContainer.APP_NAME, "myproject");  
properties.put(EJBContainer.MODULES, modules); 
properties.put("org.glassfish.ejb.embedded.glassfish.instance.root","./src/main/resources");    
EJBContainer container = EJBContainer.createEJBContainer(properties);

What we have found so far

We have enabled finer logging on glassfish but still we get no clue of what is failing.

We know about Arquillian, and we consider it as a possibility but we would like try one last time with the standard api.

Any idea of what could we be doing wrong?

1

1 Answers

0
votes

Last time I used embedded glassfish by hand I was setting org.glassfish.ejb.embedded.glassfish.installation.root property rather than instance. Try this.

As a side note: I highly recommend trying Arquillian as it gives you flexibility when it comes to choosing the target container, as your tests are portable. And you don't need to fiddle with this clumsy bootstrapping code anymore. Also I'm not a big fan of embedded containers as they often give headaches with classloaders.