从迁移到tomcat后,将JSF页面中的枚举值作为参数传递给bean方法失败 [英] Passing enum value as parameter to bean method from JSF pages fail after migrating to tomcat

查看:148
本文介绍了从迁移到tomcat后,将JSF页面中的枚举值作为参数传递给bean方法失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的JSF应用程序(使用primefaces)从glassfish 3.1迁移到tomcat7服务器。以前通过 actionlistener 属性将enum值作为字符串传递给托管bean方法(不需要转换器将字符串转换为枚举)但现在它失败了 javax.el.MethodNotFoundException

I recently migrated my JSF app(using primefaces) from glassfish 3.1 to tomcat7 server. Previously passing the enum value as string to managed bean methods through actionlistener attribute worked(without the need for a converter to convert string to enum) but now it fails with javax.el.MethodNotFoundException.

JSF页面:


<h:form>
   <h:outputLabel value="Title"/><br/>
   <p:inputText value="#{lobController.current.title}"/>

   <p:commandButton action="#{lobController.create('CAR')}" value="Post"/>
</h:form>


管理bean方法


public void create(Type type) {
  ...
}


记录消息:


javax.el.MethodNotFoundException:/_ newLOB.xhtml @ 85,111
action =#{lobController.create('CAR')}:找不到方法:
d432.xontrollers.LOBController@15b2cec .create(java.lang.String)at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
at javax.faces.component.UICommand.broadcast(UICommand.java) :315)
javax.faces.component.UIData.broadcast(UIData.java:1093)at
javax.faces.component.UIData.broadcast(UIData.java:1093)at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at
com.sun.fa ces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)at
com.sun.faces.lifecycle。 LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain。 java:304)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.primefaces.webapp.filter.FileUploadFilter。 doFilter(FileUploadFilter.java:79)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina。 core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

javax.el.MethodNotFoundException: /_newLOB.xhtml @85,111 action="#{lobController.create('CAR')}": Method not found: d432.xontrollers.LOBController@15b2cec.create(java.lang.String) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110) at javax.faces.component.UICommand.broadcast(UICommand.java:315) at javax.faces.component.UIData.broadcast(UIData.java:1093) at javax.faces.component.UIData.broadcast(UIData.java:1093) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)






编辑



如果我更改托管bean方法,这将开始工作如下:


Edit

This starts working if I change the managed bean method as follow:


public void create(String type) {
     Type type = Type.valueOf(type);
     ...
}







在Tomcat 7.0.14上使用Primefaces 3.1和JSF 2.1.6

推荐答案

这是Tomcat的EL实现中的一个错误。我已经为您报告过了: issue 52970 。希望他们不像我以前的报告那样挑剔。

It's a bug in Tomcat's EL implementation. I've reported it for you: issue 52970. Hopefully they aren't as picky on this as on my previous reports.

在他们修复之前,最好的办法是删除 Glassfish 3的EL 2.2实现JAR文件在你的webapp的 / WEB-INF / lib 中,告诉Mojarra使用它来代替 web.xml :

Until they get it fixed, your best bet is to drop a copy of Glassfish 3's EL 2.2 implementation JAR file in your webapp's /WEB-INF/lib and tell Mojarra to use it instead by the following entry in web.xml:

<context-param>     
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>   
</context-param>






更新:机票提到它是固定的,它将在7.0.27及之后。


Update: the ticket mentions that it's fixed and it will be in 7.0.27 and onwards.

这篇关于从迁移到tomcat后,将JSF页面中的枚举值作为参数传递给bean方法失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆