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

  • Home
  • SEARCH
  • 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 6104867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:53:29+00:00 2026-05-23T13:53:29+00:00

I rode that is recommended to use CDI beans as backing beans instead of

  • 0

I rode that is recommended to use CDI beans as backing beans instead of JSF managed beans.

So i decided to create a little example, to understand how it works, for a @RequestScopedBean:

-instead of using @ManagedBean(“beanName”) ,i use @Named(“beanName”)

-instead of using javax.faces.bean.RequestScopped i use javax.enterprise.context.RequestScoped;

The demo program is very simple, i have a field and a submit button, when the user inputs something and the page is refreshed, the inputed value is not displayed anymore(It last while the request lasts right?). I think i did everything ok, but i get an exception that says:

WARNING: StandardWrapperValve[Faces
Servlet]: PWC1406: Servlet.service()
for servlet Faces Servlet threw
exception
javax.el.PropertyNotFoundException:
/index.xhtml @19,47
value=”#{cdiBean.passedValue}”: Target
Unreachable, identifier ‘cdiBean’
resolved to null

This is how my program looks like:

index.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
        <title>RequestScope demo CDI(Component Dependency Injection)</title>
</h:head>

<h:body>

    <h:form>

    <h3>RequestScope demo CDI(Component Dependency Injection)</h3>

    <h:inputText value="#{cdiBean.passedValue}"/>
    <br/>
    <h:commandButton value="submit" action="index"/>

    </h:form>
</h:body>
</html>

DemoBB.java

package backingbeans;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named("cdiBean")//The Named anotation indicates that this is a CDI bean
@RequestScoped//If we use CDI beans the @RequestScoped annotation must come from: javax.enterprise.context.RequestScoped;
public class DemoBB {

    //This value will be saved on the session only until the server responds to the request
    private String passedValue;

    public String getPassedValue() {
        return passedValue;
    }

    public void setPassedValue(String passedValue) {
        this.passedValue = passedValue;
    }   
}

-Where is my mistake?

-What is the advantage of using this approach? I still don’t understand that.

  • 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-05-23T13:53:30+00:00Added an answer on May 23, 2026 at 1:53 pm

    Do you have an empty beans.xml along with your web.xml? I think it is mandatory to be there.

    Read section 15.6 here. Quote from it:

    CDI doesn’t define any special
    deployment archive. You can package
    beans in JARs, EJB-JARs or WARs—any
    deployment location in the application
    classpath. However, the archive must
    be a “bean archive”. That means each
    archive that contains beans must
    include a file named beans.xml in the
    META-INF directory of the classpath or
    WEB-INF directory of the web root (for
    WAR archives). The file may be empty.
    Beans deployed in archives that do not
    have a beans.xml file will not be
    available for use in the application.

    In an embeddable EJB container, beans
    may be deployed in any location in
    which EJBs may be deployed. Again,
    each location must contain a beans.xml
    file.

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

Sidebar

Related Questions

No related questions found

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.