Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
devel:documentation:quickstart:dev:ide:eclipse [2018/11/07 12:44] apeterova [Run unit & integration tests] |
devel:documentation:quickstart:dev:ide:eclipse [2024/01/09 08:27] koulaj [Install Tomcat] |
||
---|---|---|---|
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" | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | ====== 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: | ||
+ | |||
+ | * 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" | ||
+ | |||
+ | ====== Install Tomcat ====== | ||
+ | |||
+ | Download Tomcat 9.0.* (tested version 9.0.80) 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 " | ||
+ | |||
+ | 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 common development tips | ||
+ | * Check build errors - check that the tab Markers or Problems doesn' | ||
+ | * Try Clean/ | ||
+ | * Try restarting Eclipse. | ||
+ | |||
+ | The exception: '' | ||
+ | |||
+ | In such case, go to Windows → Preferences → Installed JREs→ edit JRE and add to default VM arguments '' | ||
+ | |||
+ | Another possible issue may be an exception like this one: '' | ||
+ | |||
+ | 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 ** (should be 11) abd **Dynamic Web Module ** (3.1): {{ .: | ||
+ | |||
+ | ===== Maven build passes, but Eclipse shows errors ===== | ||
+ | |||
+ | It can happen that Maven builds the project fine, but eclipse Project -> Clean will throw an error, such as: | ||
+ | |||
+ | < | ||
+ | Failed to execute mojo org.apache.maven.plugins: | ||
+ | |||
+ | org.eclipse.core.runtime.CoreException: | ||
+ | at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java: | ||
+ | at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.lambda$0(MavenExecutionContext.java: | ||
+ | at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java: | ||
+ | at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java: | ||
+ | at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java: | ||
+ | at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java: | ||
+ | at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.lambda$2(MavenBuilderImpl.java: | ||
+ | |||
+ | </ | ||
+ | |||
+ | In that case, update the Maven project (right click project -> Maven -> Update Project. | ||
+ | |||
+ | ===== 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: '' | ||
+ | |||
+ | 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** | ||
+ | |||
+ | <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 '' | ||
+ | |||
+ | ===== Stucked Eclipse settings ===== | ||
+ | |||
+ | If the error you see during the build is not one of frequently known, you can try deleting " | ||
+ | |||
+ | ====== Troubleshooting - stuck Eclipse module build ====== | ||
+ | |||
+ | Sometimes, Eclipse stucks after pulling new version of an external (non-core) module. The module' | ||
+ | |||
+ | The following guide describes recovery from such situation for development environment on Windows. | ||
+ | |||
+ | Suppose that an external module [idm-extmod] is stuck. | ||
+ | |||
+ | - Eclipse menu: switch off Project → Build automatically | ||
+ | - End task Eclipse in Windows Task manager | ||
+ | - Start Eclipse | ||
+ | - Right-click on idm-app module → Maven → Update project → click " | ||
+ | - Right-click on [idm-extmod] → Delete → leave unchecked the " | ||
+ | - Go to '' | ||
+ | - Go to '' | ||
+ | - In Eclipse: File → Import → Existing Maven Project, select the [ModuleDir]/ | ||
+ | - Right-click on idm-app module → Properties → Deployment Assembly → Add, select the [idm-extmod] module | ||
+ | - Eclipse menu: switch on Project → Build automatically | ||
+ | - Right-click on idm-app module → Maven → Update project → click " | ||
+ | - Repeat step 8: Right-click on idm-app module → Properties → Deployment Assembly → Add, select the [idm-extmod] module | ||
+ | - Run the server | ||
+ | - Reconfigure the test/debug environment: | ||
+ | |||