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

The Archive Base Latest Questions

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

I read some documentation on DI with Java 6 and I’m not sure to

  • 0

I read some documentation on DI with Java 6 and I’m not sure to fully understand. I have the following class in which I want to inject a service:

@ManagedBean
@RequestScoped
public class MyBean implements Serializable {

    private static final long serialVersionUID = 1L;

    @Inject
    private MyService myService;
    private List<SomeObject> someObjects;

    // Getter and setter

    public List<SomeObject> getSomeObjects() {
        if (someObjects == null) {
            someObjects = myService.find();
        }
        return someObjects;
    }

}

The service:

public class MyServiceImpl implements MyService {

    public MyServiceImpl() {
    }

}

When running this code, myService is not injected. Please, what am I doing wrong?

PS: I’m using Tomcat 7

  • 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:24:34+00:00Added an answer on June 5, 2026 at 8:24 am

    Java 6 does not have built in dependency injection, nor does Tomcat 7 AFAIK. Are you thinking about Java EE 6? Then you have to run your code in a Java EE 6 compatible appserver, like TomEE or GlassFish.

    If you want to stay with Tomcat 7, you could concider Spring or Guice instead.

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

Sidebar

Related Questions

I am not a Java programmer. I read the documentation on final, and understand
I've read some documentation on how Adaboost works but have some questions regarding it.
I have read a lot about the Java class loading process lately. Often I
I am not a Java programmer. I program R and C++. I have some
I am using some API in which there is a class Reader which have
I am new to modernizr. I read some documentation on modernizr, and I wanted
I've been coding in Inno Setup this afternoon and I read some Pascal documentation
I've read the documentation about __init__.py files and some nice questions here on SO,
While searching for some functions in C++ standard library documentation I read that push
I've read through a lot of the documentation and for some reason this still

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.