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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:52:09+00:00 2026-06-03T03:52:09+00:00

In a Java EE 6 project I am working on, there is a lone

  • 0

In a Java EE 6 project I am working on, there is a lone field annotated with @EJB that is not being injected. Injection is working fine everywhere else.

Being new to Java EE, I don’t know if it is related to the field being in an abstract class, nor can I find any output from Glassfish (3.1.2) about why this injection is not occurring.

There are no errors or warnings in the server log until the NullPointerException occurs because the dataSourceControl field is null. I have verified that the DataSourceControl Singleton is being instantiated by putting logging in it’s constructor.

As far as I can tell, the dataSourceControl field is not being injected, but the logs give me no reason why this is.

public abstract class AbstractDataMap<T> {
  @EJB
  private DataSourceControl dataSourceControl; // This is not being injected

  DataSourceControl getDataSourceControl() {
    return dataSourceControl;
  }
  // Other methods
}

public abstract class AbstractDataMapDBProd<T> extends AbstractDataMap<T> {
  @Override
  protected Connection getDBConnection() {
    return getDataSourceControl().getConnectionX(); // NullPointerException here
  }
  // Other methods
}

@Stateless
public class CountryMap extends AbstractDataMapDBProd<Country> {
  public boolean update(final Country current, final Country legacy) {
    Connection connection = getDBConnection();
    // More code 'n stuff
  }
}

Are there any rules I have missed regarding injection that is defined in an abstract class?

Anything else that cries ‘noob’?

If there are no obvious errors, any ideas on how to debug this?

  • 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-03T03:52:11+00:00Added an answer on June 3, 2026 at 3:52 am

    Injection will work in any class (base class, superclass, abstract superclass, etc.). However, injection will only work so long as you obtain an instance of CountryMap from the container (i.e., injection or lookup) rather than via new CountryMap. How are you obtaining an instance of CountryMap?

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

Sidebar

Related Questions

For a JAVA project I am working on there is a requirement that I
I am working on a JAVA project in which there are multiple terminals. These
I'm working on a small Java project that now connects to a MS SQL
I'm working on a java project that will allows users to parse multiple files
I'm currently working on a java project that requires me to make a system
I'm working on a java project full of Hibernate (3.3.1) mapping files that have
I'm working on a Java project where I have created a class that looks
I'm working on a java project that receives midi events from midi hardware using
I'm working on a Java project for class that stores workout information in a
I am working on a Java project that I want to deliver to my

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.