In the Java EE 6 project I'm working on, there is one field annotated with @EJB that is not entered. Injection works great everywhere.
As a newbie to Java EE, I donβt know if this is due to a field in an abstract class, and I can not find any conclusion from Glassfish (3.1.2) about why this injection does not occur.
There are no errors or warnings in the server log until a NullPointerException is raised because the dataSourceControl field is null. I checked that an instance of the DataSourceControl Singleton is created by entering a constructor into it.
As far as I can tell, the dataSourceControl field is not entered, but the logs give me no reason why this is so.
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 that I skipped regarding the injections that are defined in the abstract class?
Anything else that screams "noob"?
If there are no obvious errors, any ideas on how to debug this?
rusty_turkey
source share