Omnifaces cdi param和JSF 2.3之间的冲突

问题描述 投票:1回答:1

在将服务器从tomee plume 7升级到tomee plume 8之后,我的网络应用程序遇到了Omnifaces cdi param的问题。我使用裸骨webapp进行了测试并确认了这一点。

我的豆子:

@javax.faces.view.ViewScoped
@javax.inject.Named
public class Bean2 implements java.io.Serializable {
  @javax.inject.Inject @org.omnifaces.cdi.Param
  private String tag;
  private String tag2;

  @javax.annotation.PostConstruct
  public void init() {
    if (getTag() == null || getTag().length()==0) {
        setTag2("None injected");
    }
    else 
        setTag2(getTag() + " injected");
    // Getters and setters

}

我的JSF视图:

<h:body>
    Tag: <h:outputText value="#{bean2.tag}" />
    <br/>
    <p:inputText readonly="true" value="#{bean2.tag2}"/>
</h:body>

我试过http://localhost:8080/test/inject2.jsf?tag=ABC,它只工作一次。随后的试验给出:

java.lang.IllegalArgumentException: Unknown property tag of class com.mycompany.Bean2
at org.apache.bval.jsr.job.ValidateProperty$FindDescriptor.handleProperty(ValidateProperty.java:216)
at org.apache.bval.jsr.job.ValidateProperty$WalkGraph.handleProperty(ValidateProperty.java:312)
Caused by: javax.el.ELException: Error reading [tag] on type [com.mycompany.Bean2$$OwbNormalScopeProxy0]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:98)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELR...

如果我重新启动服务器,它也只能运行一次。

我的环境Java:openjdk版本“1.8.0_191”,Primefaces 6.1,Omnifaces 2.6.9。我知道没有多少人使用TomEE但是为了获取信息,TomEE plume 7基于Tomcat 8,Mojarra JSF 2.2而TomEE plume 8基于Tomcat 9,Mojarra JSF 2.3。当然有更多的差异,但测试Web应用程序非常简单,影响我的只应该是Tomcat和JSF版本,而SAME jar则会被删除。

jsf tomee omnifaces
1个回答
1
投票

这不是OmniFaces,JSF和CDI中的错误。

这是BVal(Apache的Bean验证(JSR303)实现)中的一个错误。堆栈跟踪至少证实了这一点。它从BVal类中抛出了异常。

OmniFaces CDI @Param注释具有在注入值之前自动执行Bean验证的功能。对于较旧的BVal版本和其他BV实现(例如Hibernate Validator),这一直都能正常工作。

您最好的选择是向BVal人报告此问题。同时,您可以通过在@Param上禁用BV来解决此问题。

@Inject @Param(disableBeanValidation=true)
private String tag;

在从Tomnest 7.0.4到TomEE 8.0.0-M2的upgrading测试服务器之后,我在OmniFaces中偶然发现了这个问题。与您在IT期间观察到的完全相同的问题。修复是disable bean验证。

对于记录,这是完整的堆栈跟踪:

28-Apr-2019 12:18:37.479 SEVERE [http-nio-8080-exec-28] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [facesServlet] in context with path [/MultiViewsIT] threw exception [Unknown property secondPathParamAsInteger of class org.omnifaces.test.facesviews.multiviews.MultiViewsITBean] with root cause
java.lang.IllegalArgumentException: Unknown property secondPathParamAsInteger of class org.omnifaces.test.facesviews.multiviews.MultiViewsITBean
    at org.apache.bval.jsr.job.ValidateProperty$FindDescriptor.handleProperty(ValidateProperty.java:216)
    at org.apache.bval.jsr.job.ValidateProperty$WalkGraph.handleProperty(ValidateProperty.java:312)
    at org.apache.bval.jsr.util.PathNavigation$PathPosition.handleProperty(PathNavigation.java:324)
    at org.apache.bval.jsr.util.PathNavigation.parse(PathNavigation.java:218)
    at org.apache.bval.jsr.util.PathNavigation.navigateAndReturn(PathNavigation.java:176)
    at org.apache.bval.jsr.util.PathNavigation.navigate(PathNavigation.java:192)
    at org.apache.bval.jsr.job.ValidateProperty.<init>(ValidateProperty.java:490)
    at org.apache.bval.jsr.job.ValidateProperty.<init>(ValidateProperty.java:500)
    at org.apache.bval.jsr.job.ValidationJobFactory.validateValue(ValidationJobFactory.java:76)
    at org.apache.bval.jsr.ValidatorImpl.validateValue(ValidatorImpl.java:65)
    at org.apache.bval.jsr.CascadingPropertyValidator.validateValue(CascadingPropertyValidator.java:99)
    at org.omnifaces.util.Platform.validateBeanProperty(Platform.java:129)
    at org.omnifaces.cdi.param.ParamProducer.doBeanValidation(ParamProducer.java:403)
    at org.omnifaces.cdi.param.ParamProducer.validateBean(ParamProducer.java:252)
    at org.omnifaces.cdi.param.ParamProducer.validateValues(ParamProducer.java:223)
    at org.omnifaces.cdi.param.ParamProducer.produce(ParamProducer.java:103)
    at org.omnifaces.cdi.param.DynamicParamValueProducer.create(DynamicParamValueProducer.java:72)
    at org.apache.webbeans.component.third.ThirdpartyBeanImpl.create(ThirdpartyBeanImpl.java:97)
    at org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
    at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
    at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:813)
    at org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:673)
    at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:100)
    at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
    at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:227)
    at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:213)
    at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:203)
    at org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)
    at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:66)
    at org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
    at org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:159)
    at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:101)
    at org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
    at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
    at org.omnifaces.test.facesviews.multiviews.MultiViewsITBean$$OwbNormalScopeProxy0.getFirstPathParamAsString(org/omnifaces/test/facesviews/multiviews/MultiViewsITBean.java)
    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:498)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:94)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:62)
    at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)
    at org.apache.webbeans.el22.WrappedValueExpression.getValue(WrappedValueExpression.java:68)
    at org.apache.myfaces.view.facelets.el.ELText$ELTextVariable.writeText(ELText.java:218)
    at org.apache.myfaces.view.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
    at org.apache.myfaces.view.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:46)
    at org.apache.myfaces.view.facelets.compiler.UILeaf.encodeAll(UILeaf.java:491)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:551)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:551)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1897)
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:315)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:73)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:73)
    at org.omnifaces.viewhandler.OmniViewHandler.renderView(OmniViewHandler.java:121)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:73)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:117)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:266)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:206)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.omnifaces.facesviews.FacesViewsForwardingFilter.filterExtensionLessToExtension(FacesViewsForwardingFilter.java:180)
    at org.omnifaces.facesviews.FacesViewsForwardingFilter.filterExtensionLess(FacesViewsForwardingFilter.java:137)
    at org.omnifaces.facesviews.FacesViewsForwardingFilter.filterExtensionLess(FacesViewsForwardingFilter.java:123)
    at org.omnifaces.facesviews.FacesViewsForwardingFilter.doFilter(FacesViewsForwardingFilter.java:84)
    at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
© www.soinside.com 2019 - 2024. All rights reserved.