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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:41:20+00:00 2026-05-26T19:41:20+00:00

I have found this question: What is the difference between @Inject and @EJB but

  • 0

I have found this question: What is the difference between @Inject and @EJB but I did not get any wiser. I have not done Java EE before nor do I have experience with dependency injection so I do not understand what I should use?

Is @EJB an old way of injecting? Is the injection done by the EJB container when using this annotation while using @Inject use the new CDI framework? Is that the difference and should I be using @Inject instead of @EJB if this is the case?

  • 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-26T19:41:21+00:00Added an answer on May 26, 2026 at 7:41 pm

    The @EJB is used to inject EJB’s only and is available for quite some time now. @Inject can inject any managed bean and is a part of the new CDI specification (since Java EE 6).

    In simple cases you can simply change @EJB to @Inject. In more advanced cases (e.g. when you heavily depend on @EJB‘s attributes like beanName, lookup or beanInterface) than in order to use @Inject you would need to define a @Producer field or method.

    These resources might be helpful to understand the differences between @EJB and @Produces and how to get the best of them:

    Antonio Goncalves’ blog:
    CDI Part I
    CDI Part II
    CDI Part III

    JBoss Weld documentation:
    CDI and the Java EE ecosystem

    StackOverflow:
    Inject @EJB bean based on conditions

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

Sidebar

Related Questions

This might be a trivial question, but I have not found anything about it,
This question nags me for a while but I did not found complete answer
This might be a very basic question, but have not found a convincing answer
Hello this is may first question and I have found so far the following
I have found myself doing this in my code to 'cache' the work done
I have found some info on the subject ( like this link) , but
I have a quick question about the difference between the 32 and 64 bit
Apologies for the massively stupid question but I am curious how to get this
I've searched for a potential answer to my question below, and have not found
I have found this project on Codeplex. http://www.codeplex.com/ProjNET I need to integrate this code

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.