gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Incompatible use of 2 versions of Guava in Eclipse 2023-06 leads to intermittent launch problem #3830

Closed AlexisDrogoul closed 1 year ago

AlexisDrogoul commented 1 year ago

Describe the bug When installing the "Eclipse IDE for Java and DSL Developers" version of Eclipse 2023-06, we end up with two versions of Guava in the plugins directory.

Image 2023-06-29 08-06-10

While this is fine in general in an OSGI world, it creates here a specific problem, which is described in this old Eclipse bug :

It seems to me that the problem is: Team TA ship a plugin PA built with Guava version GA. Team TB ship a plugin PB built with Guava version GB. An application uses both PA and PB. When some Guava object is passed between PA and PB, we hit a problem if that Guava class has had any method added or removed between GA ang GB. The PB class loader reports that the incoming GA is a bad class if the GB version has already been loaded. So even if PA works with GB and PB works with GA, the incompatible builds cause a run-time failure.

Output The issue manifests itself when launching GAMA and obtaining several ClassLoader violations that prevent to launch msi.gama.headless and other plugins, pointing out that two incompatible versions of specific classes (Multimap) of Guava were requested by the same plugin.

The problem is that it is intermittent: when reinstalling Eclipse (same version, same duplication of plugins), it didn't happen again. It is likely that the order in which the plugins are launched is the reason why.

Desktop (please complete the following information):

RoiArthurB commented 1 year ago

The headless part has to be re-written for GAMA 2. Did you find exactly what are the 2 eclipse's plugins depending on those different guava versions ? It's possible the problem can easily be fixed as GAMA Headless uses some deprecated parts.

Also, once you found the problematic plugin, we can open a ticket to Eclipse asking to bump the guava version and cherry-pick the updated package for the next release of GAMA 1,9.x :shrug:

RoiArthurB commented 1 year ago

This bug is pretty strange but happens only on Eclipse because of the module msi.gama.ext. The problem is that Eclipse (in the installation folder) provides both guava 30.1 and 31 and ext wildcard the plugin version (taking the newest, i.e v31). But every eclipse's components (at least the ones we're using) are all using the 30.1 version.

Therefore, a (very) dirty fix consists in simply removing by hand the jar ./plugins/org.eclipse.xtext_2.31.0.v20230529-0659.jar from the eclipse installed folder, and everything is working perfectly fine.

On a cleaner approach, the fix should be as simple as limiting the version of guava in msi.gama.ext (as done by xtext here : https://github.com/eclipse/xtext/commit/365246da97dbfb65495d80cb0b52e326cc00cd72 ), but it doesn't seem to be read by Eclipse and so the issue remains... :confused:

AlexisDrogoul commented 1 year ago

One thing we could explore is to transform msi.gama.ext into a proper plugin as it doesn't seem to have a plugin.xml file.

AlexisDrogoul commented 1 year ago

As a side note, the same two versions of Guava can be found in the plugins directory of the recently released Eclipse 2023-09.

plugins 2023-09-16 09-35-10

I will switch to this version (now that #3851 is normally solved) to continue working on GAMA 1.9.3, and I will report if it still causes trouble...

AlexisDrogoul commented 1 year ago

I could not reproduce the problem in Eclipse 2023-09. I dont know exactly what has been fixed on the Eclipse side, but the error has vanished. Can anyone verify this ?

hqnghi88 commented 1 year ago

@AlexisDrogoul can you provide your eclipse preference, i (may be Baptiste) have counter this kind of violation in loading these two version guava for configuration 2309 + 1.9.3 + 17.0.8.

AlexisDrogoul commented 1 year ago

Hi @hqnghi88 -- I had to modify my target platform each time (removing one of the two plugins). @leonsi7 had the same issue yesterday so we have to act now...

One thing we are considering is to switch to an oomph-based installer for the GAMA Dev Environment. See here: https://www.vogella.com/tutorials/Oomph/article.html -- distributing a configuration file that can be accessed through Oomph would be a great step forward !

This would effectively allow all developers to have the same preferences, plugins (JAutoDoc ?), Working Sets, projects, etc.. @lesquoyb seems interested and we are just wondering who is going to begin working on this ... @leonsi7 @RoiArthurB @hqnghi88 ... ?? 😄

RoiArthurB commented 1 year ago

Interestingly, while compiling GAMA on current latest commit ( c3e2cfd91 ) with maven, I have a single guava (com.google.guava_32.1.2.jre.jar), but I can't launch GAMA as I have the Multimap error without double guava occurence :

!SESSION 2023-09-22 16:14:16.916 -----------------------------------------------
eclipse.buildId=${build.id}
java.version=17.0.8.1
java.vendor=N/A
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64 -data @noDefault

!ENTRY org.eclipse.osgi 4 0 2023-09-22 16:14:17.462
!MESSAGE An error occurred while automatically activating bundle msi.gama.core (17).
!STACK 0
org.osgi.framework.BundleException: Exception in msi.gama.common.Activator.start() of bundle msi.gama.core.
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:839)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
    at org.eclipse.osgi.container.Module.doStart(Module.java:605)
    at org.eclipse.osgi.container.Module.start(Module.java:468)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
    at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
    at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:496)
    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:525)
    at msi.gama.application.workspace.WorkspacePreferences.isRememberWorkspace(WorkspacePreferences.java:69)
    at msi.gama.application.Application.checkWorkspace(Application.java:228)
    at org.eclipse.swt.widgets.Display.lambda$3(Display.java:5998)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:5960)
    at org.eclipse.swt.widgets.Display.syncCall(Display.java:5996)
    at msi.gama.application.Application.start(Application.java:139)
    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:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1432)
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Multimap
    at msi.gama.common.Activator.start(Activator.java:28)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810)
    ... 35 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Multimap cannot be found by msi.gama.core_1.9.3.202309220911
    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:525)
    ... 40 more
Root exception:
java.lang.NoClassDefFoundError: com/google/common/collect/Multimap
    at msi.gama.common.Activator.start(Activator.java:28)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
    at org.eclipse.osgi.container.Module.doStart(Module.java:605)
    at org.eclipse.osgi.container.Module.start(Module.java:468)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
    at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
    at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:496)
    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:525)
    at msi.gama.application.workspace.WorkspacePreferences.isRememberWorkspace(WorkspacePreferences.java:69)
    at msi.gama.application.Application.checkWorkspace(Application.java:228)
    at org.eclipse.swt.widgets.Display.lambda$3(Display.java:5998)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:5960)
    at org.eclipse.swt.widgets.Display.syncCall(Display.java:5996)
    at msi.gama.application.Application.start(Application.java:139)
    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:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1432)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Multimap cannot be found by msi.gama.core_1.9.3.202309220911
    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:525)
    ... 40 more

!ENTRY org.eclipse.osgi 4 0 2023-09-22 16:14:17.465
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError: msi/gama/common/preferences/GamaPreferenceStore
    at msi.gama.application.workspace.WorkspacePreferences.isRememberWorkspace(WorkspacePreferences.java:69)
    at msi.gama.application.Application.checkWorkspace(Application.java:228)
    at org.eclipse.swt.widgets.Display.lambda$3(Display.java:5998)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:5960)
    at org.eclipse.swt.widgets.Display.syncCall(Display.java:5996)
    at msi.gama.application.Application.start(Application.java:139)
    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:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1432)
Caused by: java.lang.ClassNotFoundException: An error occurred while automatically activating bundle msi.gama.core (17).
    at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:126)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397)
    at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:496)
    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:525)
    ... 20 more
Caused by: org.osgi.framework.BundleException: Exception in msi.gama.common.Activator.start() of bundle msi.gama.core.
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:839)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371)
    at org.eclipse.osgi.container.Module.doStart(Module.java:605)
    at org.eclipse.osgi.container.Module.start(Module.java:468)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513)
    at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
    ... 28 more
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Multimap
    at msi.gama.common.Activator.start(Activator.java:28)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818)
    at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810)
    ... 35 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Multimap cannot be found by msi.gama.core_1.9.3.202309220911
    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:525)
    ... 40 more
hqnghi88 commented 1 year ago

It used in many other plugins, i think you should keep "visibility:=reexport,"

AlexisDrogoul commented 1 year ago

I guess that this issue is resolved now, right, with the new dependency in msi.gama.ext ? Let's close it then. Feel free to reopen is something similar pops up.