0

We are converting an app from jsf 1.2 to jsf2 in wildfly 10, using spring 3.1.1 and mojarra 2.1.29-08. In doing so, we are getting a scope error like:

The scope of the object referenced by expression #{configConstant}, request, is shorter than the referring managed beans (UserSearchBean) scope of view

In our faces-config.xml, we define UserSearchBean like:

    <managed-bean>
    <managed-bean-name>UserSearchBean</managed-bean-name>
    <managed-bean-class>com.mycompany.UserSearchBean</managed-bean-class>
    <managed-bean-scope>view</managed-bean-scope>
    <managed-property>
        <property-name>configConstant</property-name>
        <value>#{configConstant}</value>
    </managed-property>
</managed-bean>

and in applicationContext.xml we have:

<import resource="../aaconfig.xml" ></import>

And in that aaconfig file we have:

<bean id="configConstant" scope="singleton"
    class="com.mycompany.ConfigConstant" >
    <property name="fileName">
        <value>config.xml</value>
    </property>
    <property name="logofilename" value="${config.logofilename}" />
</bean>

From what we read, the singleton scope should be global, but the error message from wildfly says otherwise. We have these in web.xml

      <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
 </listener>
  <context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>classpath:applicationContext.xml</param-value>
 </context-param>
 <servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
 <servlet>
 <servlet-name>accessaudit</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>

I just realized that other beans work fine, like this one. It injects fine with the correct scope. The only different I can immediately see is that configConstant has properties read from a properties file.

<bean id="userManager" class="com.mycompany.UserManager">
    <property name="userManagerDAO">
       <ref bean="userManagerDAOProxy" />
    </property>

Any ideas on what is the issue or where to start looking?

Thank you!

  • What if you use `#{configConstantBLABLABLA}`? Same error? Is your faces-config.xml 'ok'? Read https://stackoverflow.com/questions/18387993/spring-jsf-integration-how-to-inject-a-spring-component-service-in-jsf-managed – Kukeltje Oct 02 '17 at 17:35

1 Answers1

0

I found it, but not sure why. I had this:

<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
    <property name="prefix"><value>/jsp/</value></property>
    <property name="suffix"><value>.jsp</value></property>
    <property name="exposedContextBeanNames">
        <list>
            <value>configConstant</value>
        </list>
    </property>
</bean>

When I removed the exposedContextBeanNames part, it no longer gave the error. I know we do have some old jsp files that use variables from configConstant. Something in the exposing must have changed the scope, anyone know why or how to achieve the same goad?