As EJB3 applications are becoming mainstream atleast for Oracle AS customers with our 10.1.3 release, I will start blogging about real issues and how to deal with these.
Now that you ejb-jar.xml is optional and you can use annotations. Debugging of EJB3 applications could be quite complex. Also you may mix-n-match annotations and deployment descriptors and you may use descriptors to override settings originally specified using annotations
You can make obvious mistakes and debugging can be hairy.
#1 You have to remember the basic rule that name element in Stateless, Stateful and MessageDriven annotations is same as ejb-name in the descriptor. If you do not specify the name element with these annotations then the name of the bean class is inferred as the ejb-name.
#2 If you are overriding an element or specifying new configuration using ejb-jar for an EJB then you must ensure that the name element specified in Stateless annotation and ejb-name in the deployment descriptor must be the same otherwise you will end-up with two different EJBs.
Let us take an example to make things clear. Let us assume that we have a Stateless EJB defined as follows and assume you have defined transaction type to bean with annotation.
@Stateless(name="BazaarAdmin")
public class BazaarAdminBean implements BazaarAdmin
You are trying to override the transaction type to Container using the deployment descriptor and hence you put the following entry in the descriptor.
<session>
<ejb-name>BazaarAdminBean</ejb-name>
..
<transaction-type>Container</transaction-type>
</session>
In the above descriptor example, the ejb-name between the annotations and descriptors do not match and EJBs being identified by the names the container will treat them as two different EJBs. You have to make sure that ejb-name element to match to ensure that overriding works correctly and hence you must change the ejb-name as follows:
<ejb-name>BazaarAdmin</ejb-name>
We have added some features in OC4J 10.1.3 to make life easier with EJB3 applications. For example, we generate a complete ejb-jar.xml for EJB3 applications during deployment in the %OC4J_HOME%/application-dployments/<appName>/<ejbModuleName>/ directory even if you do not package an ejb-jar.xml. This will give you an idea what deployment configuration is used by the container. You can use this as a debugging tool too.
Also we have built several new logger/debugger that you can enable to generate meaningful information how annotations are being parsed during deployment.
5:21:09 AM
|