Hi there, My name is Antonio
I just created a new web-project using maven.
I'm trying to run a unit-test for my class in maven but I'm not able to
instanciate a container where to get the bean from.
The test i wrote was this
import java.util.Properties;
import javax.ejb.EJB;
import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author antonio
*/
public class RepositoryJUnitTest {
public RepositoryJUnitTest() {}
@BeforeClass
public static void setUpClass() {}
@AfterClass
public static void tearDownClass() {}
@Before
public void setUp() throws NamingException
{
Properties props =
new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
Context context =
new InitialContext(props);
//Repository repo = (Repository) context.lookup("Repository");
}
@After
public void tearDown() {}
@Test
public void createEntityManagerTest() throws NamingException
{
//final Context context =
// EJBContainer.createEJBContainer().getContext();
//Repository one =
// (Repository)
context.lookup("java:global/simple-singleton/Repository");
//Properties p =
// new Properties();
//p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
//p.put("singletonContainer", "new://Container?type=SINGLETON");
//p.put("singletonContainer.PoolSize", "0");
//p.put("singletonContainer.BulkPassivate", "1");
//Context context =
// new InitialContext(p);
//@PersistenceContext
//EntityManager em;
EntityManager em =
Repository.createEntityManager();
Assert.assertNotNull(em);
}
}
And the error I'm getting is the next one
[surefire:test]
Surefire report directory:
/home/antonio/builds/branches/research/tomee_framework/om/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.altobridge.omc.orm.repository.RepositoryJUnitTest
INFO -
********************************************************************************
INFO - OpenEJB http://openejb.apache.org/
INFO - Startup: Mon Feb 18 16:28:33 GMT 2013
INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
INFO - Version: 4.5.1
INFO - Build date: 20121209
INFO - Build time: 08:47
INFO -
********************************************************************************
INFO - openejb.home =
/home/antonio/builds/branches/research/tomee_framework/om
INFO - openejb.base =
/home/antonio/builds/branches/research/tomee_framework/om
INFO - Created new singletonService
org.apache.openejb.cdi.ThreadSingletonServiceImpl@423a346f
INFO - Succeeded in installing singleton service
INFO - Cannot find the configuration file [conf/openejb.xml]. Will
attempt to create one for the beans deployed.
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found EjbModule in classpath:
/home/antonio/builds/branches/research/tomee_framework/om/target/classes
INFO - Beginning load:
/home/antonio/builds/branches/research/tomee_framework/om/target/classes
INFO - Configuring enterprise application:
/home/antonio/builds/branches/research/tomee_framework/om/classpath.ear
SEVERE - FATAL ERROR: Unknown error in Assembler. Please send the
following stack trace and this message to [email protected] :
java.lang.ArrayIndexOutOfBoundsException: 0
at
org.apache.openejb.config.AnnotationDeployer$MethodMember.getType(AnnotationDeployer.java:5066)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.buildEjbRef(AnnotationDeployer.java:3752)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.buildAnnotatedRefs(AnnotationDeployer.java:3519)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2612)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:1721)
at
org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:342)
at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:338)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:827)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:705)
at
org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:476)
at
org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:364)
at
org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:343)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:269)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
at
org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:69)
at
org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:51)
at
org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:40)
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at
com.altobridge.omc.orm.repository.RepositoryJUnitTest.setUp(RepositoryJUnitTest.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
SEVERE - OpenEJB has encountered a fatal error and cannot be started:
Assembler failed to build the container system.
org.apache.openejb.OpenEJBException:
java.lang.ArrayIndexOutOfBoundsException: 0: 0
at
org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:357)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:269)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
at
org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:69)
at
org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:51)
at
org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:40)
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at
com.altobridge.omc.orm.repository.RepositoryJUnitTest.setUp(RepositoryJUnitTest.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at
org.apache.openejb.config.AnnotationDeployer$MethodMember.getType(AnnotationDeployer.java:5066)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.buildEjbRef(AnnotationDeployer.java:3752)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.buildAnnotatedRefs(AnnotationDeployer.java:3519)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2612)
at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:1721)
at
org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:342)
at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:338)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:827)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:705)
at
org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:476)
at
org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:364)
at
org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:343)
... 49 more
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.222
sec <<< FAILURE!
Results :
Tests in error:
createEntityManagerTest(com.altobridge.omc.orm.repository.RepositoryJUnitTest):
Attempted to load OpenEJB. java.lang.ArrayIndexOutOfBoundsException: 0: 0
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 19.755s
Finished at: Mon Feb 18 16:28:36 GMT 2013
Final Memory: 23M/226M
------------------------------------------------------------------------
Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test)
on project omc: There are test failures.
Please refer to
/home/antonio/builds/branches/research/tomee_framework/om/target/surefire-reports
for the individual test results.
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please
read the following articles:
[Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I'm not sure if I understand the error but it says
IndexOutOfboundsException: 0
Does that mean that there is no container?
What 0 means? 0 Beans? 0 containers? 0 Configurations?
I would like to know what is the container doing that can not be
instantiated.
:-D
--
Regards.
Antonio