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 7808711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:12:42+00:00 2026-06-02T03:12:42+00:00

I have a @SessionScoped @Named bean with a @Producer method for a user object:

  • 0

I have a @SessionScoped @Named bean with a @Producer method for a user object:

@Named @SessionScoped
public class UserBean implements Serializable
{
  //...
  @Named @Produces @LoggedIn @SessionScoped
  public MyUser getCurrentUser() {return user;}
}

This works fine in my setup (JBoss-7.1.1-Final) and it’s no problem to access the user fields from JSF pages with #{currentUser.name}. The qualifier is org.jboss.seam.security.annotations.LoggedIn. Now I want to @Inject this user in a field in another @Named Bean:

@Named
public class FavBean implements Serializable
{   
  private @Inject @LoggedIn MyUser currentUser;
}

This gives me the error:

org.jboss.weld.exceptions.DeploymentException:
WELD-001409 Ambiguous dependencies for type [MyUser] with qualifiers [@Default] at
  injection point [[field] @Inject @LoggedIn test.FavBean.currentUser].
Possible dependencies [[Managed Bean [class test.ejb.MyUser] with qualifiers
  [@Any @Default],
Producer Method [MyUser] with qualifiers [@Any @Default] declared as [[method]
  @Named @Produces @LoggedIn @SessionScoped public test.UserBean.getCurrentUser()]]]

I don’t understand the first dependency Managed Bean [class test.ejb.MyUser] This class is a simple @Entity and deployed in an ebb.jar in a EAR. As a workaround I’m currently injecting the UserBean get the user from there.

  • 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-02T03:12:43+00:00Added an answer on June 2, 2026 at 3:12 am

    This is because CDI searches for beans by type and your entity and the producer method return the same type. That’s why it is ambiguous.

    You need to define a new qualifier and annotate it with your producer method.

    @Qualifier
    @Retention(RUNTIME)
    @Target({METHOD, FIELD, PARAMETER, TYPE})
    public @interface CurrentUser {
    }
    

    Add this annotation to your producer method:

    @Named @Produces @CurrentUser @LoggedIn @SessionScoped
    public MyUser getCurrentUser() {return user;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Session scoped bean @SessionScoped public class UserData implements Serializable { private
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {
I have a JSF 2.0 bean: @ManagedBean @SessionScoped public class LoginBean implements Serializable {
I have this Entity called 'Operation': @Entity @Table(name=operation) public class Operation implements Serializable {
I have this managed bean based on this tutorial . import java.io.Serializable; import javax.enterprise.context.SessionScoped;
My idea is : I have a bean ( UserBean ) which have some
I have this managed bean which takes two values from database's table import java.io.Serializable;
I have a session bean <managed-bean> <managed-bean-name>vdcAddBean</managed-bean-name> <managed-bean-class>com.cloud.appsportfolio.jsf.vdc.beans.VDCAddBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> Now, I am injecting
I have already one session scoped CDI bean, which keeps currently logged in user
I have my JSF Handler defined in request scope as follows public class JsfHandler

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.