“OWB 2.0.27, TomEE 8.0.14, JSF (myfaces) 2.3.10 启动错误”

huangapple go评论56阅读模式
英文:

OWB 2.0.27, TomEE 8.0.14, JSF (myfaces) 2.3.10 startup errors

问题

We are upgrading our webapp to JSF 2.3.10, OWB 2.0.22, and TomEE 8.0.14. I realize we should move to Jakarta EE, but, for now, this is our tech stack.
升级我们的web应用程序到JSF 2.3.10,OWB 2.0.22和TomEE 8.0.14。我意识到我们应该迁移到Jakarta EE,但目前我们使用的是这个技术栈。

I'm seeing stacktraces in the catalina logs concerning Default qualifiers. A snippet of one:
我在catalina日志中看到关于Default qualifiers的堆栈跟踪。其中的一部分如下:

Caused by: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
Caused by: javax.enterprise.inject.spi.DeploymentException: 无法启动owb上下文

at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:263)
在org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:263)中

at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:43)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:43)

at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:974)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:974)

at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:762)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:762)

at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1340)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1340)

43 more
43个更多的

Caused by: org.apache.openejb.OpenEJBRuntimeException: org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.inovis.catalogue.ui.hierarchy.SelcodeList] is not not found with the qualifiers
由:org.apache.openejb.OpenEJBRuntimeException引起:org.apache.webbeans.exception.WebBeansDeploymentException:javax.enterprise.inject.UnsatisfiedResolutionException:Api类型[com.inovis.catalogue.ui.hierarchy.SelcodeList]与qualifiers未找到

Qualifiers: [@javax.enterprise.inject.Default()]
Qualifiers:[@javax.enterprise.inject.Default()]

for injection into Field Injection Point, field name: selcodeList, Bean Owner: [SearchAction, WebBeansType:MANAGED, Name:searchAction, API Types:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]
用于注入到字段注入点,字段名称:selcodeList,Bean所有者:[SearchAction,WebBeansType:MANAGED,Name:searchAction,API类型:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object],Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]

at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:200)
在org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:200)中

at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:261)
在org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:261)中

47 more
47个更多的

Caused by: org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.inovis.catalogue.ui.hierarchy.SelcodeList] is not not found with the qualifiers
由:org.apache.webbeans.exception.WebBeansDeploymentException引起:javax.enterprise.inject.UnsatisfiedResolutionException:Api类型[com.inovis.catalogue.ui.hierarchy.SelcodeList]与qualifiers未找到

Qualifiers: [@javax.enterprise.inject.Default()]
Qualifiers:[@javax.enterprise.inject.Default()]

for injection into Field Injection Point, field name: selcodeList, Bean Owner: [SearchAction, WebBeansType:MANAGED, Name:searchAction, API Types:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]
用于注入到字段注入点,字段名称:selcodeList,Bean所有者:[SearchAction,WebBeansType:MANAGED,Name:searchAction,API类型:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object],Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]

at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:398)
在org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:398)中

at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)
在org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)中

48 more
48个更多的

Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.inovis.catalogue.ui.hierarchy.SelcodeList] is not not found with the qualifiers
由:javax.enterprise.inject.UnsatisfiedResolutionException引起:Api类型[com.inovis.catalogue.ui.hierarchy.SelcodeList]与qualifiers未找到

Qualifiers: [@javax.enterprise.inject.Default()]
Qualifiers:[@javax.enterprise.inject.Default()]

for injection into Field Injection Point, field name: selcodeList, Bean Owner: [SearchAction, WebBeansType:MANAGED, Name:searchAction, API Types:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]
用于注入到字段注入点,字段名称:selcodeList,Bean所有者:[SearchAction,WebBeansType:MANAGED,Name:searchAction,API类型:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object],Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation

英文:

We are upgrading our webapp to JSF 2.3.10, OWB 2.0.22, and TomEE 8.0.14. I realize we should move to Jakarta EE, but, for now, this is our tech stack.

I'm seeing stacktraces in the catalina logs concerning Default qualifiers. A snippet of one:

> Caused by: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
> at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:263)
> at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:43)
> at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:974)
> at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:762)
> at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1340)
> 43 more
> Caused by: org.apache.openejb.OpenEJBRuntimeException: org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.inovis.catalogue.ui.hierarchy.SelcodeList] is not found with the qualifiers
> Qualifiers: [@javax.enterprise.inject.Default()]
> for injection into Field Injection Point, field name : selcodeList, Bean Owner : [SearchAction, WebBeansType:MANAGED, Name:searchAction, API Types:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]
> at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:200)
> at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:261)
> 47 more
> Caused by: org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.inovis.catalogue.ui.hierarchy.SelcodeList] is not found with the qualifiers
> Qualifiers: [@javax.enterprise.inject.Default()]
> for injection into Field Injection Point, field name : selcodeList, Bean Owner : [SearchAction, WebBeansType:MANAGED, Name:searchAction, API Types:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]
> at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:398)
> at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)
> 48 more
> Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.inovis.catalogue.ui.hierarchy.SelcodeList] is not found with the qualifiers
> Qualifiers: [@javax.enterprise.inject.Default()]
> for injection into Field Injection Point, field name : selcodeList, Bean Owner : [SearchAction, WebBeansType:MANAGED, Name:searchAction, API Types:[java.io.Serializable,com.inovis.catalogue.ui.search.SearchAction,com.inovis.catalogue.ui.BaseAction,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named,javax.faces.annotation.FacesConfig]]
> at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
> at org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:252)
> at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1231)
> at org.apache.webbeans.util.WebBeansUtil.validate(WebBeansUtil.java:1521)
> at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:1220)
> at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:1131)
> at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:323)
> 49 more

I've looked at several blogs and many questions/answers here on StackOverflow about configuring OWB2, Tomcat (TomEE+), and JSF2.3. Including:
https://hantsy.gitbook.io/java-ee-8-by-example/jsf/jsf-activation

https://stackoverflow.com/questions/45205472/apache-openwebbeanscdi-servlet-injection-not-working

https://devlearnings.wordpress.com/2011/05/15/apache-openwebbeans-cdi-from-standalone-to-webapp

https://stackoverflow.com/questions/37125988/openwebbeans-myfaces-tomcat-illegalstateexception

I've also added the extra dependencies to the TomEE/lib directory, found in the batch file, based on this site: https://lists.apache.org/thread/wct0r81bvsdbo7jbyqmw3x3d90h8s9jr

My configuration:

/META_INF/context.xml (Commented out due to org.apache.tomee.catalina.TomcatResourceFactory.create Can't create resource null -> java.lang.IllegalStateException: On a thread without an initialized context nor a classloader mapping a deployed app)

<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!--    <Resource name="BeanManager"-->
<!--              auth="Container"-->
<!--              type="javax.enterprise.inject.spi.BeanManager"-->
<!--              factory="org.apache.webbeans.container.ManagerObjectFactory"/>-->
</Context>

/WEB-INF/beans.xml

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
       bean-discovery-mode="annotated"
       version="2.0">
</beans>

/WEB-INF/web.xml (snippet)

    <context-param>
        <param-name>org.apache.myfaces.RENDER_VIEWSTATE_ID</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.ENABLE_CDI_RESOLVER_CHAIN</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>

    <resource-env-ref>
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
        <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
    </resource-env-ref>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
    </listener>

    <!--jsf-->
    <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

A snippet of our bean and the class it's injected into:

@FacesConfig(version=FacesConfig.Version.JSF_2_3)
@Default
@Named("selcodeList")
@SessionScope
public class SelcodeList extends BaseListAction implements Serializable {

@FacesConfig(version=FacesConfig.Version.JSF_2_3)
@Default
@Named("searchAction")
@SessionScoped
public class SearchAction extends BaseAction {

    @Inject
    private SelcodeList selcodeList;

I've even added a ConfigurationBean:

import javax.faces.annotation.FacesConfig;

@FacesConfig(version = FacesConfig.Version.JSF_2_3)
public class ConfigurationBean {
}

So, I suspect it's a configuration error, but I'm not sure where. However, based on the above references, everything seems to be in order. What else could cause the qualifier error?

Secondly, adding the @Default annotation explicitly seemed to help with other similar errors. I thought that annotation was implied in CDI beans?

Thank you for any help with this.

答案1

得分: 1

Sure, here are the translations for the code-related instructions:

  1. beans.xml 文件中将 bean-discovery-mode="annotated" 更改为 bean-discovery-mode="all"
  2. SelcodeListSearchAction 中删除 @FacesConfig(version = FacesConfig.Version.JSF_2_3)@Default
  3. ConfigurationBean 添加 @ApplicationScoped
  4. SearchAction bean 中添加 implements Serializable
  5. 从 TomEE/lib 目录中移除额外的 Apache OpenWebBeans 依赖项,不要移除由 Apache TomEE 提供的库。
英文:
  1. Change the bean-discovery-mode="annotated" to bean-discovery-mode="all" in beans.xml file.
  2. Remove @FacesConfig(version = FacesConfig.Version.JSF_2_3) and @Default from SelcodeList and SearchAction
  3. Add @ApplicationScoped to ConfigurationBean
  4. Add implements Serializable to SearchAction bean
  5. Remove extra Apache OpenWebBeans dependencies from the TomEE/lib directory, don't remove libs provided by Apache TomEE.

huangapple
  • 本文由 发表于 2023年4月4日 04:28:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923531.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定