Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
devel:documentation:quickstart:dev:ide:eclipse [2019/06/14 09:22]
doischert [Metamodel generation]
devel:documentation:quickstart:dev:ide:eclipse [2022/07/12 13:25]
janatam [Implementing a ConnId connector]
Line 69: Line 69:
   * rpt-impl   * rpt-impl
  
-This setup has to be done for modules **core-api**, **core-impl**, and other optional modules, which uses criteria api (i. e., **acc**, **example**, **rpt-impl**, **var**).+This setup has to be done for modules **core-api**, **core-impl**, and other optional modules, which uses criteria api (i. e., **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''. **Note:** If you don't set metamodel generation, you will see Java problems like ''ExampleProduct_ cannot be resolved to a variable''.
Line 139: Line 139:
 </code> is probably caused by a bug in Flyway. In such case, go to Windows -> Preferences -> Installed JREs-> edit JRE and add to default VM arguments ''-Djava.util.Arrays.useLegacyMergeSort=true'' </code> is probably caused by a bug in Flyway. In such case, go to Windows -> Preferences -> Installed JREs-> edit JRE and add to default VM arguments ''-Djava.util.Arrays.useLegacyMergeSort=true''
  
 +Another possible issue may be an exception like this one:
 +<code>
 +java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/idm-app]]
 +Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/idm-app]]
 +    at org.apache.catalina.util.L
 +Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [eu.bcvsolutions.idm.IdmApplication]; nested exception is java.io.FileNotFoundException: class path resource [eu/bcvsolutions/idm/test/api/AbstractIntegrationTest.class] cannot be opened because it does not exist
 +    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:182)
 +</code>
 +
 +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:
 +
 +{{ :devel:documentation:quickstart:dev:ide:screenshot_from_2019-06-17_16-26-24.png?direct&600 |}}
 +
 +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:
 +{{ :devel:documentation:quickstart:dev:ide:screenshot_from_2019-06-20_09-55-36.png?direct&600 |}}
 ===== Update project after pulling new version ===== ===== Update project after pulling new version =====
  
Line 150: Line 167:
  
 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: 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:
 +
 <code> <code>
 Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationFilter': Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationFilter':
Line 155: Line 173:
 .... ....
 nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [eu.bcvsolutions.idm.ic.service.impl.DefaultIcConfigurationFacade]: Constructor threw exception; nested exception is java.lang.NullPointerException nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [eu.bcvsolutions.idm.ic.service.impl.DefaultIcConfigurationFacade]: Constructor threw exception; nested exception is java.lang.NullPointerException
 +
 </code> </code>
  
 If you encounter this exception and you want to use Debug server mode for implementing the connector (deploying without restarts), try the following steps: 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 ''<build><plugins>'':+ 
 +  * Open **pom.xml**  of the connector and add inside the tags ''<build><plugins>'': 
 <code xml> <code xml>
- <plugin> +    <plugin> 
- <groupId>org.apache.maven.plugins</groupId> +        <groupId>org.apache.maven.plugins</groupId> 
- <artifactId>maven-jar-plugin</artifactId> +        <artifactId>maven-jar-plugin</artifactId> 
- <configuration> +        <configuration> 
- <archive> +            <archive> 
- <addMavenDescriptor>false</addMavenDescriptor> +                <addMavenDescriptor>false</addMavenDescriptor> 
- <manifestEntries> +                <manifestEntries> 
- <ConnectorBundle-FrameworkVersion>${connid.version}</ConnectorBundle-FrameworkVersion> +                    <ConnectorBundle-FrameworkVersion>${connid.version}</ConnectorBundle-FrameworkVersion> 
- <ConnectorBundle-Name>${project.artifactId}</ConnectorBundle-Name> +                    <ConnectorBundle-Name>${project.artifactId}</ConnectorBundle-Name> 
- <ConnectorBundle-Version>${project.version}</ConnectorBundle-Version> +                    <ConnectorBundle-Version>${project.version}</ConnectorBundle-Version> 
- </manifestEntries> +                </manifestEntries> 
- </archive> +            </archive> 
- </configuration> +        </configuration> 
- </plugin>+    </plugin> 
 </code> </code>
-  * Right-click on the project with the connector and run Maven -> Update Project+ 
 +  * Right-click on the project with the connector and run Maven → Update Project
   * Right-click on the Tomcat server and run Clean or Publish   * 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, e.g.: ''/home/user/bin/apache-tomcat-8.0.36/wtpwebapps/idm-app/WEB-INF/lib/'') and remove the folder ''META-INF/maven/'' from the JAR containing your connector:+  * Go to the deployments folder of the Tomcat server (this depends on your installation, e.g.: ''/home/user/bin/apache-tomcat-8.0.36/wtpwebapps/idm-app/WEB-INF/lib/'') and remove the folder ''META-INF/maven/''  from the JAR containing your connector: 
 <code bash> <code bash>
 cd /home/user/bin/apache-tomcat-8.0.36/wtpwebapps/idm-app/WEB-INF/lib/ cd /home/user/bin/apache-tomcat-8.0.36/wtpwebapps/idm-app/WEB-INF/lib/
Line 187: Line 211:
 deleting: META-INF/maven/eu.bcvsolutions.idm.connectors.csv/csv-connector/pom.properties deleting: META-INF/maven/eu.bcvsolutions.idm.connectors.csv/csv-connector/pom.properties
 deleting: META-INF/maven/eu.bcvsolutions.idm.connectors.csv/csv-connector/pom.xml deleting: META-INF/maven/eu.bcvsolutions.idm.connectors.csv/csv-connector/pom.xml
 +
 </code> </code>
-  * Check that the file ''META-INF/MANIFEST.MF'' is first or second in the JAR file:+ 
 +  * Check that the file ''META-INF/MANIFEST.MF''  is first or second in the JAR file: 
 <code bash> <code bash>
 jar -tf csv-connector-1.0.0.jar jar -tf csv-connector-1.0.0.jar
- +
 META-INF/ META-INF/
 META-INF/MANIFEST.MF META-INF/MANIFEST.MF
 ... ...
 +
 </code> </code>
 +
   * 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.)   * 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 ** **Explanation & further improvements **
  
-The problem is in fact caused by Eclipse Maven plugin, which skips the standard ''assembly'' Maven goal and doesn't put the ''META-INF/MANIFEST.MF'' at the beginning of the generated JAR package. CzechIdM loads all available ConnId connectors during initialization. ConnId tries to read the manifest of all connectors, because there is information about the supported version of ConnId framework. However, reading of manifests assumes that the manifest is first or second file of the JAR archive (this is assumed in Oracle JDK). If the manifest is not at the beginning, ConnId fails to read it with NullPointerException, so it doesn't load the connector and so CzechIdM fails to start.+The problem is in fact caused by Eclipse Maven plugin, which skips the standard ''assembly''  Maven goal and doesn't put the ''META-INF/MANIFEST.MF''  at the beginning of the generated JAR package. CzechIdM loads all available ConnId connectors during initialization. ConnId tries to read the manifest of all connectors, because there is information about the supported version of ConnId framework. However, reading of manifests assumes that the manifest is first or second file of the JAR archive (this is assumed in Oracle JDK). If the manifest is not at the beginning, ConnId fails to read it with NullPointerException, so it doesn't load the connector and so CzechIdM fails to start.
  
-The steps above are a workaround for these problems. The configuration of ''maven-jar-plugin'' ensures that the MANIFEST.MF generated during the ''jar'' goal contains additional properties for the ConnId framework (connector name, version, framework version), which is in standard Maven build added during the ''assembly'' goal. But I found no way to enforce the correct order of the files in JAR. Using existing MANIFEST.MF (POM property ''manifestFile'') didn't help. Removing the folder ''META-INF/maven/'' from the JAR couldn't be done in POM (''addMavenDescriptor=false'' seems to have no effect in Eclipse, ''maven-shade-plugin'' is not started in Eclipse build). So in the end, I remove it from the deployed JAR. Note that the folder ''META-INF/maven/'' will be added again during hot deploy, but since the connectors are already initialized, it's not a problem. +The steps above are a workaround for these problems. The configuration of ''maven-jar-plugin''  ensures that the MANIFEST.MF generated during the ''jar''  goal contains additional properties for the ConnId framework (connector name, version, framework version), which is in standard Maven build added during the ''assembly''  goal. But I found no way to enforce the correct order of the files in JAR. Using existing MANIFEST.MF (POM property ''manifestFile'') didn't help. Removing the folder ''META-INF/maven/''  from the JAR couldn't be done in POM (''addMavenDescriptor=false''  seems to have no effect in Eclipse, ''maven-shade-plugin''  is not started in Eclipse build). So in the end, I remove it from the deployed JAR. Note that the folder ''META-INF/maven/''  will be added again during hot deploy, but since the connectors are already initialized, it's not a problem.
  
 Of course, any improvements are welcome. Of course, any improvements are welcome.
  
-By standard Maven build I mean running ''mvn clean install -Dlicense.skip=true'' from the command line.+By standard Maven build I mean running ''mvn clean install -Dlicense.skip=true''  from the command line. 
 + 
 + 
 +===== Stucked Eclipse settings ===== 
 + 
 +If the error you see during the build is not one of frequently known, you can try deleting ".settings" folder for concrete module.  
 +Best way to restart module settings is to delete problematic module, then do Project -> clean and then delete the ".settings" folder and then try to import module into Eclipse again. You can try deleting other Eclipse folders starting with dot to be sure that build for this module will be clear. 
  • by koulaj