Executing the client
We can execute our client by simply right-clicking on the Enterprise Application
Project and selecting Run . After a few seconds, we should see an information dialog
displaying the output of the session bean's method.
Clients deployed this way take advantage of Java Web Start technology. Java Web
Start Applications run on the client workstation, however, they can be executed
from an URL. The webstart URL for NetBeans enterprise application client
modules defaults to the Enterprise project name, followed by the application client
module name. In our example, the URL would be http://localhost:8080/
SessionBeanIntro/SessionBeanIntro-app-client . We can verify this by
pointing the browser to this URL. The application client will be executed after a
Session bean transaction management
As previously mentioned, one of the advantages of Enterprise JavaBeans is that they
automatically take care of transactions. However, there is still some configuration
that we need to do in order to better control transaction management.
Transactions allow us to execute all the steps in a method or, if one of the steps fails
(for instance, an exception is thrown), roll back the changes made in that method.
Primarily what we need to configure is our bean's behavior if one of its methods is
called while a transaction is in progress. Should the bean's method become part of
the existing transaction? Should the existing transaction be suspended, and a new
transaction created just for the bean's method? We can configure this behavior via
the @TransactionAttribute annotation.
The @TransactionAttribute annotation allows us to control how an EJB's methods
will behave both when invoked while a transaction is in progress, and when invoked
when no transaction is in progress. This annotation has a single value attribute
that we can use to indicate how the bean's method will behave in both of these