我在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并调试了它,我发现它最终从richfaces-components-ui-4.3.1.Final.jar加载/META-INF/csv.xml两次
有问题的方法是:
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();
}
这似乎与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>
在人们暗示我加载了错误的maven 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搜索没有产生任何结果。
答案 0 :(得分:0)
好的,我最终设法让4.3.1工作了。事实证明,因为我在maven中使用了Skinny Wars,所以它与ChangeAwareClassLoader一起出现了副作用。我以为我在没有使用Skinny Wars的情况下尝试了这个问题,但我想我没有。