How to use Java11 (Java10) with Eclipse Plugin? - eclipse

If I specify JavaSE-10 as minimum execution environment in my Eclipse plugin:
I get following errors when starting my plugin as Eclipse Application:
org.osgi.framework.BundleException: Could not resolve module: org.treez.core [597]
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=10))"
Unresolved requirement: Require-Bundle: org.treez.javafxd3; visibility:="reexport"
-> Bundle-SymbolicName: org.treez.javafxd3; bundle-version="1.0.0.qualifier"; singleton:="true"
org.treez.javafxd3 [586]
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=10))"
at org.eclipse.osgi.container.Module.start(Module.java:444)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1613)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
I checked that
Java10 is reverenced under Installed JREs
10 is selected as compliance level
I use Oxygen.3a Release (4.7.3a) Build id: 20180405-1200
=>Is this a bug in eclipse equinox?
=>What else can I check to resolve this issue?
If I remove JavaSE-10 from the minimum execution environment settings I am able to start the Eclipse Application and the plugin seems to work fine.
When I export the plugin I get following warning:
# 25.04.18, 12:25:40 MESZ
# Eclipse Compiler for Java(TM) v20180330-0919, 3.13.102, Copyright IBM Corp 2000, 2015. All rights reserved.
option -bootclasspath not supported at compliance level 9 and above
When I try to use the plugin after installing it from my update page, I get a ClassNotFoundException:
...
Caused by: java.lang.ClassNotFoundException: org.treez.views.tree.TreeViewPart cannot be found by org.treez.views_1.0.0.201804191641
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:564)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
... 114 more
If I use Java8 everything works fine.
Related questions:
Java 8 & Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))"
How to set up java 10 in Eclipse Oxygen?
How to add org.eclipse.swt (and other plugin dependencies) as an automatic Java9 module?

It looks like Eclipse OSGi does not support Java SE 10 yet. I downloaded the latest Eclipse Oxygen 4.7.3a and opened plugins/org.eclipse.osgi_3.12.100.v20180210-1608.jar. The last supported profile was JavaSE-9.
So, you have two choices here:
Wait until OSGi officially supports JavaSE-10 profile.
If you really want to write a plugin with Java 10 and you have control over the plugins folder (e.g. you develop an Eclipse RCP application), open the OSGI jar and add a new profile JavaSE-10. To do this, you can copy JavaSE-9.profile to JavaSE-10.profile and fix corresponding lines in the new file. Also, you must add a new line to profile.list.

Since OSGi 4.3, the most appropriate way to specify a minimum Java version is using the Required-Capability header, as in:
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=1.10))"
I have had success fixing the reported error by replacing all occurrences of Bundle-RequiredExecutionEnvironment with the above line. In PDE, you may get a warning on the manifest file, but it can be safely ignored. Product validation and product exports seems to work without issue.
The semantic of the BREE header required that an execution environnement descriptor be provided by the OSGi implementation for each specific release of the JRE. In Equinox, this used to be defined through ".profile" files; these profiles have been supported by Equinox up to JavaSE-9, but it has been announced that Equinox they would no longer provide profiles for newer releases of Java.
The Tycho community has handled this issue on their side by creating their own Java 10 profile, but it can't be used directly from PDE. The P2 community is considering copying Tycho's Java 10 profile, but this has been stalled for a long time. I'm not sure how P2 reacts at present when fed bundles that do not contains the BREE header.

What worked for me as a work around was to
Remove the required version entries from the manifest files and ignore the corresponding warnings
Activate the option "Use class files compiled in the workspace" in the export wizard:
(Therefore I assume that something goes wrong during the compilation step of the export wizard if that option is not applied.)
I used Java 11.0.1 and Eclipse SimRel 2018-09 (plus Java11 support plugin)

Related

Cannot add an eclipse plugin, the plugin won't show up inEclipse

I am trying to add an eclipse Elugin (http://www.cs.wm.edu/semeru/TopicXP/) to my eclipse. I followed the instructions (copied the jar file into the plugins folder), but the plugin won't appear at all.
I do not have the LDA option in the right click menu
I do not have anything under Window > Show View > ...
I don't even see the plugin under Installation Details > plug-ins
I am in the Project Explorer, and using Eclipse Kepler Service Release 2. I did also try Eclipse Luna, as well as Eclipse 3.5 (the version of Eclipse that is mentioned in the plugin page) but none of these worked.
I did check the manifest and I have all required bundles. I also added Java 1.7 to it, since my environment is 1.7.
I cannot think of any reason, the plugin won't show up at all. I assumed that if there are some comparability issues, I will at least see the plugin or some errors related to loading it, but I see nothing.
Ideas?
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: TopicXP
Bundle-SymbolicName: edu.wm.topicxp;singleton:=true
Bundle-Version: 0.2.4
Bundle-Activator: edu.wm.LDATopics.LDATopics
Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime,org.apache.luc
ene,org.eclipse.jface,org.eclipse.ui.ide,org.eclipse.ui.workbench
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7, J2SE-1.5
Bundle-ClassPath: .,lib/args4j-2.0.6.jar,lib/JGibbLDA.jar
Import-Package: org.eclipse.core.resources,org.eclipse.draw2d,org.ecli
pse.draw2d.geometry,org.eclipse.jdt.core,org.eclipse.jdt.core.dom,org
.eclipse.jdt.ui,org.eclipse.jface.text,org.eclipse.ui,org.eclipse.ui.
ide,org.eclipse.ui.texteditor
Old question, but this may help someone still. This sounds very similar to a problem I struggled with. It's likely that the plugin you are trying to load has unresolved dependencies, and Eclipse doesn't show you anything in that case. But you can find out if that's the problem, and what dependencies may be missing by using the OSGI console.
First, invoke Eclipse from command line and add '-console' option.
Then in the OSGI console, use 'install' command to try to load your plugin. For instance, if you have placed com.my.plugin in the plugins folder of your Eclipse installation:
osgi> install reference:file:plugins/com.my.plugin.jar
That will give you a bundle ID in the output. Use that with the 'diag' command to see any missing dependencies.

PDE headless build not building while IDE does (3rd parties uses directives unresolved)

We have a large OSGi project with some own bundles and hundreds of third parties bundles.
After some tweaking of dependencies, we were able to produce a valid Launch Configuration that runs correctly and a product/feature configuration that builds correctly (via IDE of Eclipse Luna) and generates a valid executable.
So far so good with IDE PDE build.
Now we want to run the build in the headless way. We have followed the tutorial for Eclipse Luna (http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Ftasks%2Fpde_feature_build.htm) and set-up a headless build environment. We use the same product/feature files as before but now we got unresolved uses directives and the build fails.
The environment looks sane, since we can build headless other (smaller) applications with no problems.
Digging in some of the problems, we have seen that some of them refers to OPTIONAL imports not resolved... To my understanding they should not complain.
Example:
[java] C:\Program Files\eclipse_Luna\plugins\org.eclipse.pde.build_3.9.0.v20140415-2029\scripts\genericTargets.xml:
111: Processing inclusion from feature snapp.feature: Bundle org.apache.servicemix.bundles.jaxb-impl_2.2.1.1_2 failed to
resolve.:
[java] Package uses conflict: Import-Package: javax.xml.bind; version="[2.2.0,3.0.0)"
[java] Package uses conflict: Import-Package: javax.xml.bind.attachment; version="[2.2.0,3.0.0)"
[java] Package uses conflict: Import-Package: javax.xml.bind.helpers; version="[2.2.0,3.0.0)"
[java] Unsatisfied import package org.jvnet.staxex_0.0.0.
Since we have thousands of third parties uses directives, of course we are not going to hack the manifest of all the involved bundles...
Why does the headless build is so picky about the uses directives? Is there any way to instruct headless PDE to skip this kind of checks?
Thank you in advance!

How to change Eclipse-Groovy plugin Groovy libraries?

I am using the newest version (2.8.0) of the Eclipse-Groovy plugin that ships with groovy-all-2.1.5.jar. I added Guice to my Groovy project, and when I go to run them from inside Eclipse I get the following error in the console output:
Caught: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at net.me.myapp.utils.restclient.RestClient.<init>(RestClient.groovy:57)
at net.me.myapp.inject.UserServiceClientModule.configure(UserServiceClientModule.groovy:34)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at net.me.myapp.UserServiceClient.<init>(UserServiceClient.groovy:37)
at net.me.myapp.UserServiceClient.main(UserServiceClient.groovy:45)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
... 12 more
According to this answer it's because ShortTypeHandling wasn't added until 2.3.x. So I would now like to attach groovy-all-2.3.3.jar to my Eclipse project's classpath.
The problem is that I don't seem to have edit permissions to change what library the Groovy Libraries library uses under the hood. And when I manually add the 2.3.3 JAR to my build path, I get the following error:
Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.1.5 and you are trying to load version 2.3.3
What are my options?
Groovy-eclipse versions have its own compilers and are "locked" to them. You may change the versions to whatever is listed under Window > Preferences > Groovy > Compilers, but, AFAIK, you can't change to an arbitrary version of the compiler by simply changing the groovy-all jar in the guts of the plugin dir.
You can install new compiler versions using the update site or eclipse marketplace
Update: install additional compiler versions through Help > Install new Software, select Groovy update site and expand the Extra Groovy Compilers session:
Note i'm using snapshot update site, because i like to live dangerously.

e(fx)clipse 0.9.0 on Kepler with Java 7

is it possible to run the e(fx)clipse sample application on Kepler & Java7 at all ?
I took the steps, descripted in tutorial 4 to integrate the target definition(s)
https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial4
I tried the all-in-one-eclipse as well as upgrading a common kepler-eclipse with update-site http://download.eclipse.org/efxclipse/updates-released/0.9.0/site
However, the Sample Project JavaFX/Samples/e4 Media Application can not be compiled.
With Target Definition "RCP 3x Platform", all! application dependencies can not be resolved
With Target Definition "Target Platform Feature" a warning comes up, that the target version is newer than my current Eclipse installation. There are no comile errors anymore, but running the app I will get a lot of runtime errors like:
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Did anybody get the sample "e4 Media Application" working ?
My Eclipse: Kepler Service Release 2
My Java: JDK 7u40
============== EDIT ==============
Got it working, thanks to Tom!
Install fresh new Eclipse: http:// www.eclipse.org/downloads/packages/eclipse-rcp-and-rap-developers/keplersr2
Install Xtext 2.5.0, Update-Site: http:// download.eclipse.org/modeling/tmf/xtext/updates/composite/releases
Install e(fx)clipse, Update-Site: http:// download.eclipse.org/efxclipse/updates-released/0.9.0/site
Add new Target Platform, Update-Site: http:// download.eclipse.org/efxclipse/runtime-released/0.9.0/site
Select FX Target -> Target Platform Feature
The nightly runtime site already requires Java8 (see announcement on e(fx)clipse newsrpoup!)
If you want to run it on Java7 you need to use http://download.eclipse.org/efxclipse/runtime-released/0.9.0/Site for the target platform

Weird missing constraint with Logback under Eclipse

I have a feature-based launch configuration for an Eclipse RCP product. The feature includes ch.qos.logback.classic, ch.qos.logback.core 0.9.29, and org.slf4j.api 1.6.1. "Validate plugins" shows this error:
Could not find matching capability for Require-Capability: generic; filter="(&(generic=org.slf4j.impl.StaticLoggerBinder)(&(version>=1.6.0)(!(version>=1.7.0))))"
even though ch.qos.logback.classic exports org.slf4j.impl 1.6.1 and I can see StaticLoggerBinder.class in the .jar file. What might the problem be?
This is a guess: the "Require-Capability" is an OSGi 4.3 feature that corresponds to a "Provide-Capability". Logback doesn't have any such manifest header.
https://github.com/ceki/logback/blob/master/logback-classic/pom.xml#L339