What is the correct way to package an enterprise application
Assume your application consists only of one war file. My understanding is, that any third party library I need, and I am allowed to provide, I will include in my war, in WEB-INF/lib.
Today I came across someone who told me some details about JBoss 7 and their c开发者_JS百科oncept of modules, suggesting that an application should not deliver any third party library...but rather request the library in the correct version from the application server.
I am still more the type of guy who likes to deliver a full package, w/o any dependencies another user has to make sure, they are fullfilled. Now, long story short....is there a "Java EE standard" answer, how to cope with third party libraries in enterprise applications?'
Per the Java EE 6 Tutorial:
The document root contains a subdirectory named WEB-INF, which can contain the following files and directories:
classes: A directory that contains server-side classes: servlets, enterprise bean class files, utility classes, and JavaBeans components
tags: A directory that contains tag files, which are implementations of tag libraries
lib: A directory that contains JAR files that contain enterprise beans, and JAR archives of libraries called by server-side classes
Deployment descriptors, such as web.xml (the web application deployment descriptor) and ejb-jar.xml (an EJB deployment descriptor)
So /WEB-INF/lib is correct.
The "standard" answer depends on whether or not your Java EE app server supports the OSGi or JSR-277 standard.
JBOSS version 7 does support OSGi; earlier versions might not.
So it's really two answers: one for pre-OSGi servers ("put JARs in WEB-INF/lib for your app or the server /lib") and post-OSGi ("use OSGi").
精彩评论