I've written an EJB3 business logic and deployed under Glassfish. I'm now going to test it through a client in same container, injecting interface with @EJB.
The problem is that this interface is null
THE CLIENT
public class EjbTest {
@EJB
private static RepAlertManager rep;
public static void main(String[] args) throws IOException, SQLException {
try
{
DBConnection.setTypeConnetionLocal(true);
List<Long> result = rep.doSomething("ENTRATE");
for(Long temp:result){
System.out.println(temp);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
THE LOCAL INTERFACE
public interface RepAlertManager {
public List<Long> doSomething(String message) throws SQLException; }
THE STATELESS bean extending data source
@Stateless public class RepAlertManagerImpl extends DataSource implements RepAlertManager {
public RepAlertManagerImpl() throws IOException {
super();
}
public List<Long> doSomething(String message) throws SQLException {
// some code
} }
DATA SOURCE bean is a stateless bean setting connection in the constructor and releasing it through a get() method