Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
devel:documentation:quickstart:dev:ide:eclipse [2018/09/18 07:00] apeterova [Implementing a ConnId connector] |
devel:documentation:quickstart:dev:ide:eclipse [2019/07/02 11:05] doischert [Metamodel generation] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Eclipse ====== | ||
+ | {{tag> IDE}} | ||
+ | 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: | ||
+ | <code bash> | ||
+ | cd / | ||
+ | export JAVA_HOME=/ | ||
+ | ./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: | ||
+ | |||
+ | |||
+ | |||
+ | ====== 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. < | ||
+ | |||
+ | In the " | ||
+ | |||
+ | * 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 " | ||
+ | Right click " | ||
+ | |||
+ | |||
+ | ====== Metamodel generation ====== | ||
+ | |||
+ | After creating the project, make sure following modules are available in explorer (with prefix " | ||
+ | |||
+ | * 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**, | ||
+ | |||
+ | **Note:** If you don't set metamodel generation, you will see Java problems like '' | ||
+ | |||
+ | * Go to Project -> Properties -> Java Compiler -> Annotation Processing -> check " | ||
+ | * Go to Project -> Properties -> Java Compiler -> Annotation Processing -> Factory path -> check " | ||
+ | |||
+ | If this solution didn't help and you still see the '' | ||
+ | |||
+ | ====== 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 " | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | Create new server: In the tab " | ||
+ | |||
+ | For „Tomcat installation directory“ select the path to the installed Tomcat directory. As " | ||
+ | |||
+ | Add idm-app as an application to Tomcat: Right-click on the Tomcat server, choose "Add and Remove" | ||
+ | |||
+ | Optionally set some other options for the server: Double-click on the Tomcat server, then | ||
+ | * in the section " | ||
+ | * in the section " | ||
+ | |||
+ | ====== 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 " | ||
+ | - Switch to the " | ||
+ | - Save changes in the Tomcat server configuration | ||
+ | - Start the Tomcat server in " | ||
+ | |||
+ | ====== Run unit & integration tests ====== | ||
+ | |||
+ | When you want to run unit tests, you must switch to Maven profile **test**. Otherwise some tests (especially those which use database connection) may fail. | ||
+ | |||
+ | Set the " | ||
+ | |||
+ | If you want to run only tests in some class: 1) open this class, 2) right click on the class name, 3) choose Run As -> JUnit Test. | ||
+ | |||
+ | ====== Common development & tips ====== | ||
+ | |||
+ | ===== Tomcat server fails to start ===== | ||
+ | |||
+ | If Tomcat server fails to start, try following: | ||
+ | * Check all [[tutorial: | ||
+ | * Check build errors - check that the tab Markers or Problems doesn' | ||
+ | * Try Clean/ | ||
+ | * Try restarting Eclipse. | ||
+ | |||
+ | The exception: | ||
+ | < | ||
+ | org.springframework.context.ApplicationContextException: | ||
+ | ...... very long stacktrace ....... | ||
+ | Error creating bean with name ' | ||
+ | </ | ||
+ | |||
+ | Another possible issue may be an exception like this one: | ||
+ | < | ||
+ | java.util.concurrent.ExecutionException: | ||
+ | Caused by: org.apache.catalina.LifecycleException: | ||
+ | at org.apache.catalina.util.L | ||
+ | Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: | ||
+ | at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java: | ||
+ | </ | ||
+ | |||
+ | If you see this, make sure that | ||
+ | * you have the project idm-core-test-api open | ||
+ | * in Properties of the idm-core-impl (or any problematic project), check Java Build Path and make sure that each test folder has the Output folder set to test-classes. See below: | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | If you have a problem in not being able to Add and Remove, try to open idm-app, look at Properties, Project Facets and check you have the correct version of Java: | ||
+ | {{ : | ||
+ | ===== Update project after pulling new version ===== | ||
+ | |||
+ | 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. | ||
+ | |||
+ | ===== Implementing a ConnId connector ===== | ||
+ | |||
+ | We came across problematic behavior of Eclipse when implementing a ConnId connector. If you develop the connector that is a dependency of CzechIdM and the same connector (in the same version) is opened in Eclipse, then Tomcat with CzechIdM may fail to start with the following exception: | ||
+ | < | ||
+ | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: | ||
+ | | ||
+ | .... | ||
+ | nested exception is org.springframework.beans.BeanInstantiationException: | ||
+ | </ | ||
+ | |||
+ | If you encounter this exception and you want to use Debug server mode for implementing the connector (deploying without restarts), try the following steps: | ||
+ | * Open **pom.xml** of the connector and add inside the tags ''< | ||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | * Right-click on the project with the connector and run Maven -> Update Project | ||
+ | * Right-click on the Tomcat server and run Clean or Publish | ||
+ | * Go to the deployments folder of the Tomcat server (this depends on your installation, | ||
+ | <code bash> | ||
+ | cd / | ||
+ | zip -d csv-connector-1.0.0.jar " | ||
+ | |||
+ | deleting: META-INF/ | ||
+ | deleting: META-INF/ | ||
+ | deleting: META-INF/ | ||
+ | deleting: META-INF/ | ||
+ | deleting: META-INF/ | ||
+ | </ | ||
+ | * Check that the file '' | ||
+ | <code bash> | ||
+ | jar -tf csv-connector-1.0.0.jar | ||
+ | |||
+ | META-INF/ | ||
+ | META-INF/ | ||
+ | ... | ||
+ | </ | ||
+ | * Now you can start Tomcat in the Debug mode. The server starts and your changes in the connector can be deployed without restarts (if you don't change methods etc.) | ||
+ | |||
+ | **Explanation & further improvements ** | ||
+ | |||
+ | The problem is in fact caused by Eclipse Maven plugin, which skips the standard '' | ||
+ | |||
+ | The steps above are a workaround for these problems. The configuration of '' | ||
+ | |||
+ | Of course, any improvements are welcome. | ||
+ | |||
+ | By standard Maven build I mean running '' |