Importing applications into the development environment

Traditional Eclipse project organization

To analyze application source code for migration, the application must be imported into your Eclipse-based IDE. The application modules must be organized in projects that reflect their structure as EAR, web archive (WAR), and Enterprise JavaBeans (EJB) files. Specifically, some migration quick fixes that change web and EJB bindings and extensions only work when analyzing projects with the proper project facets to indicate they contain code for dynamic web modules and EJB modules.

If your files are not already in Eclipse, you can either import your existing EAR, WAR, and EJB modules or manually create new projects in the workspace for each EAR, WAR module, and EJB module. You can use the Import Eclipse options to create the correct project structure. Rational Application Developer or the Eclipse for Java EE developer tools are needed to create these projects properly.

For example, to import an EAR file, go to File > Import, select Java EE > EAR file. Enter the location of your EAR file. Eclipse creates a project for the EAR file and a project for each module in the application.

Figure 1. Importing an EAR file
Import Java EE EAR file

By importing the application, the proper project structure is created with the deployment descriptor information. If your EAR file contains the Java source code, it is also imported into the Eclipse project. However, most EAR and module files do not contain source code, and you need to copy the source code to its correct source folders. Again, go to File > Import to import the source code from the file system or from an archive ( .zip ) file. Repeat this procedure to import the source code for each module.

To create projects manually, go to File > New and select the appropriate project type:
  • EAR file: Enterprise Application Project
  • WAR file: Dynamic Web Project
  • EJB module: EJB Project
To copy the source files to their correct locations in the project, go to File > Import.

Review the following guidelines for structuring projects:

  • Place Java source code for a WAR file (for example, servlet, model, or utility classes) in the src folder of the project. The src folder is defined and can be changed in the Java Build Path properties for the project. If the Java source code needs to be referenced by more than one WAR file, see Shared Java projects for information on structuring the project files.
  • Place Java source code for an EJB module in the ejbModule folder of the EJB project.
  • Place precompiled Java archive (JAR) libraries for a WAR file in the WebContent/WEB-INF/lib folder.
  • Place EAR-level JAR libraries in the EarContent folder of the enterprise application project. If your project contains an APP-INF/lib folder, place the folder in the EarContent folder; however, you must run the class path rule and its quick fix to update the class paths correctly.

For a more detailed description of how to import applications into your IDE, see the WebSphere Application Server V8.5 Migration Guide ( http://www.redbooks.ibm.com/redbooks/pdfs/sg248048.pdf ).

Maven projects

To effectively analyze an application that uses Maven, install the latest M2Eclipse (m2e) in your Eclipse environment. WebSphere Developer Tools (WDT) and Rational Application Developer include m2e in the installation package. For some of the migration quick fixes to run correctly, the appropriate facets need to be set on the projects. For example, a web project requires the dynamic web module facet, and an EJB project requires the EJB module facet. Any newly created project in an IDE with m2e installed is automatically created with the appropriate facets when the proper archetype is chosen. When you import Maven projects that were not created in an environment with m2e, check the project to see whether the appropriate facets are set. To verify the facets, right-click on the project and navigate to Properties > Project Facet. You might run into a window with a similar message to Figure 4.

Figure 2. Convert to facet
Convert to facet

Select the Convert to facet form option to go to the correct project facet view. Select the correct facet for web projects and EJB projects.