Hi,
I want to use ApplicationComposer to unit test (in Eclipse) a EJB with an
injected PersistenceContext. But I'm getting the following error:
SEVERE - FAIL ... SimpleService: Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "test"
SEVERE - Invalid EjbModule(name=jax-ws, path=null)
Interstingly the path is null, I suspect I am not setting something required
in my @Module method? The following test fails:
package au.test;
import static org.junit.Assert.assertNotNull;
import javax.ejb.EJB;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.StatelessBean;
import org.apache.openejb.junit.ApplicationComposer;
import org.apache.openejb.junit.EnableServices;
import org.apache.openejb.junit.Module;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(ApplicationComposer.class)
@EnableServices("ejdb")
public class SimpleServiceApplicationComposerTest
{
@EJB
private SimpleServiceWs simpleService;
@Module
// @Classes({ SimpleService.class })
public EjbJar myWebApplication()
{
EjbJar ejbJar = new EjbJar("jax-ws");
ejbJar.addEnterpriseBean(new StatelessBean(SimpleService.class));
return ejbJar;
}
@Test
public void test()
{
assertNotNull(simpleService);
}
}
But he following test does work?!:
package au.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import javax.ejb.embeddable.EJBContainer;
import org.junit.Test;
public class SimpleServiceTest
{
@Test
public void test() throws Exception
{
EJBContainer ejbContainer = EJBContainer.createEJBContainer();
Object object =
ejbContainer.getContext().lookup("java:global/jaxws-test/SimpleService");
assertTrue(object instanceof SimpleServiceWs);
assertEquals("hello", ((SimpleServiceWs) object).doSomething());
}
}
I have verified that the persistence xml does exist in the classpath output
(META-INF/persistence.xml).
--
View this message in context:
http://openejb.979440.n4.nabble.com/Missing-required-persistence-xml-when-running-test-with-ApplicationComposer-tp4660284.html
Sent from the OpenEJB User mailing list archive at Nabble.com.