tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred59 <frederic.fouc...@atosorigin.com>
Subject Overriding persistence-unit-name
Date Tue, 12 May 2009 08:27:10 GMT

Hi all,

My current work topic is the extensibility with the EJB 3. We use OpenEJB
3.1.
In project B, we are trying to use session bean (CatalogueManager) coming
from an other project A.

To achieve that goal, we must override the persistence unit name defined in
the @PersistenceContext located in the CatalogueManager session bean. We use
then the ejbjar.xml in project B and define its content like the following :

<ejb-jar>
	<enterprise-beans>
		<session>
		
<ejb-name>xastory-csm-core.net.atos.xastory.csm.core.product.CatalogueManager</ejb-name>
		
<ejb-class>net.atos.xastory.csm.core.product.impl.CatalogueManagerImpl</ejb-class>
			<persistence-context-ref>
				<persistence-context-ref-name>
					net.atos.xastory.csm.core.product.impl.CatalogueManagerImpl/em
				</persistence-context-ref-name>
				<persistence-unit-name>
					cmi-csm-core
				</persistence-unit-name>
			</persistence-context-ref>
		</session>
	</enterprise-beans>
</ejb-jar>
the ejb-name is the same one defined in the @Stateless CatalogueManager
annotation.

When I launch the unit test in project B, I obtain the following log :
http://www.nabble.com/file/p23498287/OpenEJBExtend.log OpenEJBExtend.log 
The exception is a  javax.naming.NameAlreadyBoundException type.

If I change the name like the following :

<ejb-jar>
	<enterprise-beans>
		<session>
			<ejb-name>projectBCatalogueManager</ejb-name>
		
<ejb-class>net.atos.xastory.csm.core.product.impl.CatalogueManagerImpl</ejb-class>
			<persistence-context-ref>
				<persistence-context-ref-name>
					net.atos.xastory.csm.core.product.impl.CatalogueManagerImpl/em
				</persistence-context-ref-name>
				<persistence-unit-name>
					cmi-csm-core
				</persistence-unit-name>
			</persistence-context-ref>
		</session>
	</enterprise-beans>
</ejb-jar>

The unit test works, but in the resulting logs 
http://www.nabble.com/file/p23498287/OpenEJBExtendB.log OpenEJBExtendB.log ,
i can notice that OpenEJB deploys two session beans from the same
implementation but with two different name:
     -xastory-csm-core.net.atos.xastory.csm.core.product.CatalogueManager
     -projectBCatalogueManager

I wonder how OpenEJB can manage to choose the right instance ?
My aim is to override the initial session bean's behavior and the result
seems to be a duplication with an other name.

Do I miss anything ? Am I doing anything wrong ?

I would be grateful for your answers.
Thanks in advance.

Fred



-- 
View this message in context: http://www.nabble.com/Overriding-persistence-unit-name-tp23498287p23498287.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message