7.3:dev:quickstart:ide:eclipse

Eclipse

Configuration quickstart for developing CzechIdM in Eclipse.

Install Java and Maven

Download Java 1.8 Oracle JDK (or OpenJDK), minor version at least 101 (it's necessary due to the certificate of Nexus repository, which uses Let's encrypt and its support was added in version 101). The guide was tested for jdk1.8.0_131.

Install Maven from your system packages, at least version 3.1 is required.

yum install maven
mvn -v

If you installed Java separately from your system libraries, you should set the correct Java home for Maven in the file ".mavenrc", which you will create in your home directory. You put there the full path to your JDK:

export JAVA_HOME=/path/to/installed/jdk/

This way Maven will always use this JDK.

Install Eclipse

Download the last stable version of Eclipse from Eclipse download page. When running the installator, 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.

Download the source code

Download CzechIdM source code from GitHub:

git clone https://github.com/bcvsolutions/CzechIdMng.git

The development is always done on the branch "develop", so don't forget to switch to this branch:

git checkout -b develop origin/develop

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

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

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

  • Go to Project → Properties → Java Compiler → Annotation Processing → check "Enable project specific settings" and fill target/metamodel as "Generated source directory".
  • 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.

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

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).

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 120 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.

Install PostgreSQL

CzechIdM in "dev" profile uses PostgreSQL as the repository. You have to install it at least in basic configuration:

Install necessary packages:

yum install postgresql postgresql-server postgresql-init

Fedora 25 packages:

dnf install postgresql-server postgresql-contrib

First run of the service:

systemctl start postgresql.service

If the following error occurs: "Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details." Try initializing the PostgreSQL first and start the database again:

postgresql-setup --initdb --unit postgresql

Set automatic start of the service when starting OS:

systemctl enable postgresql.service

Set the configuration file for the database to accept login and password (change METHOD from ident to md5)

vim /var/lib/pgsql/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local        all                   all                                                peer
# IPv4 local connections:
host         all                  all                127.0.0.1/32             md5
# IPv6 local connections:
host         all                  all                ::1/128                     md5

Restart the service to load the changes:

systemctl restart postgresql.service

Create the database:

su postgres -c psql postgres
CREATE USER idmadmin PASSWORD 'idmadmin';
CREATE DATABASE "bcv_idm_storage" WITH OWNER idmadmin ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' template template0;

Common development

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.