在将 myfaces 1.2 应用程序部署到 websphere 8.0 时出现“java.lang.NoSuchMethodException:没有这样的可访问方法:对象上的 addRenderKitClass():org.apache.myfaces.config.impl.digester.elements.RenderKit”异常。似乎类似于https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014782514。
看起来它是由从不同的 jsf 库加载的 RenderKit 和 DigesterFacesConfigUnmarshallerImpl 引起的。运行带有“详细类加载”的服务器证实了这一点:
me@mycomp:/opt/IBM/WebSphere/AppServer/profiles/PROF1/logs/server1# grep org.apache.myfaces.config.impl.digester.elements.RenderKit native_stderr.log
class load: org.apache.myfaces.config.impl.digester.elements.RenderKit from: file:/opt/IBM/WebSphere/AppServer/plugins/com.ibm.ws.jsf.myfaces.jar
class load: org.apache.myfaces.config.impl.digester.elements.RenderKit from: file:/opt/IBM/WebSphere/AppServer/profiles/PROF1/installedApps/myNode03Cell/mnu-ear.ear/myapp.war/WEB-INF/lib/myfaces-impl-1.2.5.jar
class load: org.apache.myfaces.config.impl.digester.elements.RenderKit from: file:/opt/IBM/WebSphere/AppServer/profiles/PROF1/installedApps/myNode03Cell/mnu-ear.ear/myapp.war/WEB-INF/lib/myfaces-impl-1.2.5.jar
class load: org.apache.myfaces.config.impl.digester.elements.RenderKit from: file:/opt/IBM/WebSphere/AppServer/profiles/PROF1/installedApps/myNode03Cell/mnu-ear.ear/myapp.war/WEB-INF/lib/myfaces-impl-1.2.5.jar
接着
my@mycomp:/opt/IBM/WebSphere/AppServer/profiles/PROF1/logs/server1# grep DigesterFacesConfigUnmarshallerImpl native_stderr.log
class load: org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl from: file:/opt/IBM/WebSphere/AppServer/plugins/com.ibm.ws.jsf.myfaces.jar
因此 DigesterFacesConfigUnmarshallerImpl 仅从 IBM 的 jsf 加载,而 RendererKit 从所有可能的位置加载。
所以问题是如何从自定义 jsf 库中加载 DigesterFacesConfigUnmarshallerImpl。