Reputation: 856
I am trying to use @EJB annotation
to call a stateless bean. When I print the value of the reference, it is NULL . Please help me, I am completely confused as to what to do next...
Code :
@Local
public interface BatcRunLocal {
public void call(Map batc);
}
@stateless
public class batcRunBean implements BatcRunLocal {
public void call(Map batc) {
//Some code here .
}
}
In Struts2 Action Class, I am calling like this:
@EJB
package.BatcRunLocal batchRun;
batchRun.call(Map batc);
Upvotes: 0
Views: 460
Reputation: 14061
In Struts2 Action Class, I am calling like this:
I'm sorry, but I don't think Struts2 actions are injectable by the container. Only resources which are managed by the container can have injected resources. For instance, servlets, CDI beans, EJBs, JAX-RS, and so on.
So, I'd try to create a simple servlet that gets the EJB injected. If it does indeed get injected, then everything is working fine, it's just that Struts2 Action classes aren't managed by the container. If its still null, then you do have a problem, and I'd recommend taking a look at the logs, to see where the deployment failed.
If you are using JBoss AS, you'll notice in the logs if the EJB got deployed: JBoss AS is very vocal about this :-)
And I agree with @Richard Sitze : read a little about the Java naming conventions.
Upvotes: 1
Reputation: 8463
Change @stateless
to @Stateless
.
Also, you might put more focus on code style. In this case, classes names (batcRunBean) should start with a capital letter: BatcRunBean
.
Upvotes: 0