Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Loading EMF inside Maven Plugin
Loading EMF inside Maven Plugin [message #1709149] Thu, 24 September 2015 13:24 Go to next message
Rolando Amarillo is currently offline Rolando AmarilloFriend
Messages: 4
Registered: September 2015
Junior Member
Hi,

I'm developing a Sonar-Maven plugin and executing a transformation inside it with EMF code.

Here is my code to load the xmi:

Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
			Map<String, Object> m = reg.getExtensionToFactoryMap();
			m.put("xmi", new XMIResourceFactoryImpl());

			// Obtain a new resource set
			ResourceSet resSet = new ResourceSetImpl();

			// Get the resource
			Resource resource = resSet
					.getResource(
							URI.createURI("/simplifieddecisionmetrics/kdmResultSub.xmi"),
							true);
			Iterator<EObject> iter = resource.getAllContents();


As I described in this post, I'm getting this error:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project build-def
ault-product: null
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre
adedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
Caused by: org.apache.maven.plugin.MojoExecutionException
        at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionH
andling.java:41)
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBoo
tstraper.java:139)
        at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:132)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:208)
        ... 20 more
Caused by: java.lang.ExceptionInInitializerError
        at tools.sonarplugin.simplifieddecisionmetrics.IDEMetadataSensor.analyse
(IDEMetadataSensor.java:54)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.
java:59)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:5
1)
        at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseMode
PhaseExecutor.java:120)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanConta
iner.java:264)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.j
ava:235)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan
Container.java:230)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan
Container.java:228)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanCon
tainer.java:220)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.ja
va:135)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer
.java:158)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java
:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:87)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102
)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBoo
tstraper.java:135)
        ... 23 more
Caused by: java.lang.UnsupportedOperationException
        at org.eclipse.emf.ecore.impl.MinimalEObjectImpl.eBasicAdapters(MinimalE
ObjectImpl.java:295)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotificationReq
uired(BasicNotifierImpl.java:261)
        at org.eclipse.emf.ecore.impl.EFactoryImpl.basicSetEPackage(EFactoryImpl
.java:138)
        at org.eclipse.emf.ecore.impl.EFactoryImpl.eInverseAdd(EFactoryImpl.java
:714)
        at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseAdd(BasicEObjectI
mpl.java:1405)
        at org.eclipse.emf.ecore.impl.EPackageImpl.setEFactoryInstance(EPackageI
mpl.java:382)
        at org.eclipse.emf.ecore.impl.EPackageImpl.<init>(EPackageImpl.java:177)

        at subkdm.kdmObjects.impl.KdmObjectsPackageImpl.<init>(KdmObjectsPackage
Impl.java:310)
        at subkdm.kdmObjects.impl.KdmObjectsPackageImpl.init(KdmObjectsPackageIm
pl.java:336)
        at subkdm.kdmObjects.KdmObjectsPackage.<clinit>(KdmObjectsPackage.java:5
8)
        ... 57 more


I'm thinking it's a conflict between maven plugin execution and emf libraries.

I'm using:
org.eclipse.emf.ecore_2.10.2.v20150123-0348
org.eclipse.epsilon.emc.emf_1.2.0.201408251031

Rolando
Re: Loading EMF inside Maven Plugin [message #1709178 is a reply to message #1709149] Thu, 24 September 2015 15:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30353
Registered: July 2009
Senior Member
Rolando,

I can only imagine this happening if you have an older version of
org.eclipse.emf.common and a newer version of org.eclipse.emf.ecore.

The method
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotificationRequired()
is implemented like this:

public boolean eNotificationRequired()
{
return eBasicHasAdapters() && eDeliver();
}

Previously it was implemented like this:

BasicEList<Adapter> eAdapters = eBasicAdapters();
return eAdapters != null && eDeliver() && !eAdapters.isEmpty();

So it's clear you have an older (very old) implementation of
org.eclipse.emf.common on your classpath.

Likely you'll also want to be sure that
URI.createURI("/simplifieddecisionmetrics/kdmResultSub.xmi") creates a
file: URI with an absolute file system path.

On 24/09/2015 3:24 PM, Rolando Amarillo wrote:
> Hi,
>
> I'm developing a Sonar-Maven plugin and executing a transformation
> inside it with EMF code.
>
> Here is my code to load the xmi:
>
>
> Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
> Map<String, Object> m = reg.getExtensionToFactoryMap();
> m.put("xmi", new XMIResourceFactoryImpl());
>
> // Obtain a new resource set
> ResourceSet resSet = new ResourceSetImpl();
>
> // Get the resource
> Resource resource = resSet
> .getResource(
> URI.createURI("/simplifieddecisionmetrics/kdmResultSub.xmi"),
> true);
> Iterator<EObject> iter = resource.getAllContents();
>
>
> As I described in
> https://www.eclipse.org/forums/index.php/m/1709087/#msg_1709087 post,
> I'm getting this error:
>
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
> execute goal o
> rg.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project
> build-def
> ault-product: null
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
> java:216)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
> java:153)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
> java:145)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
> ct(LifecycleModuleBuilder.java:116)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
> ct(LifecycleModuleBuilder.java:80)
> at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre
> adedBuilder.build(SingleThreadedBuilder.java:51)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
> eStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
> cher.java:289)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
> a:229)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
> uncher.java:415)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
> 356)
> Caused by: org.apache.maven.plugin.MojoExecutionException
> at
> org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionH
> andling.java:41)
> at
> org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBoo
> tstraper.java:139)
> at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:132)
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
> BuildPluginManager.java:134)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
> java:208)
> ... 20 more
> Caused by: java.lang.ExceptionInInitializerError
> at
> tools.sonarplugin.simplifieddecisionmetrics.IDEMetadataSensor.analyse
> (IDEMetadataSensor.java:54)
> at
> org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.
> java:59)
> at
> org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:5
> 1)
> at
> org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseMode
> PhaseExecutor.java:120)
> at
> org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanConta
> iner.java:264)
> at
> org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
> ntainer.java:92)
> at
> org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
> java:77)
> at
> org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.j
> ava:235)
> at
> org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan
> Container.java:230)
> at
> org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan
> Container.java:228)
> at
> org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanCon
> tainer.java:220)
> at
> org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
> ntainer.java:92)
> at
> org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
> java:77)
> at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
> at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
> at
> org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.ja
> va:135)
> at
> org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
> ntainer.java:92)
> at
> org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
> java:77)
> at
> org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer
> java:158)
> at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
> at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
> at
> org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java
> :48)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
> java:87)
> at
> org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
> at
> org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
> at
> org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102
> )
> at org.sonar.runner.api.Runner.execute(Runner.java:100)
> at
> org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBoo
> tstraper.java:135)
> ... 23 more
> Caused by: java.lang.UnsupportedOperationException
> at
> org.eclipse.emf.ecore.impl.MinimalEObjectImpl.eBasicAdapters(MinimalE
> ObjectImpl.java:295)
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotificationReq
> uired(BasicNotifierImpl.java:261)
> at
> org.eclipse.emf.ecore.impl.EFactoryImpl.basicSetEPackage(EFactoryImpl
> java:138)
> at
> org.eclipse.emf.ecore.impl.EFactoryImpl.eInverseAdd(EFactoryImpl.java
> :714)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseAdd(BasicEObjectI
> mpl.java:1405)
> at
> org.eclipse.emf.ecore.impl.EPackageImpl.setEFactoryInstance(EPackageI
> mpl.java:382)
> at
> org.eclipse.emf.ecore.impl.EPackageImpl.<init>(EPackageImpl.java:177)
>
> at
> subkdm.kdmObjects.impl.KdmObjectsPackageImpl.<init>(KdmObjectsPackage
> Impl.java:310)
> at
> subkdm.kdmObjects.impl.KdmObjectsPackageImpl.init(KdmObjectsPackageIm
> pl.java:336)
> at
> subkdm.kdmObjects.KdmObjectsPackage.<clinit>(KdmObjectsPackage.java:5
> 8)
> ... 57 more
>
> I'm thinking it's a conflict between maven plugin execution and emf
> libraries.
>
> I'm using: org.eclipse.emf.ecore_2.10.2.v20150123-0348
> org.eclipse.epsilon.emc.emf_1.2.0.201408251031
>
> Rolando
>
Previous Topic:[CDO/Net4j] OutOfMemoryError: Direct buffer memory
Next Topic:[Teneo] Problem with deserializing a association
Goto Forum:
  


Current Time: Wed Aug 21 05:58:56 GMT 2019

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

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

Back to the top