eclipsegwtosgi

GWT plugin fails to load in Eclipse 2022-03 with JDK 11 or 17 because of OSGI BundleException


  1. Downloaded Eclipse: eclipse-java-2022-03-R-linux-gtk-x86_64.tar.gz
  2. Installed GWT from this update site: http://storage.googleapis.com/gwt-eclipse-plugin/v3/release/
  3. Tried various Java version (OpenJDK 11 and 17 from the repositories and downloaded from adoptium.net)
  4. Always got the same problem:
org.osgi.framework.BundleException: Could not resolve module: com.gwtplugins.gdt.eclipse.core [600]
  Unresolved requirement: Require-Bundle: com.gwtplugins.gdt.eclipse.platform
    -> Bundle-SymbolicName: com.gwtplugins.gdt.eclipse.platform; bundle-version="3.0.0.201710131939"; singleton:="true"
       com.gwtplugins.gdt.eclipse.platform [602]
         No resolution report for the bundle.  Bundle was not resolved because of a uses constraint violation.
  org.apache.felix.resolver.reason.ReasonException: Uses constraint violation. Unable to resolve resource com.gwtplugins.gdt.eclipse.platform [osgi.identity; type="osgi.bundle"; version:Version="3.0.0.201710131939"; osgi.identity="com.gwtplugins.gdt.eclipse.platform"; singleton:="true"] because it is exposed to package 'javax.servlet' from resources javax.servlet [osgi.identity; type="osgi.bundle"; version:Version="3.0.0.v201112011016"; osgi.identity="javax.servlet"] and jakarta.servlet-api [osgi.identity; type="osgi.bundle"; version:Version="4.0.0"; osgi.identity="jakarta.servlet-api"] via two dependency chains.

Chain 1:
  com.gwtplugins.gdt.eclipse.platform [osgi.identity; type="osgi.bundle"; version:Version="3.0.0.201710131939"; osgi.identity="com.gwtplugins.gdt.eclipse.platform"; singleton:="true"]
    require: (osgi.wiring.bundle=javax.servlet)
     |
    provide: osgi.wiring.bundle: javax.servlet
  javax.servlet [osgi.identity; type="osgi.bundle"; version:Version="3.0.0.v201112011016"; osgi.identity="javax.servlet"]

Chain 2:
  com.gwtplugins.gdt.eclipse.platform [osgi.identity; type="osgi.bundle"; version:Version="3.0.0.201710131939"; osgi.identity="com.gwtplugins.gdt.eclipse.platform"; singleton:="true"]
    require: (osgi.wiring.bundle=org.eclipse.jetty.servlet)
     |
    provide: osgi.wiring.bundle; bundle-version:Version="10.0.6"; osgi.wiring.bundle="org.eclipse.jetty.servlet"
  org.eclipse.jetty.servlet [osgi.identity; type="osgi.bundle"; version:Version="10.0.6"; osgi.identity="org.eclipse.jetty.servlet"]
    import: (&(osgi.wiring.package=javax.servlet)(&(version>=4.0.0)(!(version>=5.0.0))))
     |
    export: osgi.wiring.package: javax.servlet
  jakarta.servlet-api [osgi.identity; type="osgi.bundle"; version:Version="4.0.0"; osgi.identity="jakarta.servlet-api"]
    at org.eclipse.osgi.container.Module.start(Module.java:463)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)

My system as Eclipse describes it:

eclipse.buildId=4.23.0.I20220308-0310
java.version=17.0.3
java.vendor=Private Build
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product -data XXXXXXXXX

uname -a: Linux mycomputername #25~20.04.2tux1 SMP Tue Apr 12 10:34:50 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Linux: Ubuntu 20.04.4 LTS with "Budgie" desktop

I also tried another Eclipse version, but with the same results. (eclipse-SDK-4.23-linux-gtk-x86_64.tar.gz)

I found other BundleException problems, but only one for GWT, and it had no answer. And the other problems are not applicable to this problem. They were caused by the application creator, but I am not the creator of GWT and others use it without problems.

EDIT 2022.05.01:

I found no solution, but weird workarounds: If I use an Eclipse download without the "Eclipse Java Web Developer Tools" and use a ".p2f" file with an old Eclipse Update Site to install an old version of the "Eclipse Java Web Developer Tools" from there, then GWT works.

The problem is related to the javax.servlet ".jar" file. If Eclipse decided to download javax.servlet_3.1.0.v201410161800.jar GWT works. But if Eclipse decides to use javax.servlet_3.0.0.v201112011016.jar instead, GWT does not work. The weird thing is: Newer version of Eclipse use the older version of that ".jar", older version of Eclipse use the newer version of that ".jar".

With an Eclipse from https://download.eclipse.org/eclipse/downloads/drops4/R-4.23-202203080310/, the following ".p2f" file results in a working GWT installation for me:

<?xml version='1.0' encoding='UTF-8'?>
<?p2f version='1.0.0'?>
<p2f version='1.0.0'>
  <ius size='3'>
    <iu id='org.eclipse.jst.web_ui.feature.feature.group' name='Eclipse Java Web Developer Tools' version='3.22.0.v202103200058'>
      <repositories size='1'>
        <repository location='https://download.eclipse.org/releases/2021-06'/>
      </repositories>
    </iu>
    <iu id='com.gwtplugins.eclipse.sdkbundle.gwt28.feature.feature.group' name='GWT 2.8.1 SDK' version='2.8.0.201710131939'>
      <repositories size='1'>
        <repository location='http://storage.googleapis.com/gwt-eclipse-plugin/v3/release'/>
      </repositories>
    </iu>
    <iu id='com.gwtplugins.eclipse.suite.v3.feature.feature.group' name='GWT Eclipse Plugin' version='3.0.0.201710131939'>
      <repositories size='1'>
        <repository location='http://storage.googleapis.com/gwt-eclipse-plugin/v3/release'/>
      </repositories>
    </iu>
  </ius>
</p2f>

After that, uninstall the old "Eclipse Java Web Developer Tools" and install the current version from the current update site. GWT will remain working.

As I said, it's not a solution, just a weird workaround.


Solution

  • This appears to be a defect in the com.gwtplugins.gdt.eclipse.platform bundle which uses Require-Bundle to access the javax.servlet package when it should have used Import-Package.

    com.gwtplugins.gdt.eclipse.platform Require-Bundle's the javax.servlet bundle and the org.eclipse.jetty.servlet bundle which use different versions of the javax.servlet package and so the class loader cannot be properly constructed.