Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Java 11 and javax.annotation(Java11 does not include javax.annotation anymore which results in runtime errors.)
Java 11 and javax.annotation [message #1858188] Tue, 21 March 2023 15:17 Go to next message
Maximilian Lutz is currently offline Maximilian LutzFriend
Messages: 2
Registered: March 2023
Junior Member
Eclipse Build:Id: 20220609-1112
Java: 11.0.14.1

Hi all,

our RCP OSGi Application does not run anymore after upgrading to Java 11. This is because Java 11 removed javax.annotation and this leads to the following Exception while running our application:

org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:414)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:330)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:481)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:495)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:213)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:573)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
	at *.application.Application.start(Application.java:534)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:140)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:403)
	... 23 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.8.200.v20220512-1957
	at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:541)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:536)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 25 more


The Eclipse Plugin for Dependency Injection "org.eclipse.e4.core.di" cannot find the javax.annotation package at runtime right after starting the application. The Application runs as mentioned in an OSGi Container. There are no unresolved requirements or something similar at Compile time, furthermore javax.annotation is present in the Build and in the target platform. See the Manifest of the org.eclipse.e4.core.di Bundle below:

 Automatic-Module-Name = org.eclipse.e4.core.di
 Build-Jdk-Spec = 11
 Bundle-ActivationPolicy = lazy
 Bundle-Localization = plugin
 Bundle-ManifestVersion = 2
 Bundle-Name = Eclipse Dependency Injection
 Bundle-RequiredExecutionEnvironment = JavaSE-11
 Bundle-SymbolicName = org.eclipse.e4.core.di
 Bundle-Vendor = Eclipse.org
 Bundle-Version = 1.8.200.v20220512-1957
 Created-By = Maven Archiver 3.5.2
 Eclipse-SourceReferences = scm:git:https://github.com/eclipse-platform/eclipse.platform.runtime.git;path="bundles/org.eclipse.e4.core.di";tag="I20220512-1800";commitId=ada015b6ae742e99f70411886c4f72f1a1fe1713
 Export-Package = org.eclipse.e4.core.di;version="1.7.0",org.eclipse.e4.core.di.suppliers;version="1.7.0",org.eclipse.e4.core.internal.di;x-friends:="org.eclipse.e4.core.contexts",org.eclipse.e4.core.internal.di.osgi;x-internal:=true,org.eclipse.e4.core.internal.di.shared;x-friends:="org.eclipse.e4.core.contexts,org.eclipse.e4.core.di.extensions.supplier"
 Import-Package = javax.inject;version="1.0.0",org.eclipse.osgi.framework.log;version="1.1.0",org.osgi.framework;version="1.8.0",org.osgi.util.tracker;version="1.5.1"
 Manifest-Version = 1.0
 Require-Bundle = org.eclipse.e4.core.di.annotations;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,javax.annotation;bundle-version="[1.3.5,2.0.0)"


This Bundle requires the javax.annotation package, but does not import it.

We wonder how can we add javax.annotation to the OSGi runtime so that it is available for the dependency injection plugin? Has anybody maybe already had a similar problem?

[Updated on: Thu, 23 March 2023 09:18]

Report message to a moderator

Re: Java 11 and javax.annotation [message #1858192 is a reply to message #1858188] Wed, 22 March 2023 07:47 Go to previous message
Maximilian Lutz is currently offline Maximilian LutzFriend
Messages: 2
Registered: March 2023
Junior Member
Maybe some additional Info:

We have another Application that is built the same way and that one somehow works. We cannot really figure out why. As I understood OSGi correctly, every plugin has its own classloader and it seems like that javax.annotation is not loaded within the scope of the org.eclipse.e4.core.di plugin. Furthermore in the OSGi runtime it is visible that a javax.annotation bundle is started and active, so it should be avaiable at runtime.

[Updated on: Wed, 22 March 2023 08:27]

Report message to a moderator

Previous Topic:Restore a workbenchpage with an external memento.xml without closing eclipse 3.1
Next Topic:Disabling the Inspection of Web Content in Apps
Goto Forum:
  


Current Time: Sat Jul 27 10:25:53 GMT 2024

Powered by FUDForum. Page generated in 0.02929 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top