jaikiran pai [
http://community.jboss.org/people/jaikiran] created the discussion
"Re: JBoss Modules and a NICE Documentation"
To view the discussion, visit:
http://community.jboss.org/message/644348#644348
--------------------------------------------------------------
Nikos Ballas wrote:
Yes yes , i tried the deployments and deployment you suggest in the link ,but i challenge
you to do the following:
1)Declare a jar where you will only have @Entity mappings with persistence.xml and
orm.xml(not mandatory in JPA 2.0).Deploy that.
2)Declare a jar where you will have your EJB's 3 which will implement a service layer
and you need to do the @PersistenceContext(unitName="mypu").
Deploy that following the jboss-deployment-structure.xml.I think you will be
disappointed.I have already discussions with Scott Marlow on it...there is also a JIRA
issue created out of it and currently there is no way to inject in different deployments
services from other deployed jars.
So you have 2 independent deployments (one
containing the persistence unit and the other using it) and you want to access the
persistence unit in the second deployment? There's no +portable+ way for it:
JPA2 spec, section 8.2.2 Persistence Unit Scope
An EJB-JAR, WAR, application client jar, or EAR can define a persistence unit. When
referencing a persistence unit using the unitName annotation element or persistence-
unit-name deployment descriptor element, the visibility scope of the persistence unit is
determined by its point of definition:
- A persistence unit that is defined at the level of an EJB-JAR, WAR, or application
client jar is scoped to that EJB-JAR, WAR, or application jar respectively and is visible
to the components defined in that jar or war.
- A persistence unit that is defined at the level of the EAR is generally visible to all
components in the application. However, if a persistence unit of the same name is defined
by an EJB-JAR, WAR, or application jar file within the EAR, the persistence unit of that
name defined at EAR level will not be visible to the components defined by that EJB-JAR,
WAR, or application jar file unless the persistence unit reference uses the persistence
unit name # syntax to specify a path name to disambiguate the reference. When the # syntax
is used, the path name is relative to the referencing application component jar file. For
example, the syntax ../lib/persistenceUnitRoot. jar#myPersistenceUnit refers to a
persistence unit whose name, as specified in the name element of the persistence.xml file,
is myPersistenceUnit and for which the relative path name of the root of the persistence
unit is ../lib/persistenceUnitRoot.jar. The # syntax may be used with both the unitName
annotation element or persistence-unit-name deployment descriptor element to reference a
persistence unit defined at EAR level.
Previous versions of JBoss AS used to allow it but it was a JBoss specific extension.
I'm not sure if other server support it.
Nikos Ballas wrote:
@Stephen...for me it works to...but i don't want to use ears/wars only deployments
Any reason why you want to avoid such packaging which allows you to achieve the
usecase you are after?
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/644348#644348]
Start a new discussion in JBoss AS 7 Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]