0

I have the following code and I'm searching for an other way to do this.

public static RequestContextData getRequestContextData() {
    FacesContext fc = FacesContext.getCurrentInstance();
    ExpressionFactory ef = fc.getApplication().getExpressionFactory();
    MethodExpression me = ef.createMethodExpression( fc.getELContext(), "#{requestContextData.getRequestContextData}", String.class, new Class[0]);
    Object o = me.invoke(fc.getELContext(), null); 
    RequestContextData request = (RequestContextData) o;
    return request;
}

I found out that it causes problems after upgrading to tomcat 8. The ELContext is already resolved and with this code afterwards it wouldn't be resolved anymore. I already tried it with a managed property but this won't work.

Addition 1: The stack looks like the following:

  • xxx.getRequestContextData()
  • some other methods
  • BeanELResolver.getValue(ELContext, Object, Object)

The ELContext is in BeanELResolver and xxx the same one. That leads to the malfunction that the xxx overwrites the resolved property with false in the BeanELResolver which then returns an PropertyNotFoundException.

Buddy145
  • 1
  • 2
  • To prevent the usage of the ELContext I'm accessing now via the methods shown in the link. https://stackoverflow.com/questions/2633112/get-jsf-managed-bean-by-name-in-any-servlet-related-class – Buddy145 Jun 20 '17 at 08:12
  • My bean was sessionScoped and therefore the code for getting it is: Bean bean = (Bean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("bean"); – Buddy145 Jun 20 '17 at 08:22

0 Answers0