posts - 33, comments - 46, trackbacks - 0, articles - 2

EAR文件结构

Posted on 2013-04-08 16:18 在路上... 阅读(3407) 评论(0)  编辑  收藏 所属分类: JAVA相关
1、打包文件命名规则
根据JavaEE规范,打包的EAR文件可以不适用部署描述符部署,因此需要使用一些默认的约定规则,例如
•EJBs and client archives are packaged as .jar files.

•Web applications are packaged as .war files.

•Resource adapters are packaged as .rar files.

•Enterprise applications are packaged as .ear files, and can contain other Java EE modules such as EJBs, JDBC, JMS, Web applications, and Resource Adapters.

•Web Services can be packaged either as .war files or as .jar files, depending on whether they are implemented using Java classes or EJBs. Typically, the .war or .jar files are then packaged in an Enterprise Application .ear file.

•Java EE libraries are packaged either as an Enterprise Application (.ear file) or as a standard Java EE module.

•Client applications and optional packages are packaged as .jar files.
2、Java EE默认部署规则
通常EAR应用也可以使用开放式目录部署,此时也应该参考以上的规范配置相应的文件夹,例如
war应用目录名必须为XX.war
EAR==>xx.ear 
RAR==>XX.rar
EJB==>xx.jar

3、Java EE标准的部署规则
a. 应用包中所有扩展名是.war 的文件被看作是 web 模块。Web 模块的上下文根
的名字是相对于应用包根的名字,但要去掉.war 扩展名。
b. 应用包中所有扩展名是.rar 的文件都被看作是资源适配器。
c. 名字为 lib 的目录被看作是库目录,正如在节 8.2.1“捆绑的库”中所述。
d. 对于应用包中所有以扩展名是.jar 但不包含在 lib 目录内的文件来说,按下面 的方式来处理:
i. 如果 JAR 文件中包含带有 Main‐Class 属性的 META‐INF/MANINFEST.MF 文件, 或者包含 META‐INF/application‐client.xml 文件,那么这个 JAR 文件被看作 是应用客户端模块。
ii. 如果 JAR 文件包含 META‐INF/ejb‐jar.xml 文件,或者包含任何带有 EJB 组件 注释符(Stateless,等等)的类,那么这个 JAR 文件被看作是 EJB 模块。
iii. 所有其他的 JAR 文件都被忽略,除非它被上面的 JAR 文件使用 JAR 文件引 用机制(如在 mainfest 文件中的 Class‐Path 头library-directory)引用。

在Jboss环境中,可以在application.xml中手工指定library-directory,例如:
<library-directory>APP-INF/lib</library-directory>
其他的jboss遵循标准规范

4、Weblogic的部署规则

对于weblogic使用下面的一些规则处理目录结构:

•For an exploded archived Web application, in the absence of WEB-INF/web.xml descriptor, the name of the directory should have a .war suffix.

•For an exploded archived Enterprise Application without a META-INF/application.xml descriptor, the directory should have an .ear suffix. Within the application, the directory of exploded Web module should have a .war suffix. Similarly, the exploded EJB module should have a .jar suffix and the exploded RAR module should have a .rar suffix.

•If an exploded Enterprise Application contains no META-INF/application.xml descriptor, the order in which modules are deployed is undefined and is dependent on the underlying File.listFiles() method order. To ensure a specific order in which modules are deployed, you must add an application.xml descriptor and list the modules in the desired order.

如果在weblogic下面如果不使用上面的规则,则需要在application.xml 文件中指定对应的uri路径
或者在应用模块中使用下面的manifest路径规则

4.1 classloader的路径引用
在weblogic中EAR里面的所有应用共有一个classloader,所以对于ear里面的war,通常不需要在WEB-INF里面包含lib,weblogic提供了一个默认的目录:
APP-INF\lib:存放jar包
APP-INF\classes:存放classes

注意对于其他的应用服务器,可能没有这样的规则

5、Manifest Class-Path规则
在java EE规范中,可以使用manifest文件指定当前的应用模块对与其他classpath路径的关联引用,该文件位于
META-INF/MANIFEST.MF
路径下面,内容例如下面,多个引用路径使用空格分隔:
Manifest-Version: 1.0
Class-Path: utility.jar ../xxx/classes ../xxxlib/xxx.jar

META-INF/MANIFEST.MF



Manifest Class-Path


 

参考页面: http://docs.oracle.com/cd/E12839_01/web.1111/e13706/classloading.htm http://docs.oracle.com/cd/E12839_01/web.1111/e13702/deployunits.htm#DEPGD142

只有注册用户登录后才能发表评论。


网站导航: