5 Replies Latest reply on May 2, 2013 12:56 AM by japearson

    Richfaces 4.3.1 weblogic 10.3.5.0 duplicate key on deploy

    japearson

      Hi,

       

      I'm having trouble with richfaces 4.3.1 on weblogic 10.3.5.0, on deploy the following exception happens:

       

      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)

       

      I had a look inside ClientServiceConfigParser and debugged it and I found that it ended up loading /META-INF/csv.xml twice from richfaces-components-ui-4.3.1.Final.jar

       

      The problem happens on line 45 when it calls Enumeration<URL> resources = loader.getResources(name);, because that ends up returning /META-INF/csv.xml twice because it returns a http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/misc/CompoundEnumeration.html which seems to 2 copies.  Any idea how this could be worked around?

       

      In the debugger I made it avoid loading the file twice and it deployed without errors.

       

      Any idea how to get around this?

       

      I am using maven if it makes any difference.

       

      Thanks,

       

      -Joel

        • 1. Re: Richfaces 4.3.1 weblogic 10.3.5.0 duplicate key on deploy
          japearson

          For what it's worth it seems something to do with Weblogic's ChangeAwareClassLoader (weblogic.utils.classloaders.ChangeAwareClassLoader).  Because inside org.richfaces.javascript.ClientServiceConfigParser.parseConfig(String) when it runs ClassLoader loader = Thread.currentThread().getContextClassLoader(); it ends up returning the ChangeAwareClassLoader which happens to get 2 copies of the same resource.  However if I null out the loader so that it runs loader = ClientServiceConfigParser.class.getClassLoader();, then it ends up with a different classloader: weblogic.utils.classloaders.GenericClassLoader.

           

          Any ideas?

           

          In context:

           

           

              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();
              }
          
          
          • 2. Re: Richfaces 4.3.1 weblogic 10.3.5.0 duplicate key on deploy
            iabughosh

            Hello Joel,

            try deploying you project  as ear file, add thid lines to your weblogic-application.xml :

             

            <prefer-application-packages>
                   
            <package-name>com.google.*</package-name>
            </prefer-application-packages>

             

            regards.

            • 3. Re: Richfaces 4.3.1 weblogic 10.3.5.0 duplicate key on deploy
              japearson

              Hi Ibrahim,

               

              That made no difference. I'm not sure why you thought it should do anything because the problem originates in org.richfaces.javascript.ClientServiceConfigParser.parseConfig. Not in the google classes, the error from the google classes are just a symptom of the bigger problem, which is loading the csv.xml file twice.

               

              However in the end we decided to use Richfaces 4.0.0 instead and it works fine, because it seems that 4.3.1 is simply not compatible with weblogic 10.3.5.0.

              • 4. Re: Richfaces 4.3.1 weblogic 10.3.5.0 duplicate key on deploy
                japearson

                Strangely enough richfaces 4.0.0 has the same org.richfaces.javascript.ClientServiceConfigParser.parseConfig(String) but the loader.getResources(name) call only returns 1 csv.xml instead of two.

                • 5. Re: Richfaces 4.3.1 weblogic 10.3.5.0 duplicate key on deploy
                  japearson

                  Ok I managed to get 4.3.1 working in the end.  It turned out that because I was using Skinny Wars in maven, it has unforseen side effects with the ChangeAwareClassLoader. I thought I tried this problem without using Skinny Wars, but I guess I didn't.