Home » Modeling » EMF » UnsupportedOperationException from Model and UMLPackage(... when model.setName() or adding the model to the resource)
UnsupportedOperationException from Model and UMLPackage [message #1724645] |
Thu, 25 February 2016 03:56  |
Eclipse User |
|
|
|
Hello everybody,
when setting the model name or when adding the model to the resource I get UnsupportedOperationException:
Resource.Factory.Registry lResourceFactoryRegistry = Resource.Factory.Registry.INSTANCE;
Map<String,Object> lExtensionToFactoryMap = lResourceFactoryRegistry.getExtensionToFactoryMap();
lExtensionToFactoryMap.put( "xmi", new XMIResourceFactoryImpl());
ResourceSet lResourceSet = new ResourceSetImpl();
String lOutFilePath = "D:\\workspaces\\trunk\\testdata\\XMI\\04_uml-generated\\XMI.xmi";
mResource = lResourceSet.createResource( URI.createFileURI( lOutFilePath));
assert mResource != null;
Model lModel = UMLFactory.eINSTANCE.createModel();
lModel.setName( "MyModel");
// => java.lang.UnsupportedOperationException
mResource.getContents().add( lModel);
// => ExceptionInInitializerError at UMLPackage
// Caused by: java.lang.UnsupportedOperationException
// at org.eclipse.emf.ecore.impl.MinimalEObjectImpl.eBasicAdapters(MinimalEObjectImpl.java:300)
My eclipse imports are:
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLFactory;
Have I downloaded a wrong jar? I am using:
- eclipse.jdt.core_3.1.0.jar
- eclipse-emf-common-2.3.0.jar
- org.eclipse.emf.ecore.jar
- org.eclipse.emf.ecore.xmi.jar
- org.eclipse.uml2.common-1.5.0.v201005031530.jar
- org.eclipse.uml2.uml_3.1.1.v201008191505.jar
Kind regards - Thomas
|
|
| | | | | | | |
Re: UnsupportedOperationException from Model and UMLPackage [message #1724951 is a reply to message #1724755] |
Sat, 27 February 2016 13:00   |
Eclipse User |
|
|
|
1. First I again tried to find the more actual jars for the imports and runtime dependencies via Help > Install new software:
- eclipse.jdt.core_3.1.0.jar
changed to -> org.eclipse.jdt.core_3.10.0.v20140902-0626.jar
- eclipse-emf-common-2.3.0.jar
changed to -> org.eclipse.emf.common_2.11.0.v20150805-0538.jar
- org.eclipse.emf.ecore.jar
changed to -> org.eclipse.emf.ecore_2.11.1.v20150805-0538.jar
changed to , Users\...\.p2\...\org.eclipse.emf.ecore_2.11.2.v20160208-0816.jar
- org.eclipse.emf.ecore.xmi.jar
changed to -> org.eclipse.emf.ecore.xmi_2.11.1.v20150805-0538.jar
changed to , Users\...\.p2\...\org.eclipse.emf.ecore.xmi_2.11.1.v20160208-0816.jar
- org.eclipse.uml2.common-1.5.0.v201005031530.jar
changed to -> Users\...\.p2\...\org.eclipse.uml2.common_2.1.0.v20160201-0816.jar
- org.eclipse.uml2.uml_3.1.1.v201008191505.jar
changed to -> Users\...\.p2\...\org.eclipse.uml2.uml_5.1.2.v20160201-0816.jar
- For org.eclipse.uml2.types.TypesPackage:
I tried -> Users\...\.p2\...\org.eclipse.uml2.types_2.0.0.v20160201-0816.jar
No success. So I removed these jars too from the project properties for preparing the next step:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ed Willink wrote on Thu, 25 February 2016 17:52If you just Configure->Convert to Plugin projects, [...]
2. Concerning "Configure Convert to Plugin projects":
In Eclipse > Package Explorer > MoCoEMF (my EMF project) > Context Menu > Convert there are several "Convert ..." offered, but no one like "Convert to Plugin projects". What is the right navigation?
I tried other navigations, e.g. via a new plug-in project:
Eclipse > File > New > Project > Plug-in Project > Next:
Project name: (MoCoEMF - already exists as non-plug-in
=> Error: A project with that name already exists in the workspace.)
Project name: MoCoEMF-plug-in
Use default location: (D:workspaces\trunk\MoCoEMF-plug-in)
Create a Java project: src, bin
Target platformm: This plug-in is targeted to run with: Eclipse version 3.5 or greater
> Next => Content:
Properties:
ID: MoCoEMF-plug-in
Version: 1.0.0.qualifier
Name: MoCoEMF-plug-in
Vendor: (none)
Execution Environment: JavaSE-1.8
Options:
|v| Generate an activator, a Java class that controls the plug-in's life cycle
- - Activator: mocoemf_plug_in.Activator
> Next
Create a plug-in using one of the templates: no
=> MoCoEMF-plug-in and the Activator are created, but most imports still are unsatisfied.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Still the question is: How and from where to get the required jars?
Best regards - Thomas
Eclipse Modeling Tools
Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200
[Updated on: Sat, 27 February 2016 13:08] by Moderator
|
|
|
Re: UnsupportedOperationException from Model and UMLPackage [message #1724966 is a reply to message #1724951] |
Sun, 28 February 2016 03:30   |
Eclipse User |
|
|
|
Thomas,
Learning some of the concepts seems important:
https://wiki.eclipse.org/PDE/Target_Definitions
http://help.eclipse.org/mars/index.jsp?topic=/org.eclipse.pde.doc.user/concepts/target.htm
You'll want to create a target definition that points at the update
sites of the versions of the things you want to use. Likely you can
just point at the Mars update site to get the latest released versions
of what you need.
On 27.02.2016 19:00, Thomas Taeger wrote:
> 1. First I again tried to find the more actual jars for the imports
> and runtime dependencies via Help > Install new software:
> - eclipse.jdt.core_3.1.0.jar changed to ->
> org.eclipse.jdt.core_3.10.0.v20140902-0626.jar
> - eclipse-emf-common-2.3.0.jar changed to ->
> org.eclipse.emf.common_2.11.0.v20150805-0538.jar
> - org.eclipse.emf.ecore.jar changed to ->
> org.eclipse.emf.ecore_2.11.1.v20150805-0538.jar
> changed to ,
> Users\...\.p2\...\org.eclipse.emf.ecore_2.11.2.v20160208-0816.jar
> - org.eclipse.emf.ecore.xmi.jar changed to ->
> org.eclipse.emf.ecore.xmi_2.11.1.v20150805-0538.jar
> changed to ,
> Users\...\.p2\...\org.eclipse.emf.ecore.xmi_2.11.1.v20160208-0816.jar
> - org.eclipse.uml2.common-1.5.0.v201005031530.jar changed to ->
> Users\...\.p2\...\org.eclipse.uml2.common_2.1.0.v20160201-0816.jar
> - org.eclipse.uml2.uml_3.1.1.v201008191505.jar changed to ->
> Users\...\.p2\...\org.eclipse.uml2.uml_5.1.2.v20160201-0816.jar
> - For org.eclipse.uml2.types.TypesPackage:
> I tried ->
> Users\...\.p2\...\org.eclipse.uml2.types_2.0.0.v20160201-0816.jar
> No success. So I removed these jars too from the project properties
> for preparing the next step:
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - Ed Willink wrote on Thu, 25 February 2016 17:52
>> If you just Configure->Convert to Plugin projects, [...]
>
> 2. Concerning "Configure Convert to Plugin projects":
>
> In Eclipse > Package Explorer > MoCoEMF (my EMF project) > Context
> Menu > Convert there are several "Convert ..." offered, but no one
> like "Convert to Plugin projects". What is the right navigation?
>
> I tried other navigations, e.g. via a new plug-in project: Eclipse >
> File > New > Project > Plug-in Project > Next:
> Project name: (MoCoEMF - already exists as non-plug-in => Error: A
> project with that name already exists in the workspace.)
> Project name: MoCoEMF-plug-in
> Use default location: (D:workspaces\trunk\MoCoEMF-plug-in)
> Create a Java project: src, bin
> Target platformm: This plug-in is targeted to run with: Eclipse
> version 3.5 or greater
>> Next => Content:
> Properties: ID: MoCoEMF-plug-in
> Version: 1.0.0.qualifier
> Name: MoCoEMF-plug-in
> Vendor: (none)
> Execution Environment: JavaSE-1.8
> Options:
> |v| Generate an activator, a Java class that controls the plug-in's
> life cycle
> - - Activator: mocoemf_plug_in.Activator
>> Next
> Create a plug-in using one of the templates: no
>
> => MoCoEMF-plug-in und the Activator are created, but most imports
> still are unsatisfied.
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - -
> Still the question is: How and from where to get the required jars?
>
> Best regards - Thomas
>
|
|
| | | | | | | | | | | | | | | | |
Re: UnsupportedOperationException from Model and UMLPackage [message #1725446 is a reply to message #1725441] |
Thu, 03 March 2016 09:48   |
Eclipse User |
|
|
|
Thomas Taeger wrote on Thu, 03 March 2016 14:28EMF-Installation:
https://www.eclipse.org/modeling/emf/downloads/? => emf-xsd-Update-2.11.1.zip
containing binary\, features\, plugins\ and 2 jars
Unzip emf-xsd-Update-2.11.1.zip to C:\progs\eclipse\ => merging features\ and merging plugins\ without overwriting any
Eclipse | Package Explorer | MoCoEMF | Project | Properties | Java build path | Libraries:
Removed the old emf and uml2 jars =>
only JRE System Library [JavaSE-1.8] and Plug-in Dependencies (all based on the new directory C:\progs\eclipse\plugins\) | Ok
Eclipse restart
Eclipse | Package Explorer | MoCoEMF | Project | Properties | Plug-in Development | Runtime Classpath: /MoCoEMF/bin | OK
Eclipse restart
First, you don't install a feature or plug-in into Eclipse by manually extracting ZIP files and "merging" contents. That will not work and likely result in a hosed up installation. Eclipse provides the Install New Software wizard (under the Help menu) to install stuff into your existing Eclipse. Details can be found here. You probably want the EMF SDK feature(s). Note that since you're doing EMF and Eclipse plug-in development, you might want to start with the Modeling Tools or Committers packages. In any case you can always add features you need. Just don't try manually extracting files on top of your installation.
Second, you seem to be restarting Eclipse quite often as you try things, but that's not necessary. The only time Eclipse needs a restart is after installing or uninstalling a feature or plug-in(s), and it will prompt you. Changing your projects inside Eclipse does NOT require restart. In general, Eclipse will tell you when a restart is needed, otherwise you don't need to.
Finally, in general it seems your inclination is to do things manually (such as extracting files into your Eclipse installation, editing classpath files, etc). Fight that inclination; in general, plug-in development tools are there to do almost everything you need to do. In other words, there's almost always going to be a GUI, so if you find yourself doing stuff "manually" stop and look through the tutorials and/or documentation first. And of course specific questions are welcomed around here.
Oh yeah, about help creating a Target Definition... did you read the tutorial(s) that was pointed out earlier in this thread?
[Updated on: Thu, 03 March 2016 09:49] by Moderator
|
|
| |
Goto Forum:
Current Time: Tue Aug 19 18:50:32 EDT 2025
Powered by FUDForum. Page generated in 0.09667 seconds
|