Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY
Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY [message #477018] Mon, 03 March 2008 19:12 Go to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
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 #477019 is a reply to message #477018] 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 #477021 is a reply to message #477019] Tue, 04 March 2008 01:25 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
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 #477022 is a reply to message #477021] 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 #477023 is a reply to message #477022] Tue, 04 March 2008 15:53 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
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 #477024 is a reply to message #477023] 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 #477666 is a reply to message #477022] 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 #477667 is a reply to message #477666] 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 #477668 is a reply to message #477667] 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 #626123 is a reply to message #477018] 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 #626125 is a reply to message #477019] Tue, 04 March 2008 01:25 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
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 #626126 is a reply to message #477021] 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 #626127 is a reply to message #477022] Tue, 04 March 2008 15:53 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
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 #626128 is a reply to message #477023] 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 #626858 is a reply to message #477022] 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 #626859 is a reply to message #477666] 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 #626860 is a reply to message #477667] 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 ...
Previous Topic:LiteralSpecification
Next Topic:Programatic Selection of NamedElement in UMLEditor
Goto Forum:
  


Current Time: Thu Mar 28 23:11:02 GMT 2024

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

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

Back to the top