Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY
[UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378094] Mon, 03 March 2008 18:16 Go to next message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hello,

another problem, I want to access the UML_Primitive_Lib, so that I can use
the primitive types as type specification.

I tried like this:

URI primitiveTpyeLibURI =
URI.createURI(XMI2UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_UR I);
Model uml2PrimitiveTypesLibrary =
(Model)UML2Util.load(
RESOURCE_SET,
primitiveTpyeLibURI,
UMLPackage.Literals.MODEL);


actually I've tried with many URIs in different classes, but none of work
seemed to be working(i.e. load() always return null).

--XMI2UMLResource
* UML_PRIMITIVE_TYPES_LIBRARY_2_1_URI
* UML_PRIMITIVE_TYPES_LIBRARY_URI

--UMLResource
* UML_PRIMITIVE_TYPES_LIBRARY_URI

--UML22UMLResource
* UML2_PRIMITIVE_TYPES_LIBRARY_URI


Any one has any idea?
best Regards.
Jinhui
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378108 is a reply to message #378094] Mon, 03 March 2008 19:12 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Jinhui,

This is another question for the UML2 newgroup.

Have you read the introductory articles on the UML2 documentation page
(http://wiki.eclipse.org/MDT-UML2#Articles)? They described how to work with
models and profiles both programatically and using the sample editor. I
suspect the problem you are having relates to not registering the pathmaps
for the UML library resources - see the FAQ at
http://wiki.eclipse.org/MDT-UML2-FAQ#What.27s_required_to_lo ad_a_UML_.28.uml.29_resource_from_a_standalone_application.3 F.

Kenn


"Jinhui " <zhuj@in.tum.de> wrote in message
news:140c994f2ffa8aae6c53eb09bb4b9dc5$1@www.eclipse.org...
> Hello,
> another problem, I want to access the UML_Primitive_Lib, so that I can use
> the primitive types as type specification.
>
> I tried like this:
>
> URI primitiveTpyeLibURI =
> URI.createURI(XMI2UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_UR I);
> Model uml2PrimitiveTypesLibrary =
> (Model)UML2Util.load(
> RESOURCE_SET,
> primitiveTpyeLibURI,
> UMLPackage.Literals.MODEL);
>
>
> actually I've tried with many URIs in different classes, but none of work
> seemed to be working(i.e. load() always return null).
>
> --XMI2UMLResource
> * UML_PRIMITIVE_TYPES_LIBRARY_2_1_URI
> * UML_PRIMITIVE_TYPES_LIBRARY_URI
> --UMLResource
> * UML_PRIMITIVE_TYPES_LIBRARY_URI
> --UML22UMLResource
> * UML2_PRIMITIVE_TYPES_LIBRARY_URI
>
> Any one has any idea?
> best Regards.
> Jinhui
>
>
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378113 is a reply to message #378108] Mon, 03 March 2008 20:54 Go to previous messageGo to next message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hi Kenn,

first, sorry for misplacing the message in the MDT group. Newbie!


I tried both the two approaches mentioned in the article, neither worked.
the one as in the Profile-tutorial looks like this:

PrimitiveType primitiveType = importPrimitiveType( "Boolean");

protected static PrimitiveType importPrimitiveType(String name) {
Model umlLibrary =
(Model)load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LI BRARY_URI));
PrimitiveType primitiveType = (PrimitiveType)
umlLibrary.getOwnedType(name);
return primitiveType;
}

protected static org.eclipse.uml2.uml.Package load(URI uri) {
org.eclipse.uml2.uml.Package package_ = null;
try {
Resource resource = RESOURCE_SET.getResource(uri, true); (****)
package_ =(org.eclipse.uml2.uml.Package)EcoreUtil.getObjectByType(
resource.getContents(), UMLPackage.Literals.PACKAGE);
} catch (WrappedException we) {
}
return package_;
}



I got Exception at (****):
"Cannot create a resource for
'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml'; a registered
resource factory is needed"

>> I suspect the problem you are having relates to not registering the
pathmaps for the UML library resources

Can you give me more hints on this?

best Regards!
Jinhui
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378117 is a reply to message #378113] Tue, 04 March 2008 01:25 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Jinhui,

Its sounds like a resource factory has not been registered to hande the URI
you are trying load. The FAQ entry that I pointed you to shows how to do
this:
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);Kenn

"Jinhui" <zhuj@in.tum.de> wrote in message
news:902de8df46b383e348d19ed88a7e0b73$1@www.eclipse.org...
> Hi Kenn,
>
> first, sorry for misplacing the message in the MDT group. Newbie!
>
>
> I tried both the two approaches mentioned in the article, neither worked.
> the one as in the Profile-tutorial looks like this:
>
> PrimitiveType primitiveType = importPrimitiveType( "Boolean");
>
> protected static PrimitiveType importPrimitiveType(String name) {
> Model umlLibrary =
> (Model)load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LI BRARY_URI));
> PrimitiveType primitiveType = (PrimitiveType)
> umlLibrary.getOwnedType(name);
> return primitiveType;
> }
>
> protected static org.eclipse.uml2.uml.Package load(URI uri) {
> org.eclipse.uml2.uml.Package package_ = null;
> try {
> Resource resource = RESOURCE_SET.getResource(uri, true); (****)
> package_ =(org.eclipse.uml2.uml.Package)EcoreUtil.getObjectByType(
> resource.getContents(), UMLPackage.Literals.PACKAGE); } catch
> (WrappedException we) {
> }
> return package_;
> }
>
>
>
> I got Exception at (****):
> "Cannot create a resource for
> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml'; a registered
> resource factory is needed"
>
>>> I suspect the problem you are having relates to not registering the
> pathmaps for the UML library resources
>
> Can you give me more hints on this?
>
> best Regards! Jinhui
>
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378121 is a reply to message #378117] Tue, 04 March 2008 10:36 Go to previous messageGo to next message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hi Kenn,

Thanks for the advice.

Well, it seemed that the URI
"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml" has to be resolved
manually, otherwise it could not be resolved by EMF. (I always got the
"MalformedURLException")

So I solved the problem like this:
* I extract the "UMLPrimitiveTypes.library.uml" from the JAR file, and
save it in my current project dir.
* and then register the the pathmap-URI with with the physical one(the one
in my project dir), and now I was able to load the primitive type lib and
get the primitive types.

Jinhui

The code looks like this:

ResourceSet RESOURCE_SET = new
RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
new UMLResourceFactoryImpl());

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
new XMIResourceFactoryImpl());
URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml"),
URI.createFileURI(System.getProperty("user.dir") +
"/Model_Libs/UMLPrimitiveTypes.library.uml"));

Resource resource =
RESOURCE_SET.getResource(URI.createURI(UMLResource.UML_PRIMI TIVE_TYPES_LIBRARY_URI),
true);


Kenn Hussey wrote:

> Jinhui,

> Its sounds like a resource factory has not been registered to hande the URI
> you are trying load. The FAQ entry that I pointed you to shows how to do
> this:
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378126 is a reply to message #378121] Tue, 04 March 2008 15:53 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Jinhui,

What string did you try using for the base JAR URL? I've done this many
times in the past (as per the FAQ) and never had a problem...

Kenn

"Jinhui" <zhuj@in.tum.de> wrote in message
news:0026a798a8951e2cfe35598bcf00db2e$1@www.eclipse.org...
> Hi Kenn,
> Thanks for the advice.
>
> Well, it seemed that the URI
> "pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml" has to be resolved
> manually, otherwise it could not be resolved by EMF. (I always got the
> "MalformedURLException")
>
> So I solved the problem like this: * I extract the
> "UMLPrimitiveTypes.library.uml" from the JAR file, and save it in my
> current project dir.
> * and then register the the pathmap-URI with with the physical one(the one
> in my project dir), and now I was able to load the primitive type lib and
> get the primitive types.
>
> Jinhui
>
> The code looks like this:
>
> ResourceSet RESOURCE_SET = new
> RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
> new UMLResourceFactoryImpl());
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*", new
> XMIResourceFactoryImpl());
> URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml"),
> URI.createFileURI(System.getProperty("user.dir") +
> "/Model_Libs/UMLPrimitiveTypes.library.uml"));
>
> Resource resource =
> RESOURCE_SET.getResource(URI.createURI(UMLResource.UML_PRIMI TIVE_TYPES_LIBRARY_URI),
> true);
>
>
> Kenn Hussey wrote:
>
>> Jinhui,
>
>> Its sounds like a resource factory has not been registered to hande the
>> URI you are trying load. The FAQ entry that I pointed you to shows how to
>> do this:
>
>
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378130 is a reply to message #378126] Tue, 04 March 2008 18:58 Go to previous messageGo to next message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hi Kenn,

> What string did you try using for the base JAR URL? I've done this many
> times in the past (as per the FAQ) and never had a problem...

yes, you're right, after setting the correct base JAR URL, the "FAQ-way"
worked well.

Previously I was wondering, if I could avoid setting it to a specific
directory of mine, because this could be different on others' machine, and
my app is supposed to run on many machines.

regards.
Jinhui
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378633 is a reply to message #378121] Fri, 08 August 2008 15:16 Go to previous messageGo to next message
Werner Schindling is currently offline Werner SchindlingFriend
Messages: 9
Registered: July 2009
Junior Member
Hello there!

I have a problem with the same code, also trying to load resources from
a standalone application.

Jinhui schrieb:
> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
> new UMLResourceFactoryImpl());
>
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
> new XMIResourceFactoryImpl());


> Resource resource = RESOURCE_SET.getResource(uri, true);

The code above gives me a

java.lang.ClassCastException:
org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImp l cannot be
cast to org.eclipse.emf.ecore.resource.Resource$Factory

which seems strange, since UMLResourceFactoryImpl implements
Resource.Factory ...
I use the plugin versions EMF SDK 2.4 (2008/06/09) and UML2 2.1.0
(2008/05/13). Are these incompatible? They are the latest available
versions ...
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378634 is a reply to message #378633] Fri, 08 August 2008 18:41 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
UML2 2.2.0 is dependent on EMF 2.4. It looks like you have incompatible
versions.

The download page indicates all the proper depencies ...
http://www.eclipse.org/modeling/mdt/downloads/?project=uml2

- James

"Werner Schindling" <w.schindling@netconomy.et> wrote in message
news:g7ho0p$i4j$1@build.eclipse.org...
> Hello there!
>
> I have a problem with the same code, also trying to load resources from a
> standalone application.
>
> Jinhui schrieb:
>> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
>> new UMLResourceFactoryImpl());
>>
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
>> new XMIResourceFactoryImpl());
>
>
> > Resource resource = RESOURCE_SET.getResource(uri, true);
>
> The code above gives me a
>
> java.lang.ClassCastException:
> org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImp l cannot be
> cast to org.eclipse.emf.ecore.resource.Resource$Factory
>
> which seems strange, since UMLResourceFactoryImpl implements
> Resource.Factory ...
> I use the plugin versions EMF SDK 2.4 (2008/06/09) and UML2 2.1.0
> (2008/05/13). Are these incompatible? They are the latest available
> versions ...
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #378636 is a reply to message #378634] Mon, 11 August 2008 07:39 Go to previous messageGo to next message
Werner Schindling is currently offline Werner SchindlingFriend
Messages: 9
Registered: July 2009
Junior Member
You were right, my Tomcat used the wrong libs.

Thanks,
Werner

James Bruck wrote:
> UML2 2.2.0 is dependent on EMF 2.4. It looks like you have incompatible
> versions.
>
> The download page indicates all the proper depencies ...
> http://www.eclipse.org/modeling/mdt/downloads/?project=uml2
>
> - James
>
> "Werner Schindling" <w.schindling@netconomy.et> wrote in message
> news:g7ho0p$i4j$1@build.eclipse.org...
>> Hello there!
>>
>> I have a problem with the same code, also trying to load resources from a
>> standalone application.
>>
>> Jinhui schrieb:
>>> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
>>> UMLResource.Factory.INSTANCE);
>>> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
>>>
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
>>> new UMLResourceFactoryImpl());
>>>
>>>
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
>>> new XMIResourceFactoryImpl());
>>
>>> Resource resource = RESOURCE_SET.getResource(uri, true);
>> The code above gives me a
>>
>> java.lang.ClassCastException:
>> org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImp l cannot be
>> cast to org.eclipse.emf.ecore.resource.Resource$Factory
>>
>> which seems strange, since UMLResourceFactoryImpl implements
>> Resource.Factory ...
>> I use the plugin versions EMF SDK 2.4 (2008/06/09) and UML2 2.1.0
>> (2008/05/13). Are these incompatible? They are the latest available
>> versions ...
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #489016 is a reply to message #378108] Thu, 01 October 2009 08:54 Go to previous messageGo to next message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 186
Registered: July 2009
Location: Torino
Senior Member

I did as the FAQ indicated but which URI I have to import? import org.eclipse.emf.common.util.URI? Because this class have the method "createUri" but not the method "create" indicated in the line:

URI uri = URI.create(" jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_ 2.0.0.v200606221411.jar!/ ");

Is this just a typo and have I to change create in createUri?


Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #489100 is a reply to message #489016] Thu, 01 October 2009 13:49 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Federico,

That was indeed a typo and has now been fixed. Sorry about that.

Cheers,

Kenn

Federico Tomassetti wrote:
> I did as the FAQ indicated but which URI I have to import? import
> org.eclipse.emf.common.util.URI? Because this class have the method
> "createUri" but not the method "create" indicated in the line:
>
> URI uri = URI.create("
> jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_
> 2.0.0.v200606221411.jar!/ ");
>
> Is this just a typo and have I to change create in createUri?
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #584830 is a reply to message #378094] Mon, 03 March 2008 19:12 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Jinhui,

This is another question for the UML2 newgroup.

Have you read the introductory articles on the UML2 documentation page
(http://wiki.eclipse.org/MDT-UML2#Articles)? They described how to work with
models and profiles both programatically and using the sample editor. I
suspect the problem you are having relates to not registering the pathmaps
for the UML library resources - see the FAQ at
http://wiki.eclipse.org/MDT-UML2-FAQ#What.27s_required_to_lo ad_a_UML_.28.uml.29_resource_from_a_standalone_application.3 F

Kenn


"Jinhui " <zhuj@in.tum.de> wrote in message
news:140c994f2ffa8aae6c53eb09bb4b9dc5$1@www.eclipse.org...
> Hello,
> another problem, I want to access the UML_Primitive_Lib, so that I can use
> the primitive types as type specification.
>
> I tried like this:
>
> URI primitiveTpyeLibURI =
> URI.createURI(XMI2UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_UR I);
> Model uml2PrimitiveTypesLibrary =
> (Model)UML2Util.load(
> RESOURCE_SET,
> primitiveTpyeLibURI,
> UMLPackage.Literals.MODEL);
>
>
> actually I've tried with many URIs in different classes, but none of work
> seemed to be working(i.e. load() always return null).
>
> --XMI2UMLResource
> * UML_PRIMITIVE_TYPES_LIBRARY_2_1_URI
> * UML_PRIMITIVE_TYPES_LIBRARY_URI
> --UMLResource
> * UML_PRIMITIVE_TYPES_LIBRARY_URI
> --UML22UMLResource
> * UML2_PRIMITIVE_TYPES_LIBRARY_URI
>
> Any one has any idea?
> best Regards.
> Jinhui
>
>
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #584843 is a reply to message #378108] Mon, 03 March 2008 20:54 Go to previous message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hi Kenn,

first, sorry for misplacing the message in the MDT group. Newbie!


I tried both the two approaches mentioned in the article, neither worked.
the one as in the Profile-tutorial looks like this:

PrimitiveType primitiveType = importPrimitiveType( "Boolean");

protected static PrimitiveType importPrimitiveType(String name) {
Model umlLibrary =
(Model)load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LI BRARY_URI));
PrimitiveType primitiveType = (PrimitiveType)
umlLibrary.getOwnedType(name);
return primitiveType;
}

protected static org.eclipse.uml2.uml.Package load(URI uri) {
org.eclipse.uml2.uml.Package package_ = null;
try {
Resource resource = RESOURCE_SET.getResource(uri, true); (****)
package_ =(org.eclipse.uml2.uml.Package)EcoreUtil.getObjectByType(
resource.getContents(), UMLPackage.Literals.PACKAGE);
} catch (WrappedException we) {
}
return package_;
}



I got Exception at (****):
"Cannot create a resource for
'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml'; a registered
resource factory is needed"

>> I suspect the problem you are having relates to not registering the
pathmaps for the UML library resources

Can you give me more hints on this?

best Regards!
Jinhui
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #584858 is a reply to message #378113] Tue, 04 March 2008 01:25 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Jinhui,

Its sounds like a resource factory has not been registered to hande the URI
you are trying load. The FAQ entry that I pointed you to shows how to do
this:
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);Kenn

"Jinhui" <zhuj@in.tum.de> wrote in message
news:902de8df46b383e348d19ed88a7e0b73$1@www.eclipse.org...
> Hi Kenn,
>
> first, sorry for misplacing the message in the MDT group. Newbie!
>
>
> I tried both the two approaches mentioned in the article, neither worked.
> the one as in the Profile-tutorial looks like this:
>
> PrimitiveType primitiveType = importPrimitiveType( "Boolean");
>
> protected static PrimitiveType importPrimitiveType(String name) {
> Model umlLibrary =
> (Model)load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LI BRARY_URI));
> PrimitiveType primitiveType = (PrimitiveType)
> umlLibrary.getOwnedType(name);
> return primitiveType;
> }
>
> protected static org.eclipse.uml2.uml.Package load(URI uri) {
> org.eclipse.uml2.uml.Package package_ = null;
> try {
> Resource resource = RESOURCE_SET.getResource(uri, true); (****)
> package_ =(org.eclipse.uml2.uml.Package)EcoreUtil.getObjectByType(
> resource.getContents(), UMLPackage.Literals.PACKAGE); } catch
> (WrappedException we) {
> }
> return package_;
> }
>
>
>
> I got Exception at (****):
> "Cannot create a resource for
> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml'; a registered
> resource factory is needed"
>
>>> I suspect the problem you are having relates to not registering the
> pathmaps for the UML library resources
>
> Can you give me more hints on this?
>
> best Regards! Jinhui
>
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #584875 is a reply to message #378117] Tue, 04 March 2008 10:36 Go to previous message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hi Kenn,

Thanks for the advice.

Well, it seemed that the URI
"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml" has to be resolved
manually, otherwise it could not be resolved by EMF. (I always got the
"MalformedURLException")

So I solved the problem like this:
* I extract the "UMLPrimitiveTypes.library.uml" from the JAR file, and
save it in my current project dir.
* and then register the the pathmap-URI with with the physical one(the one
in my project dir), and now I was able to load the primitive type lib and
get the primitive types.

Jinhui

The code looks like this:

ResourceSet RESOURCE_SET = new
RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
new UMLResourceFactoryImpl());

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
new XMIResourceFactoryImpl());
URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml"),
URI.createFileURI(System.getProperty("user.dir") +
"/Model_Libs/UMLPrimitiveTypes.library.uml"));

Resource resource =
RESOURCE_SET.getResource(URI.createURI(UMLResource.UML_PRIMI TIVE_TYPES_LIBRARY_URI),
true);


Kenn Hussey wrote:

> Jinhui,

> Its sounds like a resource factory has not been registered to hande the URI
> you are trying load. The FAQ entry that I pointed you to shows how to do
> this:
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #584899 is a reply to message #378121] Tue, 04 March 2008 15:53 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Jinhui,

What string did you try using for the base JAR URL? I've done this many
times in the past (as per the FAQ) and never had a problem...

Kenn

"Jinhui" <zhuj@in.tum.de> wrote in message
news:0026a798a8951e2cfe35598bcf00db2e$1@www.eclipse.org...
> Hi Kenn,
> Thanks for the advice.
>
> Well, it seemed that the URI
> "pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml" has to be resolved
> manually, otherwise it could not be resolved by EMF. (I always got the
> "MalformedURLException")
>
> So I solved the problem like this: * I extract the
> "UMLPrimitiveTypes.library.uml" from the JAR file, and save it in my
> current project dir.
> * and then register the the pathmap-URI with with the physical one(the one
> in my project dir), and now I was able to load the primitive type lib and
> get the primitive types.
>
> Jinhui
>
> The code looks like this:
>
> ResourceSet RESOURCE_SET = new
> RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
> new UMLResourceFactoryImpl());
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*", new
> XMIResourceFactoryImpl());
> URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml"),
> URI.createFileURI(System.getProperty("user.dir") +
> "/Model_Libs/UMLPrimitiveTypes.library.uml"));
>
> Resource resource =
> RESOURCE_SET.getResource(URI.createURI(UMLResource.UML_PRIMI TIVE_TYPES_LIBRARY_URI),
> true);
>
>
> Kenn Hussey wrote:
>
>> Jinhui,
>
>> Its sounds like a resource factory has not been registered to hande the
>> URI you are trying load. The FAQ entry that I pointed you to shows how to
>> do this:
>
>
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #584914 is a reply to message #378126] Tue, 04 March 2008 18:58 Go to previous message
Jinhui is currently offline JinhuiFriend
Messages: 42
Registered: July 2009
Member
Hi Kenn,

> What string did you try using for the base JAR URL? I've done this many
> times in the past (as per the FAQ) and never had a problem...

yes, you're right, after setting the correct base JAR URL, the "FAQ-way"
worked well.

Previously I was wondering, if I could avoid setting it to a specific
directory of mine, because this could be different on others' machine, and
my app is supposed to run on many machines.

regards.
Jinhui
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #593695 is a reply to message #378121] Fri, 08 August 2008 15:16 Go to previous message
Werner Schindling is currently offline Werner SchindlingFriend
Messages: 9
Registered: July 2009
Junior Member
Hello there!

I have a problem with the same code, also trying to load resources from
a standalone application.

Jinhui schrieb:
> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
> new UMLResourceFactoryImpl());
>
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
> new XMIResourceFactoryImpl());


> Resource resource = RESOURCE_SET.getResource(uri, true);

The code above gives me a

java.lang.ClassCastException:
org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImp l cannot be
cast to org.eclipse.emf.ecore.resource.Resource$Factory

which seems strange, since UMLResourceFactoryImpl implements
Resource.Factory ...
I use the plugin versions EMF SDK 2.4 (2008/06/09) and UML2 2.1.0
(2008/05/13). Are these incompatible? They are the latest available
versions ...
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #593706 is a reply to message #378633] Fri, 08 August 2008 18:41 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
UML2 2.2.0 is dependent on EMF 2.4. It looks like you have incompatible
versions.

The download page indicates all the proper depencies ...
http://www.eclipse.org/modeling/mdt/downloads/?project=uml2

- James

"Werner Schindling" <w.schindling@netconomy.et> wrote in message
news:g7ho0p$i4j$1@build.eclipse.org...
> Hello there!
>
> I have a problem with the same code, also trying to load resources from a
> standalone application.
>
> Jinhui schrieb:
>> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
>> new UMLResourceFactoryImpl());
>>
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
>> new XMIResourceFactoryImpl());
>
>
> > Resource resource = RESOURCE_SET.getResource(uri, true);
>
> The code above gives me a
>
> java.lang.ClassCastException:
> org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImp l cannot be
> cast to org.eclipse.emf.ecore.resource.Resource$Factory
>
> which seems strange, since UMLResourceFactoryImpl implements
> Resource.Factory ...
> I use the plugin versions EMF SDK 2.4 (2008/06/09) and UML2 2.1.0
> (2008/05/13). Are these incompatible? They are the latest available
> versions ...
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #593737 is a reply to message #378634] Mon, 11 August 2008 07:39 Go to previous message
Werner Schindling is currently offline Werner SchindlingFriend
Messages: 9
Registered: July 2009
Junior Member
You were right, my Tomcat used the wrong libs.

Thanks,
Werner

James Bruck wrote:
> UML2 2.2.0 is dependent on EMF 2.4. It looks like you have incompatible
> versions.
>
> The download page indicates all the proper depencies ...
> http://www.eclipse.org/modeling/mdt/downloads/?project=uml2
>
> - James
>
> "Werner Schindling" <w.schindling@netconomy.et> wrote in message
> news:g7ho0p$i4j$1@build.eclipse.org...
>> Hello there!
>>
>> I have a problem with the same code, also trying to load resources from a
>> standalone application.
>>
>> Jinhui schrieb:
>>> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
>>> UMLResource.Factory.INSTANCE);
>>> Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
>>>
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml",
>>> new UMLResourceFactoryImpl());
>>>
>>>
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "*",
>>> new XMIResourceFactoryImpl());
>>
>>> Resource resource = RESOURCE_SET.getResource(uri, true);
>> The code above gives me a
>>
>> java.lang.ClassCastException:
>> org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImp l cannot be
>> cast to org.eclipse.emf.ecore.resource.Resource$Factory
>>
>> which seems strange, since UMLResourceFactoryImpl implements
>> Resource.Factory ...
>> I use the plugin versions EMF SDK 2.4 (2008/06/09) and UML2 2.1.0
>> (2008/05/13). Are these incompatible? They are the latest available
>> versions ...
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #597787 is a reply to message #378108] Thu, 01 October 2009 08:54 Go to previous message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 186
Registered: July 2009
Location: Torino
Senior Member

I did as the FAQ indicated but which URI I have to import? import org.eclipse.emf.common.util.URI? Because this class have the method "createUri" but not the method "create" indicated in the line:

URI uri = URI.create(" jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_ 2.0.0.v200606221411.jar!/ ");

Is this just a typo and have I to change create in createUri?


Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #597792 is a reply to message #597787] Thu, 01 October 2009 13:49 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Federico,

That was indeed a typo and has now been fixed. Sorry about that.

Cheers,

Kenn

Federico Tomassetti wrote:
> I did as the FAQ indicated but which URI I have to import? import
> org.eclipse.emf.common.util.URI? Because this class have the method
> "createUri" but not the method "create" indicated in the line:
>
> URI uri = URI.create("
> jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_
> 2.0.0.v200606221411.jar!/ ");
>
> Is this just a typo and have I to change create in createUri?
Previous Topic:[Announce] A Proposal and Prototype for an Eclipse Model Registry
Next Topic:Team Models development using plugin CVS
Goto Forum:
  


Current Time: Tue Dec 23 00:14:03 GMT 2014

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

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