为什么我必须注入一个属性作为接口?

时间:2015-02-03 16:49:48

标签: java dependency-injection ejb

我是注射新手......我不明白为什么我必须注入接口而不是使用对象的类......

...代码

            public interface IUserDAO extends GenericDAO<User, Integer> {

        }

    @Stateless
    public class UserDao extends JPADAO<User, Integer> implements IUsuarioDAO {

    ...methods
    }

public abstract class JPADAO<T, ID extends Serializable> implements GenericDAO<T, ID> {

    protected final Class<T> entityClass;

    @PersistenceContext(unitName = "PUnit")
    private EntityManager em;


...methods...

}

当我注入接口时,它可以工作....

@Stateless
public class UserController {

    @EJB
    IUserDAO userDao;


      public List<User> getAll() {
        return userDao.findAll();
    }

}

但是......如果我注入课程它不起作用......

...代码

@Stateless
public class UserController {

    @EJB
     UserDao userDao;


      public List<User> getAll() {
        return userDao.findAll();
    }

}

...错误

     EJB5070: Exception creating stateless session bean : [UserController]
Advertencia:   EJB5184:A system exception occurred during an invocation on EJB UserController, method: public java.util.List prueba.controller.UserController.getAll()
Advertencia:   javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
    at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:435)
    at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2516)
    at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1906)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:210)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy773.getAll(Unknown Source)
    at prueba.controller.__EJB31_Generated__UserController__Intf____Bean__.getAll(Unknown Source)
    at prueba.views.UsuariosView.enter(UsuariosView.java:59)
    at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:571)
    at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:526)
    at cdi.vaadin.prueba72.NavigationServiceImpl.onNavigationEvent(NavigationServiceImpl.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:274)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:261)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:240)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:170)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:166)
    at org.jboss.weld.event.TransactionalObserverNotifier.notifyObserver(TransactionalObserverNotifier.java:44)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:120)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:113)
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:79)
    at cdi.vaadin.prueba72.MyVaadinUI$1.buttonClick(MyVaadinUI.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
    at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:978)
    at com.vaadin.ui.Button.fireClick(Button.java:393)
    at com.vaadin.ui.Button$1.click(Button.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    ...
Caused by: java.lang.IllegalStateException: Excepción al intentar inyectar Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session en class prueba.controller.UserController: Lookup failed for 'java:comp/env/prueba.controller.UserController/userDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:145)
    at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
    at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:91)
    at org.glassfish.weld.services.JCDIServiceImpl.injectEJBInstance(JCDIServiceImpl.java:257)
    at com.sun.ejb.containers.BaseContainer.injectEjbInstance(BaseContainer.java:1683)
    at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:475)
    ... 85 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Excepción al intentar inyectar Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session en class prueba.controller.UserController: Lookup failed for 'java:comp/env/prueba.controller.UserController/userDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:717)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:484)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:170)
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:138)
    ... 91 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/prueba.controller.UserController/userDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'prueba.dao.UserDao#prueba.dao.UserDao' [Root exception is javax.naming.NamingException: Lookup failed for 'prueba.dao.UserDao#prueba.dao.UserDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found]]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:613)
    ... 94 more
Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'prueba.dao.UserDao#prueba.dao.UserDao' [Root exception is javax.naming.NamingException: Lookup failed for 'prueba.dao.UserDao#prueba.dao.UserDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found]]
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:188)
    at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1143)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:745)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715)
    at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:159)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471)
    ... 98 more
Caused by: javax.naming.NamingException: Lookup failed for 'prueba.dao.UserDao#prueba.dao.UserDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:183)
    ... 103 more
Caused by: javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:237)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:204)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:114)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:478)
    ... 107 more

Grave:   java.lang.RuntimeException: javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
    at cdi.vaadin.prueba72.NavigationServiceImpl.onNavigationEvent(NavigationServiceImpl.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:274)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:261)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:240)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:170)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:166)
    at org.jboss.weld.event.TransactionalObserverNotifier.notifyObserver(TransactionalObserverNotifier.java:44)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:120)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:113)
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:79)
    at cdi.vaadin.prueba72.MyVaadinUI$1.buttonClick(MyVaadinUI.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
    at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:978)
    at com.vaadin.ui.Button.fireClick(Button.java:393)
    at com.vaadin.ui.Button$1.click(Button.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:287)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:180)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:93)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1402)
    at com.vaadin.cdi.server.VaadinCDIServletService.handleRequest(VaadinCDIServletService.java:92)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:295)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:253)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
    at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:435)
    at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2516)
    at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1906)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:210)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy773.getAll(Unknown Source)
    at prueba.controller.__EJB31_Generated__UserController__Intf____Bean__.getAll(Unknown Source)
    at prueba.views.UsuariosView.enter(UsuariosView.java:59)
    at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:571)
    at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:526)
    at cdi.vaadin.prueba72.NavigationServiceImpl.onNavigationEvent(NavigationServiceImpl.java:36)
    ... 71 more
Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
    at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:700)
    at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:246)
    at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:430)
    ... 81 more
Caused by: javax.ejb.CreateException: Could not create stateless EJB
    at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:514)
    at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:97)
    at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:698)
    ... 83 more
Caused by: java.lang.IllegalStateException: Excepción al intentar inyectar Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session en class prueba.controller.UserController: Lookup failed for 'java:comp/env/prueba.controller.UserController/userDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:145)
    at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
    at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:91)
    at org.glassfish.weld.services.JCDIServiceImpl.injectEJBInstance(JCDIServiceImpl.java:257)
    at com.sun.ejb.containers.BaseContainer.injectEjbInstance(BaseContainer.java:1683)
    at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:475)
    ... 85 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Excepción al intentar inyectar Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session en class prueba.controller.UserController: Lookup failed for 'java:comp/env/prueba.controller.UserController/userDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:717)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:484)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:170)
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:138)
    ... 91 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/prueba.controller.UserController/userDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'prueba.dao.UserDao#prueba.dao.UserDao' [Root exception is javax.naming.NamingException: Lookup failed for 'prueba.dao.UserDao#prueba.dao.UserDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found]]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:613)
    ... 94 more
Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=prueba.controller.UserController/userDao,Remote 3.x interface =prueba.dao.UserDao,ejb-link=null,lookup=,mappedName=,jndi-name=prueba.dao.UserDao,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'prueba.dao.UserDao#prueba.dao.UserDao' [Root exception is javax.naming.NamingException: Lookup failed for 'prueba.dao.UserDao#prueba.dao.UserDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found]]
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:188)
    at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1143)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:745)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715)
    at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:159)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471)
    ... 98 more
Caused by: javax.naming.NamingException: Lookup failed for 'prueba.dao.UserDao#prueba.dao.UserDao' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:183)
    ... 103 more
Caused by: javax.naming.NameNotFoundException: prueba.dao.UserDao#prueba.dao.UserDao not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:237)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:204)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:114)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:478)
    ... 107 more

任何人都可以解释为什么吗?我不明白原因......

由于

尼古拉斯

0 个答案:

没有答案