EJB 3.1: Stateless Session Bean Deployed as .war, Dependency Injection, Asynchronous Methods

Development of an EJB 3.1 stateless session bean has become incredibly simple. You add an annotation, there is no XML required at all, no need to implement an interface anymore, and you can easily implement asynchronous methods that decouple your client calls from the method execution. Then, at the end you deploy the EJB as a simple .war file – no need to warp it in an .ear file.

 

The following screencasts explain you how to do it. You can also download the whole NetBeans project  or just a deployable .war file exactly the sources created in the screencasts.

 

Simple Stateless Session Bean with asynchronous method, developed with NetBeans 7.1 and deployed as .war file:

Asynchronous Methods with Stateless Session Bean:

Inject Stateless Session Bean into Servlet:

 

Here is a tough question at the end:

Imagine you have to add a WebLogic specific settings for your stateless session bean. There is no annotation for that. These settings have to be put in the deployment descriptor which typically used to be the weblogic-ejb-jar.xml file within an .ear file. But what if you have already build a .war file which is perfectly possible now (and neither an .ear nor an ejb.jar file).

Where do you put these settings then? Post your answer here.

Comments

  1. guess the plan.xml ist what you mean :)?

    • d0natas,

      kind of missed your reply. sorry about that.
      but yes, you are absolutely right!
      the EJB descriptors go to WEB-INF/ejb-jar.xml etc. and then you could overwrite them with a plan.xml.

      best,

      Frank

  2. Thank you for your awesome blog about the weblogic 12c. The screen caste 2 and 3 are same(duplicate) but the heading is different.

    • Venu,

      I appreciated your feedback. I will correct this, but currently I am travelling in Australia and my Mac with the videos is in Germany. So it will take at least 2 weeks…

      thanks!

      Frank

    • well, wearing sackcloth and ashes, it took over 2 months to fix it (not 2 weeks ;) ). but it’s done now!

Speak Your Mind

*