Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:22:31+00:00 2026-06-04T18:22:31+00:00

I am trying to use spring to provide managed beans to jsf. I assume

  • 0

I am trying to use spring to provide managed beans to jsf. I assume that @ManagedBean will be picked up by JSF container to link the EL in JSF to managed bean even when I use spring by configuring spring usage in faces-config.xml.

Spring shall provide the beans but now who manages scope of the beans?

I have tried following annotation on beans to have it become Request scope but they do not work.

@ManagedBean(name="helloBean") //meant for JSF
@RequestScoped //meant for JSF
@Scope(value="request") //meant for spring
@Controller //meant for spring
public class HelloBean implements Serializable {

Actually earlier I was using plain JSF and @ManagedBean and @RequestScoped were working well. Now as I tried to integrate using spring the scope are not working.

I have even tried setting bean scope in spring config but they work as expected in context of spring (singleton and prototype) but not web request context.

I was trying to avoid having to use above @Scope and @Controller annotation hoping that JSF will manage scope but do not seem like.

Below are my files snippet for spring config and MyHelloBean which probably will help communicate better.

<bean id="helloBean" class="com.mkyong.common.HelloBean" init-method="init" />

<bean id="myHelloBean" class="com.mkyong.common.MyHelloBean" init-method="init" >
        <property name="helloBean" ref="helloBean"></property>
</bean>

@ManagedBean
@RequestScoped
@Scope(value="request")
@Controller
public class MyHelloBean implements Serializable {

    private static final long serialVersionUID = 1L;
    //@ManagedProperty(value = "#{helloBean}")
    private HelloBean helloBean;

see in above MyHelloBean I am using spring DI to set helloBean which gets set by spring fine. I have commented out @ManagedBean which I think I can leave it in there as it will be ignored by spring any ways and JSF is not going to process it I guess but to be safe I commented it out for JSF to not process it.

To complete I use below in faces-config to activate spring usage.

<el-resolver> 
org.springframework.web.jsf.el.SpringBeanFacesELResolver 
</el-resolver> 

Regards,

Miten.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:22:33+00:00Added an answer on June 4, 2026 at 6:22 pm

    Your approach is a bit confusing in the sense that it seems that you’re mixing Spring XML configuration and Spring Annotation-based configuration. As described as an example here, if you’re using annotated configuration then you should have:

    <context:component-scan base-package="com.yourcom.package" />
    

    to order Spring scan for the annotations. Otherwise, if you’re using XML configuration then you should have:

    <bean id="helloBean" class="com.mkyong.common.HelloBean" init-method="init" scope="request" />
    

    as by default the scope for a Spring bean is singleton.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple authentication provider that I'm trying to use with Spring Security.
I am trying to use Spring to inject @PersistenceContext entityManager into my service. The
I am trying got use spring-mvc tag inside java-script file, here is what i
I am trying to use Spring.NET with a C# application to populate a parameter
I'm new to Spring and trying to use the Spring Formatting SPI for UI
I'm trying to understand why one would use Spring Batch over a scripting language
I have a Spring MVC application trying to use a rich domain model, with
I'm trying to use UTF-8 encoding for the Spring application I'm developing but I
I'm trying to use aspectj with compile time weaving to support annotations like Spring's
In Spring MVC Hibernate application , when i am trying to use properties file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.