Question

In the JavaEE 7 tutorial

The following is mentioned

Enterprise beans often provide the business logic of a web application. In these cases,
packaging the enterprise bean within the web application's WAR module simplifies
deployment and application organization. Enterprise beans may be packaged within a
WAR module as Java programming language class files or within a JAR file that is
bundled within the WAR module.

Then after a short while

JAR files that contain enterprise bean classes packaged within a WAR module are not
considered EJB JAR files, even if the bundled JAR file conforms to the format of an EJB
JAR file. The enterprise beans contained within the JAR file are semantically
equivalent to enterprise beans located in the WAR module's WEB-INF/classes directory,
and the environment namespace of all the enterprise beans are scoped to the WAR module.

I can't make it past this part, to understand the example.

How is it possible that

Enterprise beans may be packaged within a WAR module as Java programming language class files or within a JAR file that is bundled within the WAR module

yet

JAR files that contain enterprise bean classes packaged within a WAR module are not considered EJB JAR files, even if the bundled JAR file conforms to the format of an EJB JAR file.

Était-ce utile?

La solution

The specification is trying to say that EJB annotations will be recognized on classes in WEB-INF/classes/ or within JARs in WEB-INF/lib/, but if you decide to move a pre-existing EJB module JAR into WEB-INF/lib/, it will be interpreted as a regular JAR, not as an independent EJB module, which means module-specific deployment descriptors in that JAR will be ignored (e.g., META-INF/ejb-jar.xml, META-INF/validation.xml, META-INF/beans.xml, etc.). Instead, those descriptors need to be merged together and put into the containing WAR's WEB-INF/ (e.g., WEB-INF/ejb-jar.xml, etc.).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top