Issue
I'm trying to switch our legacy multi-modules project to Java-11, but tycho complaints on missing dependencies in my pom file, I added JDK version as 11. Here is part of pom
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<jdk-version>11</jdk-version>
<!-- Plugins tycho version -->
<tycho.version>1.7.0</tycho.version>
...
</properties>
<build>
...
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<source>${jdk-version}</source>
<target>${jdk-version}</target>
</configuration>
</plugin>
...
</build>
And here is my META-INF/MANIFEST.MF file
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Meta-Persistence: META-INF/openjpa_persistence_product.xml
Bundle-Name: JPA
Bundle-SymbolicName: com.XXX.jpa
Bundle-Version: 2.1.2
Bundle-Vendor: XXX
Bundle-RequiredExecutionEnvironment: JavaSE-11
Eclipse-ExtensibleAPI: true
Import-Package: com.XXX.config,
com.XXX.core,
com.XXX.core.util.logging,
com.XXX.sql,
javax.persistence,
javax.persistence.criteria,
javax.persistence.metamodel,
org.apache.openjpa.persistence,
org.apache.openjpa.util,
org.osgi.framework,
org.osgi.service.component,
org.osgi.service.jdbc,
org.osgi.service.jndi,
org.osgi.service.jpa,
org.slf4j
Export-Package: com.XXX.jpa,
com.XXX.jpa.concurrent,
com.XXX.jpa.util
Service-Component: OSGI-INF/*.xml
Bundle-ActivationPolicy: lazy
After executed mvn clean install I received
ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: com.XXX.jpa 2.1.2
[ERROR] Missing requirement: org.apache.openjpa 3.0.0 requires 'java.package; javax.rmi 0.0.0' but it could not be found
[ERROR] Cannot satisfy dependency: com.XXX.jpa 2.1.2 depends on: java.package; org.apache.openjpa.persistence 0.0.0
What I tried
- add version to org.apache.openjpa.persistence, org.apache.openjpa.util in MANIFEST.MF
- add javax.rmi into Import-Package section of MANIFEST.MF
But result was always the same - tycho complaints on javax.rmi package
UPDATE Hi @howlger! Thanks for your help, but now I received another problem
- I create bunlde for javax.rmi
<parent>
<groupId>com.XXX</groupId>
<artifactId>bundle.platform</artifactId>
<version>2.1.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- This bundle was added because in Java-11 javax.rmi package was removed from the standard library -->
<groupId>com.XXX</groupId>
<artifactId>com.XXX.javax.rmi</artifactId>
<version>1.0.6.Final</version>
<packaging>bundle</packaging>
<name>Java RMI API Bundle</name>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.rmi</groupId>
<artifactId>jboss-rmi-api_1.0_spec</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
*;version="${project.version}"
</Export-Package>
<Import-Package>
*
</Import-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
<Bundle-SymbolicName>
${project.artifactId}
</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
</plugins>
</build>
and deployed to our artifactory, but unfortunately can't add this bundle to p2 feature
I added it as a dependency to main pom file which creates p2 repo as
<dependencies>
<!-- com.XXX.javax.rmi -->
<dependency>
<groupId>org.jboss.spec.javax.rmi</groupId>
<artifactId>jboss-rmi-api_1.0_spec</artifactId>
<version>${javax.rmi.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.rmi</groupId>
<artifactId>jboss-rmi-api_1.0_spec</artifactId>
<version>${javax.rmi.version}</version>
<classifier>sources</classifier>
</dependency>
</dependencies>
But when I'm trying to add that bundle to platform feature as a plugin
<plugin
id="com.XXX.javax.rmi"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
I received:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: com.XXX.repository 2.1.2
[ERROR] Missing requirement: com.XXX.bundle.platform.feature.feature.group 2.1.2 requires 'org.eclipse.equinox.p2.iu; com.navteq.javax.rmi 0.0.0' but it could not be found
[ERROR] Cannot satisfy dependency: com.navteq.phoenix.repository 2.1.2 depends on: org.eclipse.equinox.p2.iu; com.navteq.phoenix.bundle.platform.feature.feature.group [2.1.2,2.1.3)
[ERROR]
What I do incorrect?
UPDATE2 There were 2 main problem in this issue
- Incorrect dependency in main pom file which creates p2 repo - it should have the same groupId, artifactId, version as the ones in pom which creates bandle
<dependencies>
<!-- com.XXX.javax.rmi -->
<dependency>
<groupId>com.XXX</groupId>
<artifactId>com.XXX.javax.rmi</artifactId>
<version>1.0.6.Final</version>
</dependency>
</dependencies>
- The import of the sun.refelection should be added to pom file which created bundle
<configuration>
<instructions>
<Export-Package>
*;version="${project.version}"
</Export-Package>
<Import-Package>
sun.reflect;resolution:=optional
</Import-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
<Bundle-SymbolicName>
${project.artifactId}
</Bundle-SymbolicName>
</instructions>
</configuration>
Solution
The javax.rmi
package was contain in the system library (in Java 9 and 10 in the module java.corba
) until it was removed in Java 11 by JEP 320.
For Java 11 or higher you need to add a plugin/bundle containing the package javax.rmi
to your target platform since it is required by the org.apache.openjpa
plugin/bundle you have. Or maybe there is a newer version of org.apache.openjpa
that contains the javax.rmi
package or does not require it anymore.
Answered By - howlger
Answer Checked By - David Marino (JavaFixing Volunteer)