Skip to content
This repository

How to build and run MCT in Eclipse 

VWoeltjen edited this page · 30 revisions

Within this section, we will learn how to take the MCT code found on GitHub and be able to build and run it within the Eclipse IDE. This page is structured in the following way: first we begin with a prerequisites section which defines what you need before being able to build and run MCT in the Eclipse environment. Then we offer our recommended set-up. Next we present a detailed step-by-step guide for bringing MCT and Eclipse together, as well as a terse-version for those well-experienced in Eclipse. Lastly we conclude with a section for those using MySQL with MCT, as well as a section on troubleshooting the MCT/Eclipse setup.

Table of Contents

  1. Prerequisites
  2. Our Recommended Setup
  3. Building and Running MCT in Eclipse
    1. Terse Guide
    2. Detailed Guide
  4. For MySQL users
  5. Troubleshooting

Prerequisites

Recommended Setup

We, the MCT team here over at NASA Ames, recommend the following setup for developing MCT under Eclipse:

  • Java SE 6 JDK (as MCT was originally build with respect to Java 6)
  • Apache Derby (MCT is configured to work with Apache Derby; you will have to do some extra steps if you want to use MySQL)
  • The latest version of Apache Derby
  • Eclipse Kepler (as it has GitHub and Maven plugins--as well as many other useful tidbits--already integrated into the IDE)

Building and Running MCT in Eclipse

Within this section we bring the MCT project into the Eclipse development environment. The steps in which to do this is presented in two equivalent ways:

  • Terse: Only the high-level steps. Best for experienced Eclipse users.
  • Detailed: This instruction set for those not comfortable navigating the Eclipse environment.

Should you, working in the Terse instruction-set, need a bit more detail, then refer to the same numbered-step within Detailed section.

Terse Guide

The following is a terse instruction-set, designed to get the user, experienced with the Eclipse IDE, building and running MCT in Eclipse post-haste. We assume you have already forked-and-cloned yourself of MCT from our GitHub site. Now, should you need more detail for a specific step, look that same step up in the detailed section.

  1. Import your local copy of MCT into Eclipse. We recommend you make a separate workspace for MCT, as it contains a fare amount of projects.
  2. Next we have Maven setup resources needed to run MCT in Eclipse:
    1. From the superpom directory, run (from the terminal) mvn -N install.
    2. Now, from the platform-assembly directory, run (from the terminal) mvn install -DskipTests -Declipse -Ddistribution.
  3. Add a linked resource named "M2_REPO" pointing to your Maven repository, typically at ~/.m2/repository. Note that Eclipse will need the full path.
  4. Verify that an M2_REPO classpath variable has been added to Eclipse's Java build path (usually there by default; should point to Maven repository, ~/.m2/repository. Eclipse will need the full path.)
  5. Set an API Baseline. In Eclipse 4.2 or above, it is easiest to set Eclipse to ignore missing API baselines; otherwise, add a baseline "MCT_API_Baseline"
  6. Refresh all of the projects in Eclipse
  7. Now add a M2_REPO environment-variable to MCT's run configuration (points to Maven repository, again, usually at ~/.m2/repository. Eclipse will need the full path.)
  8. Set your Java compiler compliance level if necessary (MCT is developed under Java 6 but has been tested against Java 7 as well.)

Detailed Guide

The following is a detailed instruction-set, meant to shed light on the Eclipse IDE, that will end with you being able to build and run MCT within the Eclipse IDE.

  1. Bring MCT into Eclipse
  2. Next we have Maven setup resources needed to run MCT in Eclipse:
    1. (From the terminal) cd into the directory containing your MCT project. Note the directories superpom and platform-assembly.
    2. From the superpom directory, run (from the terminal) mvn -N install.
    3. Upon receiving "Build Success", cd back into the directory containing your MCT project
    4. Now, from the platform-assembly directory, run (from the terminal) mvn install -DskipTests -Declipse -Ddistribution.
  3. Now set up Linked Resources in Eclipse:
    1. Navigate to Eclipse Preferences -> General -> Workspace -> Linked Resources
    2. Click the button new.
    3. Click the button folder.
    4. Select the directory named repository, which is located at ~/.m2/repository, and click the button open.
    5. In the name field, enter "M2_REPO".
    6. Click Ok.
  4. Now we check that the M2_REPO classpath variable has been added:
    • Navigate to Preferences -> Java -> Build Path -> Classpath Variables and ensure the path for M2_REPO is ~/.m2/repository. If M2_REPO is not there, then to add it perform parts (b) through (f) within step (3) above.
  5. Next, we add the API baseline:
    1. Navigate to Eclipse Preferences -> Plug-in Development -> API Baselines. Now, based on your version of Eclipse, you have the following options:
      • If your version of Eclipse is 4.2 or above: You can tell Eclipse to ignore missing API baselines, by selecting ignore from the drop-down box found near the bottom-right of the window. Next click the button Ok. Now, Eclipse will ask if you want to do a full build, click No.
      • Otherwise (i.e., you have an older version of Eclipse):
        1. click Add Baseline .
        2. In the name field, enter "MCT_API_Baseline".
        3. click reset.
        4. click Ok.
  6. Refresh all projects in Eclipse:
    • Select all projects in the Project Explorer window, then on your keyboard press F5 to refresh all projects.
  7. Now we add a M2_REPO environment-variable to MCT's run configuration:
    1. Navigate to Run -> Run Configurations...
    2. In the window that appears, navigate to Java Applications -> MCT
    3. Click the tab 'Environment'
    4. Now we add the environment variable:
      1. click new
      2. click variables
      3. click edit variables
      4. click new
      5. Now, click browse and select the directory named repository, which is located at ~/.m2/repository
      6. In the name field, enter "M2_REPO" and click Ok
      7. (We are in the 'Preferences' window now) click Ok
      8. (We are in the 'Select Variable' window now) from the list, scroll down and choose "M2_REPO", then click Ok
      9. In the name field, enter "M2_REPO"
      10. Eclipse will ask you if you want to overwrite the previous M2_REPO variable that is in the Environment already, click Yes
  8. Now comes a choice whether you want to work with Java 6 or Java 7; MCT will work with either:
    • You want to build MCT with respect to Java 6: Then we need to set the the Compiler compliance level to 1.6:
      1. Navigate to Eclipse Preferences -> Java -> Compiler
      2. Set the Compiler compliance level to 1.6
      3. A full rebuild is requested by Eclipse, click Yes.
      4. Thank you, and congratulations: You are set up to build and run MCT in Eclipse!
    • You want to build MCT with respect to Java 7: Then we need to alter MCT's run configuration to build with respect to Java 7, (as well as set your Compiler compliance level to 1.7:
      1. Navigate to Run -> Run Configurations...
      2. In the window that appears, navigate to Java Applications -> MCT
      3. Click the tab 'JRE'
      4. Click the radio-button Alternate JRE and from the drop-down box, select Java SE 7
      5. To set your Compiler compliance level to 1.7, see
      6. Click Run to build-and-run MCT. Thank you, and congratulations: You are set up to build and run MCT in Eclipse!

For MySQL users only

First, we shall configure a MySQL database for Eclipse: here

Now, Change the run configuration (or debug) launch. The database connection parameters will need to be set. The easiest way to do this is to add the following to the VM arguments of the launch configuration (the bold sections will need to be changed to reflect how the database is configured, will need to be modified depending on whether derby or mysql are being used).

 -Dmct.database_connectionUrl=**jdbc:mysql://localhost:3306/**   
 -Dmct.database_name=**dbname**   
 -Dmct.database_userName=**dbuser**   
 -Dmct.database_password=**dbpassword**     

Troubleshooting

  1. Upon completing step (8) in Building and Running MCT in Eclipse if you receive in the Eclipse Console:
    java.lang.RuntimeException: Error starting bundle reference:file: .../mct/subscriptionManager/bin/
    (where '...'' is your path to your copy of MCT) This occurs because your compiler compliance level is set at 1.7 yet you are building MCT with respect to 1.6. To change the compiler compliance level, refer above to step (8).
  2. Eclipse is giving cannot be resolved to a type errors. Sometimes Eclipse seems to lose track of what has and hasn't been built. In particular, this seems to happen following a Maven build (or the first change thereafter) or a git pull. Cleaning & building (Project > Clean > Clean all projects) should resolve this issue.
  3. Upon building and running MCT, nothing is happening, then (eventually) you get
    [ERROR] unable to obtain persistence provider (Activator.java:47)
    You have an instance of MCT already running. Close it and re-build MCT.
  4. A rare-one: If you have errors with the manifest file in the mctcore project, try the steps in this section. The problem seems to be with eclipse, but here is a workaround:
    1. Use the cut function (or delete) to temporarily remove the Bundle-ClassPath (in mctcore/META-INF/MANIFEST.MF), save the file.
    2. Launch the properties editor on the mctcore project and check the checkbox next to the mysql connector jar file in the Java Build Path -> Order and Export tab) to export the jar.
    3. Rebuild all the project
    4. Revert the steps that were done in 1 and 2 above (revert the classpath and remove the export checkbox).
Something went wrong with that request. Please try again.