本文介绍了java.lang.NoSuchMethodError:javax.faces.component.UIComponent.getPassThroughAttributes(Z)Ljava/util/Map;迁移到JSF 2.2之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在迁移到JSF 2.2之后,我得到了以下异常.具体来说,我是将Mojarra 2.1.17升级到Mojarra 2.2.8.

I am getting the below exception after migrating to JSF 2.2. Specifically, I'm upgrading Mojarra 2.1.17 to Mojarra 2.2.8.

java.lang.NoSuchMethodError: javax.faces.component.UIComponent.getPassThroughAttributes(Z)Ljava/util/Map;
    at org.primefaces.renderkit.RendererUtils.renderPassThroughAttributes(RendererUtils.java:79)
    at org.primefaces.renderkit.CoreRenderer.renderDynamicPassThruAttributes(CoreRenderer.java:119)
    at org.primefaces.renderkit.CoreRenderer.renderPassThruAttributes(CoreRenderer.java:114)
    at org.primefaces.renderkit.BodyRenderer.encodeBegin(BodyRenderer.java:44)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    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:313)

当我检查jsf-api-2.2.8.jar内的UIComponent时,我看到有一种方法Map<String, Object> getPassThroughAttributes(boolean create);.

When I check the UIComponent inside jsf-api-2.2.8.jar, I can see there is a method Map<String, Object> getPassThroughAttributes(boolean create);.

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

该方法为 .当Webapp的运行时类路径被多个不同版本的JSF API库污染时,就会发生此问题.换句话说,您仍然在运行时类路径中的某个位置具有JSF 2.0或2.1 API.

That method was introduced in JSF 2.2. This problem will thus happen when the webapp's runtime classpath is polluted with multiple different versioned JSF API libraries. In other words, you've still a JSF 2.0 or 2.1 API somewhere in the runtime classpath.

这表明您正在尝试通过手动将JSF捆绑在Web应用程序中并将其部署到已经捆绑了JSF的Java EE容器(例如WildFly,JBoss AS,GlassFish,WebLogic,WebSphere等)来升级JSF. .您的stacktrace太短,无法确认,但是您的问题历史记录确认您正在使用WebLogic.

This suggests that you're trying to upgrade JSF by manually bundling it in the webapp and deploying it to a Java EE container which already bundles JSF out the box, such as WildFly, JBoss AS, GlassFish, WebLogic, WebSphere, etc. Your stacktrace is too short in order to be able to confirm that, but your question history confirms that you're using WebLogic.

为了在WebLogic中正确升级Mojarra,您实际上应该替换/wlserver/modules文件夹中的JSF JAR.

In order to properly upgrade Mojarra in WebLogic, you should actually be replacing the JSF JAR(s) in /wlserver/modules folder.

如果您实际上使用的是没有捆绑JSF的准系统servlet容器,例如Tomcat,那么您需要验证/WEB-INF/lib(如果是Maven,则为pom文件) JSF API中的重复项.最常见的入门错误是也有一个javaee-api.jar.应该将其删除(或设置为provided).另请参阅如何导入javax.我的Eclipse项目中的servlet API?

In case you're actually using a barebones servletcontainer which doesn't bundle JSF out the box, such as Tomcat, then you'd need to verify if /WEB-INF/lib (or pom file in case of Maven) is free of duplicates in JSF API. Most common starter's mistake is having a javaee-api.jar in there too. This should be removed (or be set to provided). See also a.o. How do I import the javax.servlet API in my Eclipse project?

这篇关于java.lang.NoSuchMethodError:javax.faces.component.UIComponent.getPassThroughAttributes(Z)Ljava/util/Map;迁移到JSF 2.2之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:02
查看更多