-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Does a persistence-unit have to be packaged as an EJB?
PostPosted: Thu Oct 30, 2008 5:06 pm 
Regular
Regular

Joined: Sun Sep 25, 2005 11:35 pm
Posts: 57
I am trying to figure out if a persistence-unit has to be packaged as an EJB. What I have is an ear application that I want to deploy to JBoss. This application contains a jar containing my domain entities. This jar contains the following persistence unit which specifies a jta-data-source:

Code:
<persistence-unit name="myappDatabase">
    <jta-data-source>java:/myappDatasource</jta-data-source>
    <properties>
        <property name="jboss.entity.manager.factory.jndi.name" value="java:/myappEntityManagerFactory"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
    </properties>
</persistence-unit>


If I package the jar as a normal jar, I get the following exception when JBoss tries to deploy the application:

Code:
javax.naming.NameNotFoundException: myappEntityManagerFactory not bound


If I package my domain entities as an ejb jar, the exception goes away. So I have two questions:

1) Is it true that if I have a persistence-unit that needs to be deployed on JBoss then it must be packaged as an ejb?

2) How do I test this jar outside an ejb container (using junit etc.)? I am able to do this by changing the persistence configuration to transaction-type="RESOURCE_LOCAL", but then I can't keep both the configurations in the same jar (local and jta). How do people deal with this issue?

Thanks.
Naresh


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.