This discussion is archived
2 Replies Latest reply: Oct 25, 2012 6:39 AM by 676767 RSS

Ejb as shared library problem

676767 Newbie
Currently Being Moderated
I would like to have ejb module as shared library on weblogic. I followed the instruction in this tutorial:
http://www.youtube.com/watch?v=Kh8h_jQYScI
I deployed ejb jar as shared library and my jsf application. I added some lines to manifest files and it almost worked but i have problem with injection EJB.

How shoul i inject EJB in my jsf controller classes?
@EJB
private pl.alfaprojekt.model.session.ParametrFacade parametrFacade;
this seems to doesn't work.

Here is my stack trace:
com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean loginController
     at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:229)
     at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
     at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
     at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
     at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
     at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
     at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
     at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
     at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:103)
     at com.sun.el.parser.AstValue.getTarget(AstValue.java:149)
     at com.sun.el.parser.AstValue.invoke(AstValue.java:238)
     at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
     at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)
     at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2464)
     at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
     at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168)
     at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2116)
     at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:288)
     at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246)
     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
     at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
     at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at pl.alfaprojekt.view.filter.CheckSession.doFilter(CheckSession.java:50)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at pl.alfaprojekt.view.filter.NoCacheFilter.doFilter(NoCacheFilter.java:36)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3288)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
     at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
     at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
     at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
     at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
     at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: com.sun.faces.spi.InjectionProviderException: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public void pl.alfaprojekt.view.jsf.LoginController.init() on bean class class pl.alfaprojekt.view.jsf.LoginController with args: null
     at com.bea.faces.WeblogicInjectionProvider.invokePostConstruct(WeblogicInjectionProvider.java:40)
     at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:223)
     ... 49 more
Caused by: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public void pl.alfaprojekt.view.jsf.LoginController.init() on bean class class pl.alfaprojekt.view.jsf.LoginController with args: null
     at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:395)
     at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethods(Jsr250Metadata.java:365)
     at weblogic.servlet.internal.WebComponentContributor.invokeLifecycleMethods(WebComponentContributor.java:318)
     at weblogic.servlet.internal.WebComponentContributor.notifyPostConstruct(WebComponentContributor.java:301)
     at com.bea.faces.WeblogicInjectionProvider.invokePostConstruct(WeblogicInjectionProvider.java:38)
     ... 50 more
Caused by: java.lang.reflect.InvocationTargetException
     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 com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:393)
     ... 54 more
Caused by: javax.ejb.EJBException: EJB Exception: : java.lang.IllegalArgumentException: No persistence unit named 'InternetShipping-ejbPU' is available in scope InternetShipping-web-1.0.war. Available persistence units: []
     at weblogic.persistence.ModulePersistenceUnitRegistry.getPersistenceUnit(ModulePersistenceUnitRegistry.java:130)
     at weblogic.persistence.BasePersistenceContextProxyImpl.<init>(BasePersistenceContextProxyImpl.java:40)
     at weblogic.persistence.TransactionalEntityManagerProxyImpl.<init>(TransactionalEntityManagerProxyImpl.java:31)
     at weblogic.persistence.EntityManagerInvocationHandlerFactory.createTransactionalEntityManagerInvocationHandler(EntityManagerInvocationHandlerFactory.java:20)
     at weblogic.persistence.PersistenceManagerObjectFactory.createPersistenceContextProxy(PersistenceManagerObjectFactory.java:66)
     at weblogic.persistence.PersistenceManagerObjectFactory.getObjectInstance(PersistenceManagerObjectFactory.java:31)
     at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
     at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:251)
     at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:406)
     at weblogic.j2eeclient.java.ClientReadOnlyContextWrapper.lookup(ClientReadOnlyContextWrapper.java:35)
     at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
     at javax.naming.InitialContext.lookup(InitialContext.java:411)
     at javax.naming.InitialContext.doLookup(InitialContext.java:284)
     at com.oracle.pitchfork.inject.Jsr250Metadata.jndiLookup(Jsr250Metadata.java:307)
     at com.oracle.pitchfork.inject.Jsr250Metadata.resolveByName(Jsr250Metadata.java:303)
     at com.oracle.pitchfork.inject.Jsr250Metadata.resolve(Jsr250Metadata.java:266)
     at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:228)
     at com.oracle.pitchfork.inject.Jsr250Metadata.inject(Jsr250Metadata.java:219)
     at com.oracle.pitchfork.spi.BaseComponentBrokerImpl.getBean(BaseComponentBrokerImpl.java:63)
     at com.oracle.pitchfork.spi.EjbComponentCreatorBrokerImpl.getBean(EjbComponentCreatorBrokerImpl.java:33)
     at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbComponentCreatorImpl.java:76)
     at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:209)
     at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBManager.java:235)
     at weblogic.ejb.container.manager.StatelessManager.createBean(StatelessManager.java:293)
     at weblogic.ejb.container.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:185)
     at weblogic.ejb.container.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:114)
     at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:174)
     at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:146)
     at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:103)
     at weblogic.ejb.container.internal.BaseLocalObject.__WL_preInvoke(BaseLocalObject.java:67)
     at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:20)
     at pl.alfaprojekt.model.session.ParametrFacade_acgyn4_NoIntfViewImpl.getParWartosc(Unknown Source)
     at pl.alfaprojekt.view.jsf.LoginController.init(LoginController.java:71)
     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 com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:393)
     at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethods(Jsr250Metadata.java:365)
     at weblogic.servlet.internal.WebComponentContributor.invokeLifecycleMethods(WebComponentContributor.java:318)
     at weblogic.servlet.internal.WebComponentContributor.notifyPostConstruct(WebComponentContributor.java:301)
     at com.bea.faces.WeblogicInjectionProvider.invokePostConstruct(WeblogicInjectionProvider.java:38)
     at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:223)
     at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
     at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
     at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
     at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
     at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
     at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
     at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
     at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:103)
     at com.sun.el.parser.AstValue.getTarget(AstValue.java:149)
     at com.sun.el.parser.AstValue.invoke(AstValue.java:238)
     at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
     at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)
     at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2464)
     at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
     at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168)
     at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2116)
     at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:288)
     at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246)
     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
     at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
     at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at pl.alfaprojekt.view.filter.CheckSession.doFilter(CheckSession.java:50)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at pl.alfaprojekt.view.filter.NoCacheFilter.doFilter(NoCacheFilter.java:36)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3288)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
     at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
     at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
     at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
     at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
     at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

     at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(EJBRuntimeUtils.java:154)
     at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:509)
     at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:447)
     at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:166)
     at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:103)
     at weblogic.ejb.container.internal.BaseLocalObject.__WL_preInvoke(BaseLocalObject.java:67)
     at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:20)
     at pl.alfaprojekt.model.session.ParametrFacade_acgyn4_NoIntfViewImpl.getParWartosc(Unknown Source)
     at pl.alfaprojekt.view.jsf.LoginController.init(LoginController.java:71)
     ... 59 more
Caused by: java.lang.IllegalArgumentException: No persistence unit named 'InternetShipping-ejbPU' is available in scope InternetShipping-web-1.0.war. Available persistence units: []
     at weblogic.persistence.ModulePersistenceUnitRegistry.getPersistenceUnit(ModulePersistenceUnitRegistry.java:130)
     at weblogic.persistence.BasePersistenceContextProxyImpl.(BasePersistenceContextProxyImpl.java:40)
     at weblogic.persistence.TransactionalEntityManagerProxyImpl.(TransactionalEntityManagerProxyImpl.java:31)
     at weblogic.persistence.EntityManagerInvocationHandlerFactory.createTransactionalEntityManagerInvocationHandler(EntityManagerInvocationHandlerFactory.java:20)
     at weblogic.persistence.PersistenceManagerObjectFactory.createPersistenceContextProxy(PersistenceManagerObjectFactory.java:66)
     at weblogic.persistence.PersistenceManagerObjectFactory.getObjectInstance(PersistenceManagerObjectFactory.java:31)
     at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
     at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:251)
     at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:406)
     at weblogic.j2eeclient.java.ClientReadOnlyContextWrapper.lookup(ClientReadOnlyContextWrapper.java:35)
     at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
     at javax.naming.InitialContext.lookup(InitialContext.java:411)
     at javax.naming.InitialContext.doLookup(InitialContext.java:284)
     at com.oracle.pitchfork.inject.Jsr250Metadata.jndiLookup(Jsr250Metadata.java:307)
     at com.oracle.pitchfork.inject.Jsr250Metadata.resolveByName(Jsr250Metadata.java:303)
     at com.oracle.pitchfork.inject.Jsr250Metadata.resolve(Jsr250Metadata.java:266)
     at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:228)
     at com.oracle.pitchfork.inject.Jsr250Metadata.inject(Jsr250Metadata.java:219)
     at com.oracle.pitchfork.spi.BaseComponentBrokerImpl.getBean(BaseComponentBrokerImpl.java:63)
     at com.oracle.pitchfork.spi.EjbComponentCreatorBrokerImpl.getBean(EjbComponentCreatorBrokerImpl.java:33)
     at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbComponentCreatorImpl.java:76)
     at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:209)
     at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBManager.java:235)
     at weblogic.ejb.container.manager.StatelessManager.createBean(StatelessManager.java:293)
     at weblogic.ejb.container.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:185)
     at weblogic.ejb.container.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:114)
     at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:174)
     at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:146)
     ... 64 more
  • 1. Re: Ejb as shared library problem
    user696 Explorer
    Currently Being Moderated
    In which descriptor file or you referencing the shared file if it is inside weblogic.xml it might not work

    You cannot reference any other type of shared Java EE library (EJB, enterprise application, or plain JAR file) from the weblogic.xml deployment descriptor file of a Web application.
    http://docs.oracle.com/cd/E24329_01/web.1211/e24368/libraries.htm#i1071072

    Regards,
    Sunil P
  • 2. Re: Ejb as shared library problem
    676767 Newbie
    Currently Being Moderated
    Any Java EE application or module can reference an optional package (using META-INF/MANIFEST.MF), whereas only enterprise applications and Web applications can reference a shared Java EE library (using weblogic-application.xml or weblogic.xml).

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points