[英]2 classes with same name in different jar's in portlet for WebSphere portal
I am working on a portlet project and came across a problem with 2 classes with same name (including packages) in different .jar files. 我正在研究一个portlet项目,并且在不同的.jar文件中遇到了两个同名类(包括包)的问题。 I have
com.ibm.ws.webcontainer.jar
as a default WebSphere library and jsf-impl.jar
which is necessary for some JSF features. 我将
com.ibm.ws.webcontainer.jar
作为默认的WebSphere库,并将jsf-impl.jar
作为某些JSF功能所必需的。
The problem comes out when PortletFacesContextFactoryImpl
class (another JSF class) tries to get access to com.sun.faces.util.Util.parameterNonNull(Object arg)
method and I get NoSuchMethodError
. 当
PortletFacesContextFactoryImpl
类(另一个JSF类)尝试获取对com.sun.faces.util.Util.parameterNonNull(Object arg)
方法的访问PortletFacesContextFactoryImpl
出现了问题,并且出现了NoSuchMethodError
。
I tried setting classloader policy to PARENT_LAST, this doesn't help. 我尝试将类加载器策略设置为PARENT_LAST,这没有帮助。 I can't remove
com.ibm.ws.webcontainer.jar
from the server, but when I try to use Util class in my code, the only option is the class from it, not from jsf-impl.jar
. 我无法从服务器中删除
com.ibm.ws.webcontainer.jar
,但是当我尝试在我的代码中使用Util类时,唯一的选择是从其中的类,而不是jsf-impl.jar
。 jsf-impl.jar
is included into Java Build Path. jsf-impl.jar
包含在Java构建路径中。
How can this problem be solved since I cannot alter PortletFacesContextFactoryImpl
source and move .jar with wrong class? 由于无法更改
PortletFacesContextFactoryImpl
源和使用错误的类移动.jar,如何解决此问题?
Parent Last should be your solution. 上一个父母应该是您的解决方案。 WebSphere Portal deploys portlet application with Parent Last as default, but it does not hurt to double check it at the WebSphere Application Server Integrated Solutions Console (Admin Console) >
WebSphere Portal部署portlet应用程序时默认使用Parent Last,但是在WebSphere Application Server集成解决方案控制台(管理控制台)>再次检查它不会有任何问题。
However, it also depends on your portlet application setup. 但是,这还取决于您的Portlet应用程序设置。 I assume it is
com.sun.faces.util.Util
which is troubling you. 我以为是
com.sun.faces.util.Util
困扰着您。 On my system, this class is located in jsf-impl.jar
and the Application Server Web Container . 在我的系统上,此类位于
jsf-impl.jar
和Application Server Web容器中 。 In order to get it to work, jsf-impl.jar
needs to be placed in the WEB-INF/lib
directory of your portlet application. 为了使其正常工作,需要将
jsf-impl.jar
放置在portlet应用程序的WEB-INF/lib
目录中。 To verify that, use the Class Loader View of WAS: Admin Console > Troubleshooting > Class loader viewer > WebSphere_Portal > Applications and then the your portlet application. 要验证这一点,请使用WAS的类加载器视图:管理控制台>故障排除>类加载器查看器> WebSphere_Portal>应用程序,然后使用您的Portlet应用程序。 It must start with PA.
它必须以PA开头。 Switch to the table view and search for the class.
切换到表格视图并搜索类。
You also mentioned the Java Build Path . 您还提到了Java Build Path 。 This is another topic and depends on your IDE - assumingly Eclipse.
这是另一个主题,取决于您的IDE-可能是Eclipse。 Check the Order and Export tab,
jsf-impl.jar
should be placed at the top, so that it overrules the server runtime classpath entries. 检查“ 订购和出口”选项卡,应将
jsf-impl.jar
放在顶部,以便它覆盖服务器运行时类路径条目。
PARENT_LAST classpath setting will help you. PARENT_LAST类路径设置将为您提供帮助。 However, for this setting to be done, your portlet muste be packaged as a EAR.
但是,要完成此设置,您的portlet muste必须打包为EAR。 If your portlet is packaged as a war and you configure the classpath settings manually, they get erased everytime you deploy the portlet.
如果您将portlet打包打包,并且您手动配置了classpath设置,则每次部署该Portlet时,它们都会被删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.