Home » Modeling » UML2 » Profile with enumeration in same file as model -> ClassCastException
Profile with enumeration in same file as model -> ClassCastException [message #470230] |
Fri, 09 February 2007 11:23 |
Sebastien Boucard 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
|
|
|
Re: Profile with enumeration in same file as model -> ClassCastException [message #470243 is a reply to message #470230] |
Fri, 09 February 2007 22:02 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Sebastien,
It is being looked into. Saving model and profile in one file should work.
- James.
"Sebastien Boucard" <sboucard@sodius.com> wrote in message
news:31b0516f84b8f305367925ea24c54348$1@www.eclipse.org...
> 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
>
|
|
|
Re: Profile with enumeration in same file as model -> ClassCastException [message #470247 is a reply to message #470243] |
Mon, 12 February 2007 01:37 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Sebastien,
I'm seeing this stack trace..
java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EAttributeImpl
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2559)
at
org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2026)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1240)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1306)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:949)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:932)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:681)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:163)
With slight modifications I can open the model and can see the following .
Please raise a defect and this will be taken care of.
Regards.
- James.
"James Bruck" <jbruck@ca.ibm.com> wrote in message
news:eqir16$qgm$2@utils.eclipse.org...
> Hi Sebastien,
>
> It is being looked into. Saving model and profile in one file should
> work.
>
> - James.
>
> "Sebastien Boucard" <sboucard@sodius.com> wrote in message
> news:31b0516f84b8f305367925ea24c54348$1@www.eclipse.org...
>> 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
>>
>
>
-
Attachment: model1.gif
(Size: 11.73KB, Downloaded 174 times)
|
|
| | |
Re: Profile with enumeration in same file as model -> ClassCastException [message #586832 is a reply to message #470230] |
Fri, 09 February 2007 22:02 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Sebastien,
It is being looked into. Saving model and profile in one file should work.
- James.
"Sebastien Boucard" <sboucard@sodius.com> wrote in message
news:31b0516f84b8f305367925ea24c54348$1@www.eclipse.org...
> 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
>
|
|
|
Re: Profile with enumeration in same file as model -> ClassCastException [message #586845 is a reply to message #470243] |
Mon, 12 February 2007 01:37 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Sebastien,
I'm seeing this stack trace..
java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EAttributeImpl
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2559)
at
org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2026)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1240)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1306)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:949)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:932)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:681)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:163)
With slight modifications I can open the model and can see the following .
Please raise a defect and this will be taken care of.
Regards.
- James.
"James Bruck" <jbruck@ca.ibm.com> wrote in message
news:eqir16$qgm$2@utils.eclipse.org...
> Hi Sebastien,
>
> It is being looked into. Saving model and profile in one file should
> work.
>
> - James.
>
> "Sebastien Boucard" <sboucard@sodius.com> wrote in message
> news:31b0516f84b8f305367925ea24c54348$1@www.eclipse.org...
>> 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
>>
>
>
-
Attachment: model1.gif
(Size: 11.73KB, Downloaded 143 times)
|
|
| | |
Goto Forum:
Current Time: Wed Apr 24 21:19:01 GMT 2024
Powered by FUDForum. Page generated in 0.03848 seconds
|