问题
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)
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?
回答1:
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.
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.
In order to properly upgrade Mojarra in WebLogic, you should actually be replacing the JSF JAR(s) in /wlserver/modules
folder.
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?
来源:https://stackoverflow.com/questions/24358511/jsf-2-0-get-errors-because-of-primefaces-4