One of the changes in JBoss AS 5 that comes as a surprise for many
Seam developers/users familiar with the behavior of JBoss AS 4 is the
automatic loading of persistence units from /META-INF/persistence.xml.
(As expected, we had to change several of the Seam examples to
accommodate this change). This is one of those configuration by
exception features in Java EE 5, with one significant exception. While
the container will locate the /META-INF/persistence.xml file on its
own, a container that goes by the book will only deploy the
persistence unit if a resource reference is declared in the descriptor
file (web.xml or ejb-jar.xml). JBoss AS does not wait for this signal.
In my opinion, there is a problem with the JBoss AS approach. What if
you have persistence units that you don't want to deploy? One use case
is that you have persistence units for different environments and a
configuration file can toggle between them. Another use case is that
you have another library, such as Spring or Seam, which bootstraps the
persistence unit instead. Sure, you could rename the file, but then
you break all the IDE behavior that expects the file to be named
persistence.xml. Personally, I think there should be some way to
disable the behavior in JBoss AS and make it look for the persistence
unit references. I agree to keep the automatic loading as the default,
but it is pretty inconvenient not to be able to disable it.
Anyone else agree? Disagree? Why?
-Dan
--
Dan Allen
Software consultant | Author of Seam in Action
http://mojavelinux.com
http://mojavelinux.com/seaminaction
NOTE: While I make a strong effort to keep up with my email on a daily
basis, personal or other work matters can sometimes keep me away
from my email. If you contact me, but don't hear back for more than a week,
it is very likely that I am excessively backlogged or the message was
caught in the spam filters. Please don't hesitate to resend a message if
you feel that it did not reach my attention.