是否所有EJB都部署为JAR?

时间:2017-11-12 03:39:59

标签: jar glassfish ejb war ear

在查看Netbeans如何使用ant构建企业应用程序时,将其打包为EAR文件:

library-inclusion-in-manifest:
     [copy] Copying 1 file to /home/thufir/NetBeansProjects/netbeansEnterpriseApp/build/lib

-do-ear-dist:
    [mkdir] Created dir: /home/thufir/NetBeansProjects/netbeansEnterpriseApp/netbeansEnterpriseApp-ejb/dist
      [jar] Building jar: /home/thufir/NetBeansProjects/netbeansEnterpriseApp/netbeansEnterpriseApp-ejb/dist/netbeansEnterpriseApp-ejb.jar

-post-dist:

dist-ear:

pre-pre-compile:

pre-compile:

-do-compile-deps:
     [copy] Copying 1 file to /home/thufir/NetBeansProjects/netbeansEnterpriseApp/build

do-compile:
     [copy] Copying 1 file to /home/thufir/NetBeansProjects/netbeansEnterpriseApp/build/META-INF

post-compile:

compile:

pre-dist:

do-dist-without-manifest:

do-dist-with-manifest:
    [mkdir] Created dir: /home/thufir/NetBeansProjects/netbeansEnterpriseApp/dist
      [jar] Building jar: /home/thufir/NetBeansProjects/netbeansEnterpriseApp/dist/netbeansEnterpriseApp.ear

post-dist:

dist:

BUILD SUCCESSFUL
Total time: 1 second
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ tree
.
├── build
│   ├── lib
│   │   └── netbeansRemoteInterface.jar
│   ├── META-INF
│   │   └── MANIFEST.MF
│   └── netbeansEnterpriseApp-ejb.jar
├── build.xml
├── dist
│   └── netbeansEnterpriseApp.ear
├── nbproject
│   ├── ant-deploy.xml
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   │   └── private.properties
│   ├── project.properties
│   └── project.xml
├── netbeansEnterpriseApp-ejb
│   ├── build
│   │   ├── classes
│   │   │   ├── ejb
│   │   │   │   └── NewSessionBean.class
│   │   │   ├── META-INF
│   │   │   │   └── MANIFEST.MF
│   │   │   └── netbeansRemoteInterface.jar
│   │   ├── empty
│   │   └── generated-sources
│   │       └── ap-source-output
│   ├── build.xml
│   ├── dist
│   │   └── netbeansEnterpriseApp-ejb.jar
│   ├── nbproject
│   │   ├── ant-deploy.xml
│   │   ├── build-impl.xml
│   │   ├── genfiles.properties
│   │   ├── private
│   │   │   └── private.properties
│   │   ├── project.properties
│   │   └── project.xml
│   └── src
│       ├── conf
│       │   └── MANIFEST.MF
│       └── java
│           └── ejb
│               └── NewSessionBean.java
└── src
    └── conf
        └── MANIFEST.MF

23 directories, 25 files
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ asadmin deploy dist/netbeansEnterpriseApp.ear 
Application deployed with name netbeansEnterpriseApp.
Command deploy executed successfully.
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ asadmin list-applications
netbeansEnterpriseApp  <ear, ejb>  
Command list-applications executed successfully.
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp$ cd dist/
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ ls
netbeansEnterpriseApp.ear
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ jar xf netbeansEnterpriseApp.ear 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ ll
total 40
drwxr-xr-x 4 thufir thufir 4096 Nov 11 19:29 ./
drwxrwxr-x 7 thufir thufir 4096 Nov 11 19:28 ../
drwxr-xr-x 2 thufir thufir 4096 Nov 11 19:28 lib/
drwxr-xr-x 2 thufir thufir 4096 Nov 11 19:28 META-INF/
-rw-r--r-- 1 thufir thufir 2834 Nov 11 19:28 netbeansEnterpriseApp.ear
-rw-r--r-- 1 thufir thufir 1351 Nov 11 19:28 netbeansEnterpriseApp-ejb.jar
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ 
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ ll lib/
total 20
drwxr-xr-x 2 thufir thufir 4096 Nov 11 19:28 ./
drwxr-xr-x 4 thufir thufir 4096 Nov 11 19:29 ../
-rw-r--r-- 1 thufir thufir  782 Nov 11 19:28 netbeansRemoteInterface.jar
thufir@dur:~/NetBeansProjects/netbeansEnterpriseApp/dist$ 

我注意到,当部署到Glassfish时,会列出EAR和EJB。就其本身而言,EJB是packaged作为JAR?没有将EJB打包为EAR这样的东西? (相反,根据我的理解,在EAR或WAR中打包的任何EJB最终都被部署为JAR。)

或者,是否存在部署为JAR文件的EJB?

1 个答案:

答案 0 :(得分:0)

是的,如果您的应用程序服务器(如jboss7和w​​ildfly)支持,则WAR中的EJB不需要打包为Jar。 ejb-classes可以在WEB-INF / classes中的WAR中找到。

您可以在ejb-cdi-unit-test-war找到的用于测试的示例项目。如果您尝试克隆,则需要maven来构建项目。