10.3.5.0重複鍵,上部署以下例外情況:RichFaces的4.3.1的WebLogic上我在WebLogic上的10.3.5.0與RichFaces的4.3.1麻煩部署
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! duplicate key: class javax.faces.validator.LongRangeValidator
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:290)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
Truncated. see log file for complete stacktrace
Caused By: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! duplicate key: class javax.faces.validator.LongRangeValidator
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:351)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:222)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalArgumentException: duplicate key: class javax.faces.validator.LongRangeValidator
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:72)
at com.google.common.collect.ImmutableMap$Builder.fromEntryList(ImmutableMap.java:245)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:231)
at org.richfaces.javascript.ClientServiceConfigParser.parseConfig(ClientServiceConfigParser.java:53)
我裏面看看ClientServiceConfigParser和調試它,我發現,它結束了裝載/META-INF/csv.xml從兩次RichFaces的組件-UI-4.3.1.Final.jar
問題的方法是:
public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (null == loader) {
loader = ClientServiceConfigParser.class.getClassLoader();
}
Builder<Class<?>, LibraryFunction> resultBuilder = ImmutableMap.builder();
try {
Enumeration<URL> resources = loader.getResources(name);
while (resources.hasMoreElements()) {
URL url = (URL) resources.nextElement();
resultBuilder.putAll(parse(loader, url));
}
} catch (IOException e) {
return Collections.emptyMap();
}
return resultBuilder.build();
}
I t似乎與Weblogic的ChangeAwareClassLoader(weblogic.utils.classloaders.ChangeAwareClassLoader
)有關。因爲在org.richfaces.javascript.ClientServiceConfigParser.parseConfig(String)
裏面,當它運行ClassLoader loader = Thread.currentThread().getContextClassLoader();
時,它最終返回ChangeAwareClassLoader
,恰好得到相同資源的2個副本。但是,如果我將加載程序清零(使用調試程序)以使其運行loader = ClientServiceConfigParser.class.getClassLoader();
,那麼它最終會得到一個不同的類加載程序:weblogic.utils.classloaders.GenericClassLoader
。其中沒有獲得相同資源的2份副本。
對於什麼是值得我使用maven和RichFaces的已加載這樣:
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
以前人們認爲我已經加載了錯誤的行家depdencies,我可以告訴你,它不涉及到: IllegalArgumentException: duplicate key (JSF)
由於使用調試器,我確認loader.getResources(name);
返回完全相同的資源。
zip:C:/bea/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/_appsdir_umsWebUI-jee-ear-1.0-SNAPSHOT_ear/6m7brt/lib/richfaces-components-ui-4.3.1.Final.jar!/META-INF/csv.xml
zip:C:/bea/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/_appsdir_umsWebUI-jee-ear-1.0-SNAPSHOT_ear/6m7brt/lib/richfaces-components-ui-4.3.1.Final.jar!/META-INF/csv.xml
也可對照我嘗試了JSF論壇,只是把weblogic的論壇帖子,但我想我會在這裏得到更好的反應。兩個其他職位在這裏:
https://forums.oracle.com/forums/thread.jspa?threadID=2529414 https://community.jboss.org/thread/224100
所以從編譯我自己豐富的面部的版本之外,沒有任何人有解決方法的任何想法?如何禁用ChangeAwareClassLoader
也許?嘗試禁用該類加載器時,我的Google搜索沒有產生任何結果。