hello.ear:The content of META-INF/application.xml:
META-INF/application.xml
shared/util-1.jar
shared/util-2.jar
hello-ejb.jar
hello.war
<?xml version="1.0" encoding="UTF-8"?>All classes and resources in all jar files under shared directory (e.g., util-1.jar, util-2.jar) are accessible to hello-ejb.jar and hello.war. For instance, you may choose to put hello-ejb's business interfaces, component interfaces and home interfaces in util-1.jar, to avoid duplicates in ejb jar and war.
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_5.xsd">
<module>
<ejb>hello-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>hello.war</web-uri>
<context-root>hello</context-root>
</web>
</module>
<library-directory>shared</library-directory>
</application>
Better yet, you don't even need to have an application.xml to use this mechanism. Recall that all descriptors are optional in JavaEE 5. The default library-directory is a directory named lib inside the EAR. You just put your shared jar files here and they will be automatically made accessible for all components. However, these files do need to use *.jar extension.
Tags: