Hi,

I believe this was already discussed on this list, but I didn't found the
topic on google.

I'm able to test EJBs using the EJBContainer as mentioned on TomEE
examples.

But when I try to test a CDI bean I'm getting a
UnsatisfiedResolutionException.

I tried to add a beans.xml to /src/test/resources/META-INF but no success.

Do I need DeltaSpike on this case?

Thanks


INFORMAÇÕES - Existing thread singleton service in SystemInstance():
org.apache.openejb.cdi.ThreadSingletonServiceImpl@4b4b25c8
INFORMAÇÕES - OpenWebBeans Container is starting...
INFORMAÇÕES - Adding OpenWebBeansPlugin : [CdiPlugin]
INFORMAÇÕES - Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
GRAVE - CDI Beans module deployment failed
org.apache.webbeans.exception.inject.DeploymentException:
javax.enterprise.inject.UnsatisfiedResolutionException: Api type
[br.com.test.CdiBean] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name :  bean, Bean Owner :
[CdiBeanTest, Name:null, WebBeans Type:MANAGED, API
Types:[java.lang.Object,br.com.test.EjbContainerTest,br.com.test.CdiBeanTest],
Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:215)
at
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:192)
at
org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:160)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41)
at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:846)
at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:652)
at
org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:335)
at
javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at br.com.test.EjbContainerTest.setUp(EjbContainerTest.java:43)
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:606)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
at
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api type
[br.com.test.CdiBean] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name :  bean, Bean Owner :
[CdiBeanTest, Name:null, WebBeans Type:MANAGED, API
Types:[java.lang.Object,br.com.test.EjbContainerTest,br.com.test.CdiBeanTest],
Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
at
org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at
org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:195)
at
org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:960)
at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:491)
at
org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:422)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:202)
... 32 more


----------------------------------------------------------------------------------------

@Named
public class CdiBean
{
public double randomNumber()
{
return Math.random();
}
}


----------------------------------------------------------------------------------------

public class CdiBeanTest extends EjbContainerTest
{
//@Inject
//private StatelessEjb ejb;

@Inject
private CdiBean bean;

@Test
public void f()
{
//System.out.println(ejb.randomNumber());
System.out.println(bean.randomNumber());
}
}


----------------------------------------------------------------------------------------

public class EjbContainerTest
{
protected EJBContainer container;

@BeforeClass
public void setUp() throws Exception
{
final Properties properties = new Properties();
properties.setProperty("openejb.embedded.remotable", "true");
properties.setProperty("openejb.autocreate.jta-datasource-from-non-jta-one",
"false");


                // dataSource setup ommited

container = EJBContainer.createEJBContainer(properties);
}

@BeforeMethod
public void inject() throws NamingException
{
if(container != null)
{
container.getContext().bind("inject", this);
}
}

@AfterClass
public void close()
{
if(container != null)
{
container.close();
container = null;
}
}
}

Reply via email to