2

Some time ago, I tried out the embeddable container API of EJB 3.1 with GlassFish.

Now I tried to do the same thing with JBoss 7.1, but could not make it work. I spent some time researching the problem, but only found others having this problems and no answers or examples to it.

I do know of Arquillian, which more or less eliminates the need of an embeddable container for testing EJBs, but still am interested in a working solution.

So, here's the code which works with GlassFish:

Map<String, Object> params = new HashMap<String, Object>();
//param is needed due to GlassFish bug http://java.net/jira/browse/GLASSFISH-16285
params.put(EJBContainer.APP_NAME, "MyAppName");
EJBContainer container = EJBContainer.createEJBContainer(params);
MyBean instance = (MyBean) container.getContext().lookup("java:global/MyAppName/classes/MyBean");
instance.doSomething("data");
container.close();
Alexander Rühl
  • 6,769
  • 9
  • 53
  • 96

0 Answers0