首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Websphere 8.5.5上带有ejb无状态的CODI

Websphere 8.5.5上带有ejb无状态的CODI
EN

Stack Overflow用户
提问于 2013-10-31 14:28:12
回答 1查看 1.9K关注 0票数 0

如果webapp包含@无状态ejb,我无法在websphere 8.5.5上启动嵌入CODI的webapp。

我明白这一例外:

代码语言:javascript
复制
[ERROR   ] null
java.lang.reflect.InvocationTargetException
[ERROR   ] An error occured while initializing MyFaces: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
[ERROR   ] Uncaught.init.exception.thrown.by.servlet 
    Faces Servlet
    codiTest
    javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @ApplicationScoped does not exist within current thread
    at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:342)
    at [internal classes]
    at org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig_$$_javassist_78.isAdvancedQualifierRequiredForDependencyInjection(CodiCoreConfig_$$_javassist_78.java)
    at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.PhaseListenerExtension.consumePhaseListeners(PhaseListenerExtension.java:110)
    at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleFactoryWrapper.getLifecycle(CodiLifecycleFactoryWrapper.java:67)
    at javax.faces.webapp.FacesServlet.init(FacesServlet.java:119)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322)
    at [internal classes]

[ERROR   ] SRVE0266E: Error occured while initializing servlets: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:385)
    at [internal classes]
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @ApplicationScoped does not exist within current thread
    at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:342)
    at [internal classes]
    at org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig_$$_javassist_78.isAdvancedQualifierRequiredForDependencyInjection(CodiCoreConfig_$$_javassist_78.java)
    at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.PhaseListenerExtension.consumePhaseListeners(PhaseListenerExtension.java:110)
    at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleFactoryWrapper.getLifecycle(CodiLifecycleFactoryWrapper.java:67)
    at javax.faces.webapp.FacesServlet.init(FacesServlet.java:119)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322)
    ... 1 more

[WARNING ] Unknown RenderKit 'HTML_BASIC'.
[WARNING ] Unknown RenderKit 'HTML_BASIC'.
[ERROR   ] An exception occurred
java.lang.IllegalArgumentException: Could not find a RenderKit for "HTML_BASIC"

我已经说明过,只有当项目中存在ejb (在我的例子中是@无状态ejb)时,问题才会发生。

在这种情况下,当服务器启动并安装/部署webapp时,应用程序上下文将被初始化。这里没问题。

当webapp处理第一个HTTP请求时,初始化FacesServlet并实例化CodiNavigationHandler

在构造函数中调用方法CodiNavigationHandler.isAddViewConfigsAsNavigationCaseActivated(),并尝试获取对CODI JsfModuleConfig的引用。这个JsfModuleConfig有一个@ApplicationScoped注释,beanManager试图获取应用程序上下文。

这个应用程序上下文已经创建(在部署webapp时),但是还没有调用LibertyContextsService.initApplicationContext(String)。因此,应用程序上下文在LibertyContextsService.applicationContexts ThreadLocal变量上为null,并且出现错误:

代码语言:javascript
复制
WebBeans context with scope type annotation @ApplicationScoped does not exist within current thread

复制:

  • 创建动态Web项目
  • 在WEB下添加几乎为空的beans.xml (只是一个beans元素)
  • 在WEB下添加一个几乎为空的faces-config.xml (只是一个faces-config元素)
  • 添加带有faces/index.xhtml的web.xml
  • 在WEB/lib (http://www.apache.org/dyn/closer.cgi/myfaces/binaries/myfaces-extcdi-assembly-jsf20-1.0.5-bin.zip)中复制codi jars
  • 添加一个无状态bean: 导入javax.annotation.PostConstruct;导入javax.ejb.Stateless;@无状态公共类MyBean { @PostConstruct公共postConstruct() { System.out.println("post构造:“+ this);}公共字符串getTitle() {返回”测试“;}
  • 添加一个jsf bean: 导入javax.inject.Inject;导入javax.inject.Named;@命名公共类MyController { @Inject私有MyBean myBean;公共字符串getTitle() {返回myBean.getTitle();}
  • 添加一个简单的jsf网页: ${myController.title} >

nota:如果您删除了ejb上的@无状态,应用程序就能工作。

EN

回答 1

Stack Overflow用户

发布于 2013-11-04 11:00:58

实际上,它似乎是一个bug (我还在IBM上发布了这个问题:https://www.ibm.com/developerworks/community/forums/html/topic?id=f372bbc5-5ba4-4c2a-9ef0-0bdcd76766da#09228314-2baf-4892-899e-5a8cc52daa19)。

我要设法创建一个PMR (我在一家大公司,很难找到合适的人,允许我访问)。

所以现在我已经转到jboss了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19709201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档