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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:17:06+00:00 2026-06-03T06:17:06+00:00

This is my first time working with GAE and I’m trying to get CDI

  • 0

This is my first time working with GAE and I’m trying to get CDI working. Long story short: The @Inject field in my servlet is not getting injected (it’s always null).

I’m working in Eclipse and debug the application on the local test server included in the GAE SDK (which is started by Eclipse as well). When I access the servlet on localhost, I get a null-pointer exception for someService. I’ve also output the value of someService to verify it is really null, which it is.

Edit: When I added a @Named("skldjfx") qualifier to the injection point, Weld complained the dependency is unsatisfied (in the validation phase), so that’s a good sign. However, the field is still always null.

Servlet:

public class BlogServlet extends HttpServlet {

    @Inject private SomeService someService;

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {

        resp.setContentType("text/plain");
        resp.getWriter().println("Hello. " + someService.getSomeValue());
        //                                      \
        //                                  always null
    }
}

SomeService class:

@ApplicationScoped
public class SomeService {

    private String someValue = "some value";

    public String getSomeValue() {
        return someValue;
    }
}

I’ve configured Weld’s Listener in web.xml:

<listener>
    <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>

The listener is properly loaded because it logs its initialization message: org.jboss.weld.environment.servlet.Listener contextInitialized.

I’ve included (an empty) beans.xml in both war/WEB-INF and war/META-INF. I also tried it without META-INF. Maybe beans.xml isn’t processed? Other contents in the WEB-INF folder (such as web.xml) are processed properly.

How can I verify if beans.xml is processed and/or fix SomeService not getting injected?

  • 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-03T06:17:08+00:00Added an answer on June 3, 2026 at 6:17 am

    It looks like it’s not possible to use CDI with GAE, because GAE’s Jetty fork ignores jetty-web.xml, which is needed to specify the BeanManager. See this link and this link. Really strange GAE is not supporting the use of CDI.

    Note that these links are really old, but so far I haven’t found any evidence to the contrary.

    Anyway, my next step will be to use Google’s own dependency injection framework Guice. Using it with GAE is described here. I’d prefer CDI though.

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

Sidebar

Related Questions

This is my first time working with python. I'm trying to create a dictionary
This is my first time working with Objective-C, and I keep trying to create
This is my first time working with localStorage, and I'm trying to store a
This is my first time working with regular expressions and I've been trying to
This is my first time working with Quartz. I am trying out a sample
This is my first time working with file i/o in java, and it's not
Let me start off by saying that this is my first time working with
I am currently working on an ASP.NET MVC2 project. This is the first time
This is my first time truly working with composite keys. I have a record
This is my first time working with a webservice and I tried looking up

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.