This discussion is archived
2 Replies Latest reply: Jul 17, 2012 3:33 AM by Justin James RSS

Embedded EJBContainer  // No EJBContainer provider available

Justin James Newbie
Currently Being Moderated
Hello Friends

Environment :

Can you please share with me the EJBContainer.PROVIDER value while using weblogic12c.
I created an EJB3.1 stateless session bean, now I'm trying to use embedded ejb container for JUnit test class within the same EJB project.

I'm already followed this link -
but no luck.While running JUnit test class, getting following exception you can find at the bottom this post.

I'm using these packages from javax.ejb_3.1.0.jar
import javax.ejb.embeddable.EJBContainer;
import javax.ejb.spi.EJBContainerProvider;

Note : The same test project is running well in glassfish server.

Thanks in advance,
Have more fun with Java.

Exception :
javax.ejb.EJBException: No EJBContainer provider available for requested provider: 
        javax.ejb.spi.EJBContainerProvider: no provider names had been found.
     at javax.ejb.embeddable.EJBContainer.reportError(
     at javax.ejb.embeddable.EJBContainer.createEJBContainer(
     at com.justin.math.ejb.test.CalculatorEJBJUTest.init(
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(
     at java.lang.reflect.Method.invoke(
     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
     at org.junit.runners.model.FrameworkMethod.invokeExplosively(
     at org.junit.internal.runners.statements.RunBefores.evaluate(
     at org.junit.internal.runners.statements.RunAfters.evaluate(
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Test Class :
package com.justin.math.ejb.test;

import static org.junit.Assert.*;

import java.util.Properties;
import javax.ejb.embeddable.EJBContainer;
//import javax.ejb.spi.EJBContainerProvider;
import javax.naming.NamingException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.justin.math.ejb.CalculatorEJB;

public class CalculatorEJBJUTest {
     static EJBContainer ejbContainer; 
     static CalculatorEJB calculatorEJB;
     public static void init() {          
          String globalJndiName = "java:global/classes/CalculatorEJB";
          //String localJndiName = "java:module/CalculatorEJB";
          Properties properties = new Properties();
          try {
               properties.setProperty(EJBContainer.MODULES, "CalculatorEJB");
               properties.setProperty(EJBContainer.PROVIDER, "javax.ejb.spi.EJBContainerProvider");
                        //Also tried without setting properties in WLS12c. Glassfish was fine without properties.
               ejbContainer = EJBContainer.createEJBContainer(properties);
                        //Just trying both global and local jndi names
               //calculatorEJB = (CalculatorEJB) ejbContainer.getContext().lookup(localJndiName);
               calculatorEJB = (CalculatorEJB) ejbContainer.getContext().lookup(globalJndiName);
          } catch (NamingException e) {
     public static void release() {
          if(ejbContainer != null)
     public void testAdd() {
          int result = calculatorEJB.add(1, 2);
          assertEquals(3, result);
     public void testMultiply() {
          int result = calculatorEJB.multiply(1, 2);
          assertEquals(2, result);