Bean in jar inside EAR/lib folder possible?

I have an EAR with the following structure:

myapp.ear
...META-INF
......application.xml
...lib
......common.jar
......specialBeanlib.jar
...myejb.jar
...mywar1.war
...mywar2.war

As you can see common.jar and specialBeanlib.jar are in the EAR lib folder.

myejb.jar contains the service classes.
mywar1.war contains the user-gui.
mywar2.war contains the admin-gui.

The ejb and the war modules are build from separate maven projects and are referenced in the application.xml file. The file specialBeanlib.jar is referenced as provided dependency in both web projects and as normal dependency in the ejb project so it gets stored in the EAR lib folder. It explicitly should not be an own ejb module.

The question: Can I have any Beans eg an @ApplicationScoped Bean, in the file specialBeanlib.jar , so it is accessible from both mywar1.war and mywar2.war via @Inject ?


it should be fine. During the compile time, since you provide the specialBeanlib.jar as dependency in the Maven, it should appear in the classpath during the compilation of mywar1 and mywar2 modules. During he run-time, since speicalBeanlib.jar is located in the earlib folder, which is at the parent classloader of the war classloaders, the bean class should be loaded fine too.

链接地址: http://www.djcxy.com/p/82666.html

上一篇: 我的EAR中的WAR不会正确加载log4j2,但是JAR会加载它

下一篇: EAR / lib文件夹中的jar可能吗?