How does import and export of .war files to a deployed tomcat instance work?

How do I import and alternately export a .war file within Eclipse and also, how is the imported .war file configurable within Eclipse?

Answers

  • **In general Eclipse has a native .war file import that you can use…** [
    http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Ftwimpwar.html][1]

    1. Select File > Import . 2. In the Import dialog, select WAR file and then click Next. 3. Locate the WAR file that you want to import using the Browse button. 4. The wizard assumes you want to create a new Web project with the same name as the WAR file. If you accept this choice, the project will be created with the same servlet version as specified by the WAR file and in the same location. If you want to override these settings, you can click New and specify your new settings in the Dynamic Web Project wizard. 5. Click Finish to populate the Web project. And a native export feature: [
    http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Ftwcrewar.html][2]

    **To export a WAR file from a Web project, do the following:**

    1. Right click on a Web project folder and select Export from the pop-up menu. Then select WAR file in the Export window and then select Next.

    2. Specify the Web project you want to export (this field is primed if you used the pop-up menu to open the wizard), and specify a location for the new WAR file.

    3. Optionally, supply WAR export Options, such as whether or not to include Java™ source files in the WAR, and whether to overwrite any existing resources during the export process. Source files are not usually included in a WAR file, because they are not necessary for the server to run the web application. 4. Click Finish. **However, if you want to simply spin up the war file without creating a new project use the following steps:** **How to deploy a Tomcat instance of a webapp from a war file within eclipse.** 5. Create a new empty server in Eclipse and name it appropriately. Do not add any local eclipse project to the server.

    6. Run the new server once (with no project added) to create the appropriate directories, likely at the following location:{path to workspace}\{project name}\.metadata\.plugins\org.eclipse.wst.server.core\tmp1

    Note that the new location would be the highest number in the org.eclipse.wst.server.core directory [ tmp1, tmp2, tmp3 etc.]. I will use tmp1 as an example in this case.

    7. Copy the your new war file or unzipped war directory into the webapps folder located at: {path to workspace}\{project name}\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps

    8. Select Open Launch Configuration for the new server. In the Arguments tab, add the following to the existing VM arguments. You may need to add other VM arguments if the project requires those.

    -DapplicationProperties="{path to workspace}\{project name}\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps\{Your war file name without extension}\WEB-INF\classes\{yourProject.properties}”

    ``Run the new server and test [1]:
    http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Ftwimpwar.html [2]:
    http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Ftwcrewar.html