• Download
  • Getting Started
  • Members
  • Projects
  • Bugzilla – Bug 392752 java.lang.UnsupportedOperationException at com.google.common.collect.ImmutableMap.put(ImmutableMap.java:278) Last modified: 2017-03-13 03:19:57 EDT
    I've migrated from Xtext 2.1.1 to Xtext 2.3.1 and get an exception when running my generator (which is based on xtend2) with a mwe2 workflow:
         [echo] Starting generation process...
         [java] 2012-10-24 15:13:27,403 [main] ERROR org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher - com/google/inject/internal/Maps
         [java] java.lang.NoClassDefFoundError: com/google/inject/internal/Maps
         [java] 	at org.eclipse.emf.mwe2.language.scoping.InjectableFeatureLookup.getInjectableFeatures(InjectableFeatureLookup.java:29)
         [java] 	at org.eclipse.emf.mwe2.language.scoping.Mwe2ScopeProvider.createComponentFeaturesScope(Mwe2ScopeProvider.java:132)
         [java] 	at org.eclipse.emf.mwe2.language.scoping.Mwe2ScopeProvider.scope_Assignment_feature(Mwe2ScopeProvider.java:60)
         [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         [java] 	at java.lang.reflect.Method.invoke(Method.java:597)
         [java] 	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
         [java] 	at org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.polymorphicFindScopeForReferenceName(AbstractDeclarativeScopeProvider.java:150)
         [java] 	at org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.getScope(AbstractDeclarativeScopeProvider.java:98)
         [java] 	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getScope(DefaultLinkingService.java:59)
         [java] 	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:119)
         [java] 	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:179)
         [java] 	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:219)
         [java] 	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:203)
         [java] 	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:263)
    Looks like it's the same problem reported here:
    http://www.eclipse.org/forums/index.php?t=msg&th=262950/
    I guess it's a jar dependency issue with google guice and mwe2...
    Regards
    Serano
    The problem seems to be in the org.eclipse.xtext.generator.GeneratorComponent class.
    public class GeneratorComponent implements IWorkflowComponent {
         * @since 2.3
         protected Map<String, OutputConfiguration> getOutputConfigurations() {
               IOutputConfigurationProvider outputConfigurationProvider = injector
                         .getInstance(IOutputConfigurationProvider.class);
               Set<OutputConfiguration> configurations = outputConfigurationProvider.getOutputConfigurations();
    // bug ==> instanciates a SingletonImmutableMap
               return uniqueIndex(configurations, new Function<OutputConfiguration, String>() {
                    public String apply(OutputConfiguration from) {
                         return from.getName();
    As a workaround sub-class the GeneratorComponent and override the method as follows:
    	@Override
    	protected Map<String, OutputConfiguration> getOutputConfigurations() {
    		IOutputConfigurationProvider outputConfigurationProvider =  getInjector().getInstance(IOutputConfigurationProvider.class);
    		Set<OutputConfiguration> configurations = outputConfigurationProvider.getOutputConfigurations();
    			return newLinkedHashMap(uniqueIndex(configurations, new Function<OutputConfiguration, String>() {
    				public String apply(OutputConfiguration from) {
    				return from.getName();
    Regards
    Serano
    the problem here was the I still had in the project old mwe2 jars.
    After I removed the old jars the mwe2 workflow of my generator ended with a new issue:
         [java] 2012-10-25 09:54:51,973 [main] ERROR org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow com.csg.cs.tools.mdgen.icm.generator.wf.IcmDslGenerator: null
         [java] java.lang.RuntimeException: Problems running workflow com.csg.cs.tools.mdgen.icm.generator.wf.IcmDslGenerator: null
         [java]     at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
         [java]     at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
         [java]     at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
         [java]     at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
         [java]     at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
         [java] Caused by: java.lang.UnsupportedOperationException
         [java]     at com.google.common.collect.ImmutableMap.put(ImmutableMap.java:278)
         [java]     at org.eclipse.xtext.generator.AbstractFileSystemAccess.setOutputPath(AbstractFileSystemAccess.java:64)
         [java]     at org.eclipse.xtext.generator.GeneratorComponent.getConfiguredFileSystemAccess(GeneratorComponent.java:135)
         [java]     at com.csg.cs.tools.mdgen.icm.generator.wf.McpWorkflowComponent.invokePrivate(McpWorkflowComponent.java:51)
         [java]     at com.csg.cs.tools.mdgen.icm.generator.wf.McpWorkflowComponent.invoke(McpWorkflowComponent.java:43)
    see workaround in my other comment.
    (In reply to comment #0)
    > I've migrated from Xtext 2.1.1 to Xtext 2.3.1 and get an exception when
    > running my generator (which is based on xtend2) with a mwe2 workflow:    
    > [echo] Starting generation process...
         [java] 2012-10-24 15:13:27,403
    > [main] ERROR org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher -
    > com/google/inject/internal/Maps
         [java] java.lang.NoClassDefFoundError:
    > com/google/inject/internal/Maps
         [java] 	at
    > org.eclipse.emf.mwe2.language.scoping.InjectableFeatureLookup.
    > getInjectableFeatures(InjectableFeatureLookup.java:29)
         [java] 	at
    > org.eclipse.emf.mwe2.language.scoping.Mwe2ScopeProvider.
    > createComponentFeaturesScope(Mwe2ScopeProvider.java:132)
         [java] 	at
    > org.eclipse.emf.mwe2.language.scoping.Mwe2ScopeProvider.
    > scope_Assignment_feature(Mwe2ScopeProvider.java:60)
         [java] 	at
    > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         [java] 	at
    > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
         [java] 	at
    > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
    > java:25)
         [java] 	at java.lang.reflect.Method.invoke(Method.java:597)
    > [java] 	at
    > org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.
    > java:291)
         [java] 	at
    > org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.
    > polymorphicFindScopeForReferenceName(AbstractDeclarativeScopeProvider.java:
         [java] 	at
    > org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.
    > getScope(AbstractDeclarativeScopeProvider.java:98)
         [java] 	at
    > org.eclipse.xtext.linking.impl.DefaultLinkingService.
    > getScope(DefaultLinkingService.java:59)
         [java] 	at
    > org.eclipse.xtext.linking.impl.DefaultLinkingService.
    > getLinkedObjects(DefaultLinkingService.java:119)
         [java] 	at
    > org.eclipse.xtext.linking.lazy.LazyLinkingResource.
    > getEObject(LazyLinkingResource.java:179)
         [java] 	at
    > org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.
    > getEObject(ResourceSetImpl.java:219)
         [java] 	at
    > org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:203)
         [java]
    > at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:263)
    Looks
    > like it's the same problem reported here:
    > http://www.eclipse.org/forums/index.php?t=msg&th=262950/
    I guess it's a jar
    > dependency issue with google guice and mwe2...
    Regards
    Serano