Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Profile with enumeration in same file as model -> ClassCastException
Profile with enumeration in same file as model -> ClassCastException [message #586748] Fri, 09 February 2007 11:23
Sebastien Boucard is currently offline Sebastien BoucardFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

I have a Model on which I apply a Profile. The model and the profile and
saved in the same unique file.
The profile defines a stereotype with a property whose type is an
enumeration, defined in this profile as well.
This stereotype is applied to an instance of the model, an the property is
set to an enumeration literal.
No problem to save this model. The file format looks good, all necessary
information is there.

But I get a ClassCastException when a reload the resource.
This is because the resource is loaded using
XMLResource.OPTION_DEFER_IDREF_RESOLUTION=true (in UMLResourceFactoryImpl).
By the time the xmi reader try to set the value of the property, the type
of this property is not already set (forward references are not resolved,
we did not reached the end of the document).

I suspect this problem would be solved by saving this profile in another
resource, but I need the ability to save the model and the applied profile
in one unique file.

Using Eclipse 3.2.1, EMF 2.2.1, UML2 2.0.1.


Here is the uml model:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:MyProfile="http:///schemas/MyProfile/0"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
xsi:schemaLocation="http:///schemas/MyProfile/0 #_UAiohrgvEdunuaNMnDW42g">
<uml:Model xmi:id="_UAiogLgvEdunuaNMnDW42g" name="MyModel">
<packagedElement xmi:type="uml:Class" xmi:id="_UAiogbgvEdunuaNMnDW42g"
name="MyClass"/>
<profileApplication xmi:id="_UAiogrgvEdunuaNMnDW42g"
appliedProfile="_UAiohLgvEdunuaNMnDW42g">
<eAnnotations xmi:id="_UAiog7gvEdunuaNMnDW42g"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_UAiohrgvEdunuaNMnDW42g"/>
</profileApplication>
</uml:Model>
<uml:Profile xmi:id="_UAiohLgvEdunuaNMnDW42g" name="MyProfile"
metaclassReference="_UAioj7gvEdunuaNMnDW42g">
<eAnnotations xmi:id="_UAiohbgvEdunuaNMnDW42g"
source="http://www.eclipse.org/uml2/2.0.0/UML">
<contents xmi:type="ecore:EPackage" xmi:id="_UAiohrgvEdunuaNMnDW42g"
name="MyProfile" nsURI="http:///schemas/MyProfile/0" nsPrefix="MyProfile">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_UAioh7gvEdunuaNMnDW42g" name="MyStereotype">
<eAnnotations xmi:id="_UAioiLgvEdunuaNMnDW42g"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_UAiokLgvEdunuaNMnDW42g"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_UAioibgvEdunuaNMnDW42g" name="base_Class" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.0.0/UML#//Class"/>
</eStructuralFeatures>
<eStructuralFeatures xmi:type="ecore:EAttribute"
xmi:id="_UAioirgvEdunuaNMnDW42g" name="MyProperty" ordered="false"
lowerBound="1" eType="_UAioi7gvEdunuaNMnDW42g"/>
</eClassifiers>
<eClassifiers xmi:type="ecore:EEnum"
xmi:id="_UAioi7gvEdunuaNMnDW42g" name="MyEnumeration">
<eAnnotations xmi:id="_UAiojLgvEdunuaNMnDW42g"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_UAiolbgvEdunuaNMnDW42g"/>
<eLiterals xmi:id="_UAiojbgvEdunuaNMnDW42g" name="MyLiteral"/>
<eLiterals xmi:id="_UAiojrgvEdunuaNMnDW42g"
name="MySecondLiteral" value="1"/>
</eClassifiers>
</contents>
</eAnnotations>
<elementImport xmi:id="_UAioj7gvEdunuaNMnDW42g">
<importedElement xmi:type="uml:Class"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</elementImport>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_UAiokLgvEdunuaNMnDW42g" name="MyStereotype">
<ownedAttribute xmi:id="_UAiokbgvEdunuaNMnDW42g" name="base_Class"
association="_UAiok7gvEdunuaNMnDW42g">
<type xmi:type="uml:Class"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
</ownedAttribute>
<ownedAttribute xmi:id="_UAiokrgvEdunuaNMnDW42g" name="MyProperty"
type="_UAiolbgvEdunuaNMnDW42g"/>
</packagedElement>
<packagedElement xmi:type="uml:Extension"
xmi:id="_UAiok7gvEdunuaNMnDW42g" name="Class_MyStereotype"
memberEnd="_UAiolLgvEdunuaNMnDW42g _UAiokbgvEdunuaNMnDW42g">
<ownedEnd xmi:type="uml:ExtensionEnd"
xmi:id="_UAiolLgvEdunuaNMnDW42g" name="extension_MyStereotype"
type="_UAiokLgvEdunuaNMnDW42g" aggregation="composite"
association="_UAiok7gvEdunuaNMnDW42g"/>
</packagedElement>
<packagedElement xmi:type="uml:Enumeration"
xmi:id="_UAiolbgvEdunuaNMnDW42g" name="MyEnumeration">
<ownedLiteral xmi:id="_UAiolrgvEdunuaNMnDW42g" name="MyLiteral"/>
<ownedLiteral xmi:id="_UAiol7gvEdunuaNMnDW42g"
name="MySecondLiteral"/>
</packagedElement>
</uml:Profile>
<MyProfile:MyStereotype xmi:id="_UAiomLgvEdunuaNMnDW42g"
base_Class="_UAiogbgvEdunuaNMnDW42g" MyProperty="MySecondLiteral"/>
</xmi:XMI>


Any help would be appreciated,

Sebastien
www.mdworkbench.com
Previous Topic:Using UML2 GenModel with a simple eCore model to handle 'subsets'
Next Topic:A suggestion for user-friendly typing
Goto Forum:
  


Current Time: Sat Apr 27 04:35:15 GMT 2024

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

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

Back to the top