7.7:dev:quickstart:ide:eclipse

Eclipse

Configuration quickstart for developing CzechIdM in Eclipse.

Install Eclipse

Download the last stable version of Eclipse from Eclipse download page. When running the installer, choose "IDE for Java EE Developers". It is advised to download Eclipse directly from download page, since when installing from distribution repositories via dnf or yum, you are not able to choose from distinct Eclipse editions.

If you installed Java separately from your system libraries, you should run Eclipse with the specified JDK:

cd /path/to/eclipse
export JAVA_HOME=/path/to/installed/jdk/
./eclipse

Next set the correct Java Runtime in Eclipse: Window → Preferences → Java → Installed JREs → button Add… → Standard VM - Next. In the following window, fill the "JRE home" with the path to JDK, then click Finish

Remove Eclipse pom.xml error - Plugin execution not covered by lifecycle configuration: org.bsc.maven:maven-processor-plugin:3.3.1:process (execution: process, phase: generate-sources) - go to WindowPreferencesMavenErrors/Warnings → set Plugins execution not covered by lifecycle configuration to warning.

Import project

Open Eclipse and choose to import project from existing Maven projects: File → Import → Maven – Existing Maven Projects → Next → Select root directory

Choose the location of your repository from file explorer, i.e. <path>/CzechIdM/Realization/backend.

In the "Projects" window, tick checkboxes for projects under core module and other modules. Do not import the "gui" module. Thus you should have following modules selected:

  • ic
  • acc
  • app
  • core-api
  • core-test-api
  • core-impl
  • aggregator
  • example
  • parent
  • vs
  • rpt
  • rpt-api
  • rpt-impl

Finish. Project should be imported.

Set the "dev" profile for developing (because it uses postgresql DB and module acc): Right click "idm-app" → Maven → Select Maven Profiles → check "dev"

Metamodel generation

After creating the project, make sure following modules are available in explorer (with prefix "idm-"):

  • acc
  • app
  • core-api
  • core-impl
  • core-test-api
  • example
  • ic
  • parent
  • rpt
  • rpt-api
  • rpt-impl

This setup has to be done for modules core-api, core-impl, and other optional modules, which uses criteria api (e.g. acc, example, rpt-impl).

Note: If you don't set metamodel generation, you will see Java problems like ExampleProduct_ cannot be resolved to a variable.

  • Go to Project → Properties → Java Compiler → Annotation Processing → check "Enable project specific settings" and fill "Generated source directory" = "target/metamodel"".
  • Go to Project → Properties → Java Compiler → Annotation Processing → Factory path → check "Enable project specific settings" and add external jar hibernate-jpamodelgen.jar (version 5.x.x). Artefact could be found in local maven repository or downloaded from any public maven repository.

Build the Project

After that you can build the projects from Eclipse by Project → Build Project or you can check "Build Automatically".

If you see some dependency errors try this approach:

Right-click the project "idm-aggregator" and choose "Run as" → "Maven install". The first build of the project will download necessary libraries to your local Maven repository (e.g. "forest" from Nexus repository).

If dependency errors still remain, for all projects: Right click on the project → Maven → Update Project… → click Select All → Click OK

Install Tomcat

Download Tomcat 8.0.* (tested version 8.0.36) from Apache website. Unzip it somewhere in your home directory.

Next we will install Tomcat as a Server to the Eclipse:

Show the tab "Servers" if it isn't visible yet: Window → Show View → Servers

Create new server: In the tab "Servers", right-click and choose New → Server → Apache → Tomcat v8.0 Server - Next →

For „Tomcat installation directory“ select the path to the installed Tomcat directory. As "JRE" choose installed JDK. Then Next → Next → Finish.

Add idm-app as an application to Tomcat: Right-click on the Tomcat server, choose "Add and Remove" and select "idm-app"

Optionally set some other options for the server: Double-click on the Tomcat server, then

  • in the section "Timeouts" increase the timeout for start to 240 s.
  • in the section "Server Options", uncheck "Modules auto reload by default".

Deploy changes without reloading

Small changes in code may be applied to the server without restarting the server or reloading modules (hot code replacement). This can be configured as follows:

  • Double-click on the Tomcat server, in the section "Publishing" choose the option "Automatically publish when resources change"
  • Switch to the "Modules" tab of the Tomcat server and choose the module "idm-app". Click the button "Edit…" and uncheck "Auto reloading enabled". After submitting you should see the value "Disabled" in the column "Auto Reload".
  • Save changes in the Tomcat server configuration
  • Start the Tomcat server in "DEBUG" mode.

Common development & tips

If Tomcat server fails to start, try following:

  • Check build errors - check that the tab Markers or Problems doesn't show any Java or Maven build error. (You can ignore XML validation problems.) If it does, try updating Maven project.
  • Try Clean/Publish actions on the Tomcat server.
  • Try restarting Eclipse.

When you pull new version of the project from Git and there were some changes including Maven dependencies (e.g. newer version of some artifact), you should update your project:

  • select all projects
  • right-click and choose Maven → Update Project

The IDE will update dependencies and rebuild the projects if necessary.