Results 1 to 5 of 5

Thread: DelagatingViewResolver - not working in combo with PhaseListener

  1. #1

    Default DelagatingViewResolver - not working in combo with PhaseListener

    I am having a problem with the DelegatingViewResolver. I have written a JSF phase listener to intercept requests before the RESTORE_VIEW phase. My application than tries to retrieve a JSF managed bean via an EL expression factory. The managed bean has a reference to a spring managed component. The managed bean is constructed, but during the el coerce method, I am receiving an initialization failed exception. When I take the spring service component out of my managed bean xml config, the phase listener is able to construct the managed bean without any problems. Does anyone have an idea why this is happening? below is my code and config...

    Code:
    <lifecycle>
            <phase-listener>com.asc.ltp.web.listeners.RedirectPhaseListener</phase-listener>
        </lifecycle>
    
        <application>
           <message-bundle>com.asc.ltp.web.messages</message-bundle>
           <variable-resolver>
    			org.springframework.web.jsf.DelegatingVariableResolver
    		</variable-resolver>
    		<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    	</application>
    
    <managed-bean>
            <managed-bean-name>ActivationApi</managed-bean-name>
            <managed-bean-class>com.asc.ltp.web.ActivationAPIImpl</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>accountManager</property-name>
                <value>#{standardAccountManager}</value>
            </managed-property>
    </managed-bean>
    
     public void beforePhase(PhaseEvent event) {
            try{
                FacesContext ctx = event.getFacesContext();
    
            HttpServletRequest request =
                (HttpServletRequest)ctx.getExternalContext().getRequest();
    
            ELContext elCtx = ctx.getELContext();
            ExpressionFactory ef = ctx.getApplication().getExpressionFactory();
            ValueExpression ve = ef.createValueExpression(elCtx,"${ActivationApi}", ActivationAPI.class);
    
            ActivationAPIImpl activationManager = (ActivationAPIImpl)ctx.getApplication().createValueBinding("#{LoginManager}").getValue();
    
    
    
            ActivationAPIImpl activationAPI = (ActivationAPIImpl)ve.getValue(elCtx); //fails here!

  2. #2

    Default

    FYI...I just wrapped my code in a try catch, catching an ExceptionInInitializerError. The cause of the error is as follows...

    Code:
    20:26:44,108 ERROR [STDERR] Caused by: java.util.MissingResourceException: Can't find bundle for base name com.sun.el.Messages, locale en_US
    20:26:44,108 ERROR [STDERR] 	at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
    20:26:44,108 ERROR [STDERR] 	at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
    20:26:44,108 ERROR [STDERR] 	at java.util.ResourceBundle.getBundle(ResourceBundle.java:549)
    20:26:44,108 ERROR [STDERR] 	at com.sun.el.util.MessageFactory.<clinit>(Unknown Source)
    Google the error, but couldn't find anything useful...

  3. #3

    Default

    Ok, it looks like a made a little progress...

    After upgrading my jboss from 4.0.4 to 4.2.2, i was able to see a more informative log. You see, it turns out I was references a Transaction proxy bean...when I changed the reference of the JSF managed property to the target and not the proxy, everything works as expected. So my question is this:
    Am i not going to be able to wire a TransactionProxyFactoryBean as a managed JSF property using the DelagatingViewResolver??

  4. #4
    Join Date
    Nov 2007
    Posts
    9

    Default

    Did you end up with an answer?
    I am looking at the exact same issue and am wondering the same thing!

  5. #5

    Default

    Oh...that was so long ago that I forgot what I did to solve the issue...

    The bottom line is I am using the DelagatingViewResolver in conjunction with a TransactionProxyFactoryBean...I think I might of solved it by changing some jars that were in my classpath...might have been the EL jars...

    Geez, sorry I can't be more of help here...I just remembering going thru hell on that one, and finally getting it to work by looking more in detail about my classpath. Also, you may want to check what jars are in the JBoss classpath as part of the distribution...there could be some conflicts...especially with Expression Language...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •