1

プロジェクトで Arquillian テストを実行しようとしていますが、動作しません。CDI、EJB、Hibernate、および JBoss-AS-7.1.0 サーバーを使用しています。

私はこのようなクラスを持っています:

public interface AppManager {
    Customer findCustomer(String id);
    Customer saveCustomer(Customer entity);
}

実現

@Local(AppManager.class)
@Stateless
public class AppManagerBean implements AppManager {
    @Inject
    EntityManager em;  // injecting from producer class

    @Override
    public Customer findCustomer(String id) {
        Customer result = null;
        try {
            result = em.find(Customer.class, id);
        } catch (NoResultException ignored) {}
        return result;
    }

    @Override
    public Customer saveCustomer(Customer entity) {
        if (null == entity.getLastModified()) em.persist(entity);
        else entity = em.merge(entity);
        return entity;
    }
}

テストは次のようになります。

@RunWith(Arquillian.class)
public class CustomerRegistrationTest {
    @Inject
    AppManagerBean manager; 

    @Deployment
    public static WebArchive createTestArchive() {
        return ShrinkWrap.create(WebArchive.class, "test.war")
        // adding classes omitted
        .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
        .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
        .addAsWebInfResource("test-ds.xml");
    }

    @Test
    public void testRegister() throws Exception {
        Customer jack = new Customer("some_string_id", "Jack", "ex@example.com");
        manager.saveCustomer(jack);
        assertEquals("Jack", manager.findCustomer("some_string_id").getName());
    }
}

テストを実行しようとすると、例外が発生します:

   org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies
 for type [ManagerBean] with qualifiers [@Default] at injection point [[field]
 @Inject com.example.ejb.CustomerRegistrationTest.manager]

他の指定子でクラスを注入しようとしましたが、無意味でした。このエラーは、考えられるすべての結果の中で最も単純です。

アップデート:

Arquillian.xml

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

    <defaultProtocol type="Servlet 3.0" />

    <container qualifier="jboss" default="true">    
   </container>
</arquillian>

インターフェイスを注入すると

@EJB
private AppManager manager;

私はこの巨大なエラーログを取得しました:

14:00:30,454 ERROR [org.jboss.ejb3.invocation] (http-localhost-127.0.0.1-8080-1) JBAS014134: EJB Invocation failed on component AppManagerBean for method public abstract com.example.model.Customer com.example.ejb.AppManager.saveCustomer(com.example.model.Customer): javax.ejb.EJBException: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at com.example.ejb.AppManager$$$view5.saveCustomer(Unknown Source) [classes:]
      at com.example.rest.CustomerRegistrationTest.testRegister(CustomerRegistrationTest.java:76) [classes:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) [arquillian-junit.jar:]
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [arquillian-junit.jar:]
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270) [arquillian-junit.jar:]
      at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60) [arquillian-core.jar:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) [arquillian-core.jar:]
      at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38) [arquillian-core.jar:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) [arquillian-core.jar:]
      at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75) [arquillian-core.jar:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-core.jar:]
      at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60) [arquillian-core.jar:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-core.jar:]
      at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89) [arquillian-core.jar:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) [arquillian-core.jar:]
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) [arquillian-core.jar:]
      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111) [arquillian-core.jar:]
      at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240) [arquillian-junit.jar:]
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) [arquillian-junit.jar:]
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) [arquillian-junit.jar:]
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) [arquillian-junit.jar:]
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) [arquillian-junit.jar:]
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) [arquillian-junit.jar:]
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) [arquillian-junit.jar:]
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199) [arquillian-junit.jar:]
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147) [arquillian-junit.jar:]
      at org.junit.runner.JUnitCore.run(JUnitCore.java:157) [arquillian-junit.jar:]
      at org.junit.runner.JUnitCore.run(JUnitCore.java:136) [arquillian-junit.jar:]
      at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65) [arquillian-junit.jar:]
      at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160) [arquillian-protocol.jar:]
      at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126) [arquillian-protocol.jar:]
      at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90) [arquillian-protocol.jar:]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
      at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
      at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
      at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:85) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:65) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:62) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.pool.AbstractPool.create(AbstractPool.java:60) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:128) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:47) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      ... 112 more
Caused by: java.lang.RuntimeException: Error looking up java:comp/env/com.example.util.GcmSenderProducer/senderId in JNDI
      at org.jboss.weld.injection.spi.helpers.AbstractResourceServices.resolveResource(AbstractResourceServices.java:51) [weld-spi-1.1.Final.jar:20110112-1536]
      at org.jboss.weld.util.Beans.injectEEFields(Beans.java:638) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:160) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:290) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.AbstractReceiverBean.getReceiver(AbstractReceiverBean.java:73) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:131) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:299) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:681) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:118) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:703) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:712) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.SessionBean$1$1.proceed(SessionBean.java:176) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.bean.SessionBean$1.inject(SessionBean.java:173) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.as.weld.injection.WeldEEInjection.inject(WeldEEInjection.java:78) [jboss-as-weld-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:60) [jboss-as-weld-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
      at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]
      ... 120 more
Caused by: javax.naming.NameNotFoundException: env/com.example.util.GcmSenderProducer/senderId -- service jboss.naming.context.java.module.test.test.env."com.example.util.GcmSenderProducer".senderId
      at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)
      at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:123)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)
      at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.7.0_25]
      at org.jboss.weld.injection.spi.helpers.AbstractResourceServices.resolveResource(AbstractResourceServices.java:47) [weld-spi-1.1.Final.jar:20110112-1536]
      ... 156 more
4

3 に答える 3

0

この質問への答え:

問題が見つかりました。解決策は、Web アーカイブ カップルの外部ライブラリと web.xml を環境エントリと共に挿入することでした。

あいまいで、同様の問題に直面している人にはあまり役に立ちません。

コードにバグがあります。これは正しくありません:

  @Inject
    AppManagerBean manager; 

なんで?ステートレス Bean で、それがローカル ビジネス インターフェースを提供する EJB であることを既に宣言しているため、次のようになります。

@Local(AppManager.class)

したがって、非ビジネス インターフェースを使用して EJB を @Inject する場合は、@Local インターフェースを使用したら、Bean のメタデータを

@LocalBean 

注釈。

これにより、リゾルバーは @Inject WELD-001408 例外を解決します。

Bean に @LocalBean という注釈が付けられたら、実装クラスを @Inject できるはずです。さらに、@Local アノテーションをローカル Bean に置くことによって、または単に @Local アノテーションを既に保持しているビジネス インターフェースを実装することによって、@Local ビジネス インターフェースを宣言できるようにする必要があります。

于 2016-12-19T14:57:11.287 に答える
-1

問題が見つかりました。解決策は、Web アーカイブ カップルの外部ライブラリと web.xml を環境エントリと共に挿入することでした。

于 2013-08-21T14:22:44.017 に答える