9 Replies Latest reply: Jul 26, 2013 7:40 AM by dvohra21 RSS

    Spring's JSF DelegatingVariableResolver cause InvocationTargetException

    594171
      Hi,

      in our ADF Faces application, as part of the faces-config.xml, we have the following entry:
      <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>    
      The spring.jar file, which contains above class, resides in the WEB-INF/lib
      Everything works without any problem on OC4J,JBoss,.... but, when we try to execute application on WebLogic 10.3, the following exceptions occurs:
      com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! 
        Source Document: file:/D:/OracleMiddleware/jdeveloper/system/system11.1.1.0.31.51.56/o.j2ee/drs/TEE/tee/WEB-INF/faces-config.xml
        Cause: Unable to create a new instance of 'org.springframework.web.jsf.DelegatingVariableResolver': java.lang.reflect.InvocationTargetException
           at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:211)
           at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:184)
           at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:465)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
           at weblogic.security.service.SecurityManager.runAs(Unknown Source)
           at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:175)
           at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1784)
           at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2999)
           at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1371)
           at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)
           at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
           at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
           at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
           at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
           at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
           at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
           at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
           at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
           at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
           at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
           at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
           at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
           at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:16)
           at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)
           at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
           at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
           at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
           at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
           at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)
           at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
           at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
           at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
           at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
           at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
           at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
           at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      What can be a wrong ?
        • 1. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
          594171
          Anyone tried to use custom JSF variable-resolver on jsf application deployed on WebLogic ?
          Any hint ?!? Classloader problem or what ? How to solve ?

          BEA people, what you say ?
          • 2. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
            Frank Nimphius-Oracle
            Hi,

            since OC4J is not production in JDeveloepr 11, I assume you tested this in 10.1.3, which uses JSF 1.1. In JDeveloper 11 and WLS 10.3 it needs JSf 1.2. Make sure the variable resolver supports that

            Frank
            • 3. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
              594171
              I just moved spring.jar from WEB-INF/lib to the

              <MIDDLEWARE-HOME>\jdeveloper\system\system11.1.1.0.31.51.56\DefaultDomain\lib\

              And this produces the following error:
                Cause: Class 'org.springframework.web.jsf.DelegatingVariableResolver' is missing a runtime dependency: java.lang.NoClassDefFoundError: javax/faces/el/VariableResolver
                   at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:222)
                   at com.sun.faces.config.processor.ApplicationConfigProcessor.addVariableResolver(ApplicationConfigProcessor.java:481)
                   at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:239)
                   at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:94)
                   at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:119)
              -Adding
                <library-ref>
                  <library-name>jsf</library-name>
                </library-ref>
              to the weblogic-application.xml does not help...
              • 4. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
                594171
                Frank Nimphius wrote:
                Hi,

                since OC4J is not production in JDeveloepr 11, I assume you tested this in 10.1.3, which uses JSF 1.1. In JDeveloper 11 and WLS 10.3 it needs JSf 1.2. Make sure the variable resolver supports that

                Frank
                Hi Frank,

                actually, the question is quite simple:

                What to do in order to set custom variable-resolver (which is deprecated in JSF 1.2, but not unsupported) in a brand new JDeveloper 11g finall ADF Faces application ?

                I would like for that varible-resolver to be instance of

                org.springframework.web.jsf.DelegatingVariableResolver

                This class is a part of spring.jar archive, so because of that, I just put spring.jar in the WEB-INF/lib
                However, this produces InvocationTargetException, as in my first message

                Moving spring.jar from WEB-INF/lib to the
                <MIDDLEWARE-HOME>\jdeveloper\system\system11.1.1.0.31.51.56\DefaultDomain\lib\

                produces

                Class 'org.springframework.web.jsf.DelegatingVariableResolver' is missing a runtime dependency: java.lang.NoClassDefFoundError: javax/faces/el/VariableResolver

                - Whatever I do, this does not help

                So, how to set custom variable-resolver, the question is now ?
                Cannot believe that nobody knows
                • 5. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
                  Maxence Button
                  Hi,

                  Well, I'm not a ADF specialist, but if you have a problem regarding the resolution of some classes, I would adise you two solutions :
                  => Keeping the mechanism of domain/lib, just add your Faces implementation into that domain directory to get rid of the CNFE (but I'm not fond of that method since it adds that behavior to all the applications ...)
                  => ship all your implementations in your app (web-inf/lib). Then package into an EAR and add some FilteringClassLoaders to isolate your classes in your application.
                  (this one is recommended by BEA | Oracle & me :) )

                  If you don't know what FilteringClassLoaders are or how to use them, I invite you to read that post :
                  http://m-button.blogspot.com/2008/08/how-to-use-weblogic-filteringclassloade.html

                  Hope this helps !

                  And one last word, when you say "cannot believe that nobody knows", I understand your frustration, but there are always problem discoverers and you're unfortunately among them.
                  Since WebLogic 10.3 has just been integrated with JDeveloper, it's quite usual that some stuff isn't adjusted yet.
                  We are doing our best here to help you.





                  Regards
                  • 6. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
                    594171
                    Maxence Button wrote:
                    Hi,

                    Well, I'm not a ADF specialist, but if you have a problem regarding the resolution of some classes, I would adise you two solutions :
                    I am appreciate your help.

                    Just one explanation: variable-resolver is not ADF Faces- specific feature, but JSF one.
                    I will try how this works with WebLogic standalone, so maybe problem is in JDev 11/WebLogic integration, do not know
                    I also will try your solutions, but moving jsf-api.jar (JSF impl which contains javax.faces.el.VariableResolver) to the DefaultDomain/lib causes InvocationtargetException again
                    So what remains, is a FilteringClassLoaders ...
                    Let see..
                    • 7. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
                      594171
                      Maxence Button wrote:
                      => ship all your implementations in your app (web-inf/lib). Then package into an EAR and add some FilteringClassLoaders to isolate your classes in your application.
                      (this one is recommended by BEA | Oracle & me :) )
                      Maxence,

                      you point me to right direction.
                      I just put JSF implementation files (jsf-api.jar, jsf-impl.jar) along with spring.jar (which contains my variable-resolver) in the application WEB-INF/lib, and then:

                      1. in the the weblogic-application.xml, I just added:
                          <prefer-application-packages>
                              <package-name>javax.faces.*</package-name>
                              <package-name>com.sun.faces.*</package-name>
                              <package-name>org.springframework.*</package-name>
                          </prefer-application-packages>
                      2. manually added one new descriptor, well-know weblogic.xml, with the following entry:
                          <container-descriptor>
                            <prefer-web-inf-classes>true</prefer-web-inf-classes>
                         </container-descriptor>
                      After doing so, no more InvocationTargetException nor ClassNotFoundException

                      Thanks again,...
                      • 8. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
                        Maxence Button
                        Cvele,

                        Good to know you solved your problem.

                        Just note that you used the child-delegation-first model (prefer-web-inf) that works but can cause some classloading errors (LinkageErrors).

                        The FilteringClassLoader is way more elegant but imposes to use an EAR.
                        Then if you keep your current implementation (WAR), the FilteringClassLoader mechanism didn't work. The prefer-web-inf did the trick.

                        If you're aware of that and that works, fine.

                        But note that it would be better to use the FCL, instead of the Child-delegation-first model.

                        Anyway, good to know you're not stuck anymore ! :)

                        Regards
                        • 9. Re: Spring's JSF DelegatingVariableResolver cause InvocationTargetException
                          dvohra21

                          java.lang.ClassNotFoundException: javax.faces.el.VariableResolver


                          Add the jsf-api.jar to the runtime classpath of the server.