Primefaces调用javax.faces 2.2方法,但2.1在Websphere 9的路径中

时间:2019-03-20 19:41:25

标签: primefaces websphere

我有一个使用自定义jsf提供程序(在WAS中设置为DEFAULT)在WAS 9中部署的应用程序。 Jars与隔离的类加载器位于共享库中。一切工作正常,直到我们从richfaces迁移到primefaces。我们使用javax.faces 2.1.29,但是由于某些原因,primefaces似乎检测到我们正在使用2.2,并且正在调用仅存在于2.2(getPassThroughAttributes)中的方法。查看正在使用的堆栈版本似乎是正确的,所以我不确定为什么要进行2.2方法调用。有人碰到这个吗?

> 3/19/19 17:19:07:671 CDT] 00000091 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException: javax/faces/component/UIComponent.getPassThroughAttributes(Z)Ljava/util/Map; (loaded from file:/opt/IBM/WebSphere/AppServer_2/trunkLib/javax.faces-2.1.29-10.jar by 
com.ibm.ws.classloader.CompoundClassLoader@abecddd0[library:trunkLib]
   Local ClassPath: /opt/IBM/WebSphere/AppServer_2/trunkLib/javax.faces-2.1.29-10.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/httpclient-4.5.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/httpcore-4.4.4.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/commons-codec-1.11.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/hk2-api-2.4.0-b34.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/hk2-locator-2.4.0-b34.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/hk2-utils-2.4.0-b34.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/javax.annotation-api-1.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/jaxrs-ri-2.22.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/jersey-guava-2.22.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/validation-api-1.1.0.Final.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/classes:/opt/IBM/WebSphere/AppServer_2/trunkLib/javassist-3.23.1-GA.jar
   Parent: com.ibm.ws.classloader.ProtectionClassLoader@a5c5ece8

> Caused by: java.lang.NoSuchMethodError: javax/faces/component/UIComponent.getPassThroughAttributes(Z)Ljava/util/Map; (loaded from file:/opt/IBM/WebSphere/AppServer_2/trunkLib/javax.faces-2.1.29-10.jar by 
com.ibm.ws.classloader.CompoundClassLoader@abecddd0[library:trunkLib]
   Local ClassPath: /opt/IBM/WebSphere/AppServer_2/trunkLib/javax.faces-2.1.29-10.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/httpclient-4.5.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/httpcore-4.4.4.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/commons-codec-1.11.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/hk2-api-2.4.0-b34.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/hk2-locator-2.4.0-b34.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/hk2-utils-2.4.0-b34.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/javax.annotation-api-1.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/jaxrs-ri-2.22.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/jersey-guava-2.22.2.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/validation-api-1.1.0.Final.jar:/opt/IBM/WebSphere/AppServer_2/trunkLib/classes:/opt/IBM/WebSphere/AppServer_2/trunkLib/javassist-3.23.1-GA.jar
   Parent: com.ibm.ws.classloader.ProtectionClassLoader@a5c5ece8
   Delegation Mode: PARENT_LAST) called from class org.primefaces.util.Jsf22Helper (loaded from file:/opt/IBM/WebSphere/AppServer_2/profiles/server1/installedApps/loggerheadNode03Cell/trunk80_war.ear/trunk80.war/WEB-INF/lib/primefaces-6.2.jar

2 个答案:

答案 0 :(得分:1)

看起来像PrimeFaces searches the classpath for JSF 2.2 classes-不幸的是,在这种情况下,PrimeFaces必须在WAS提供的JSF 2.2捆绑包中找到这些类。将primefaces-6.2从应用程序trunk80.war中移出并移到隔离的共享库trunkLib中应该可以解决此问题。

答案 1 :(得分:0)

首先让我们开始说PrimeFaces源是OPEN的,它很容易调试。在源文件中(在您的IDE或GitHub中本地进行)的简单搜索将为您提供Jsf22Helper.java的源文件。然后,您可以检查该调用位置。在调试模式下运行是最简单的,但是在GitHub的PrimeFaces存储库中进行的搜索仅显示CoreRenderer.java

中的一个位置
protected void renderDynamicPassThruAttributes(FacesContext context, UIComponent component) throws IOException {
    if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()) {
        Jsf22Helper.renderPassThroughAttributes(context, component);
    }
}

接下来,您应该检查

PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22()

为此,getter返回一个属性,该属性从其获取布尔值

atLeastJsf22 = LangUtils.tryToLoadClassForName("javax.faces.flow.Flow") != null;

在这里您会看到,为了确定“最小”版本,他们尝试加载JSF 2.2或更高版本中仅 的类。这意味着无论您是否使用父类的第一类加载,或与放置PrimeFaces的位置无关,如果javax.faces.flow.Flow位于类路径上,PrimeFaces都会认为JSF 2.2可用。 JSF 2.1是否也在类路径上甚至在JSF 2.2之前都没有关系,因为此特定类在JSF2.1中不存在,并且会始终从JSF加载2.2罐。

要解决此问题,您有三个选择

后者将是最好的,甚至可能是开箱即用的。