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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:01:48+00:00 2026-06-05T08:01:48+00:00

Part of my problem here is using the proper vocabulary, so I apologize in

  • 0

Part of my problem here is using the proper vocabulary, so I apologize in advance for what might be a simple matter of terminology.

Suppose I have a Person interface, and a PersonBean class that implements that interface.

Suppose further I have a producer method somewhere (annotated @Produces) that returns a Person. Internally it returns a new PersonBean, but that’s neither here nor there.

Finally, suppose I have another CDI bean somewhere with an injection point defined like this:

@Inject
private Person person;

Assuming I have all my beans.xml files in place etc. and have bootstrapped Weld or another CDI-1.0-compliant environment, as this all stands I will get an ambiguous definition error. This makes sense: Weld will find my PersonBean as a candidate for injection (it could just call the constructor) and will find the output of my producer method as a candidate for injection.

What I’d like to do is somehow force the production of Person instances in this application to always route through the producer method.

I understand I could invent some qualifier somewhere and make the producer method produce Person instances that are qualified by that qualifier. If I do that, and change my injection point to include the qualifier, then obviously there’s only one source of these qualified injectables (namely my producer method), so voila, problem solved.

But suppose I don’t want to invent some bogus qualifier. (I’m not saying this is the case; just trying to more deeply understand the issues.) What are my options? Do I have any? I suppose I could put @Typed(Object.class) on the PersonBean to make it so that it was not seen as a Person by CDI….

Any ideas welcomed, including pointers to documentation, or better ways to understand this. Thanks.

  • 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-05T08:01:50+00:00Added an answer on June 5, 2026 at 8:01 am

    From digesting several different answers here and elsewhere, the solution I’ve adopted is to use the @Typed annotation with a value of Object.class on my bean. This means that it will only be eligible to be injected into fields that are declared like this:

    @Inject
    private Object something;
    

    …which thankfully prove to be pretty much nonexistent. 🙂

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

Sidebar

Related Questions

I have a problem with Menu button on Android 4.0. Here's the interesting part
I don't have a problem, I'm just curious. Here is a part of my
I really seem to have a big problem here. I'm using MySQL to store
Part of the solution to my problem I found here: How to calculate correlation
Here is part 1 of our problem (Loading a dynamically generated XML file as
Here's my problem, say, for example, I have a link on my page, it
Here is the problem I put to you. I have an page where a
Got a problem here with a simple section of code that uses managedQuery cursors.
wondering if anyone might have some insight or point me to the proper documentation
I’ve looked at the various questions regarding this problem on here such as: Using

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.