how to create ear file, and include war and jar files inside that

荒凉一梦 提交于 2020-06-24 07:14:34

问题


I am trying to create an EAR file from the command prompt. I have used

jar -cvf myServletWAR.ear . 

But my question is, how can I get this EAR file to have WAR files and JAR files inside it?

Do I need to create the war file separately and include in the ear file?

I can't use the ANT file for this, as there are few restrictions on this project.


回答1:


One of my EAR files has structure as follows:

app.ear
  - APP-INF
    - lib
      // libraries (.jar) here
  - META-INF
    - MANIFEST.MF
    - weblogic-application.xml
  - module1.war
  - customlib.jar

This archive is being deployed onto WebLogic 10.3.

Remeber .ear is just a ZIP file, so you can always create it this way, although it seems messy.




回答2:


check if jar cmd is working if so, create the jar of your class files and descriptors etc.

After that jar -cvf <<earname>> <<files want to be in the ear >>




回答3:


Could you try this :

jar -xvf myServletWAR.ear

You could also refer to :

How to add a WAR file into an existent EAR file? and how to I have two .war files within one .ear file?

You would have to add these EAR file references in the application.xml of the ear file.




回答4:


If you have generated a client and EJB together, they are automatically packaged into an enterprise archive file (.ear) and you do not need to do this. Otherwise:

  • Package the EJB's .jar file into an .ear for your application. To do this use a jar command similar to the following:
jar -cvf myApplication .ear myService.jar

If you have a client .war file you can add that to the .ear file in the same way.

  • Create a deployment descriptor application.xml either using your
    application server's tools or by copying and editing a sample, as
    follows:

  • Locate a sample .ear, which is in examples directory in

mapdemo/mapdemo/repos/myService.deploy/JMapServ-WL.ear
  • Extract the descriptor application.xml from the .ear file, using the following jar command:

jar -xvf JMapServ-WL.ear META-INF/application.xml

  • Make a copy of the application.xml descriptor and edit it, replacing JMapServ with the name of your .jar file. You can also add the name of your .war file if you added that to the .ear file.

  • Put the descriptor in the meta-inf subdirectory of the directory containing your .ear file.

  • Package the descriptor into your .ear file using a jar command similar to:

jar -uvf myService.ear META-INF/application.xml



回答5:


.jar file into an .ear

jar -cvf myApplication .ear myService.jar

.war file you can add that to the .ear file in the same way.

Reffer http://supportline.microfocus.com/Documentation/books/sx51/thdpoy10.htm




回答6:


If you want to create an ear from the command line, following are the options that you can try.

Option 1. Using an ant build and use the ear task. Configure this ear task as stated in stackoverflow question on ant ear task usage

Note: Maven based build is preferred over ant these days.

Option 2. If you can use maven, configure your modules and use maven ear plugin to generate an ear. The below command will be able to generate the ear.

mvn clean package

Refer to the maven question regarding a Java EE project for more information on configuring war, jars for an ear.



来源:https://stackoverflow.com/questions/15197114/how-to-create-ear-file-and-include-war-and-jar-files-inside-that

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!