Which of the following is true for a portable JavaEE application?

A JavaEE application is packaged as follows.

Which of the following is true for a portable JavaEE application?

A JavaEE application is packaged as follows.

Which of the following is true for a portable JavaEE application?

A.
This is an invalid application. A JavaEE application cannot have more than one persistent with same name.

B.
�MyPu� defined under each module is visible to only the defining module. There is no way other modules can access it.

C.
Code in the ejb1.jar can access �MyPU� defined under war1.war using �war1#myPU�



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Mohamed Fayek

Mohamed Fayek

all is wrong
explanation:

Only the PUs defined at the ear level (i.e. PUs contained in a jar file placed in the library directory of the ear) are accessible to all the other components of the ear.

Here, ejb1.jar defines an EAR level PU, which can be accessed by code in war1.war. However, the reverse is not possible.

The restriction is that only one persistence unit of any given name must be defined within a single EJB-JAR file, within a single WAR file, within a single application client jar, or within an EAR. Here,
the same name for two PUs is used but not in the same scope. One is in war file and another is in a separate jar file. So this is valid.

The classes in myPU defined in war1.war can access myPU defined in ejb1.jar using the name ../../lib/ejb1.jar#myPU.

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.

Mohamed Fayek

Mohamed Fayek

sorry take in consideration that ejb1.jar is not at EAR LEVEL because it is not under the lib of application.

Mohamed Fayek

Mohamed Fayek

sorry in this case B is correct.

Lejmi

Lejmi

B is correct