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 #470230] Fri, 09 February 2007 11:23 Go to next message
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
Re: Profile with enumeration in same file as model -> ClassCastException [message #470243 is a reply to message #470230] Fri, 09 February 2007 22:02 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
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 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
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 #470265 is a reply to message #470247] Mon, 12 February 2007 09:19 Go to previous messageGo to next message
Sebastien Boucard is currently offline Sebastien BoucardFriend
Messages: 9
Registered: July 2009
Junior Member
Thanks for the quick answer.

Bug reported:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=173843

My current workaround is to call resolveForwardReferences() in UMLHandler:

protected void processTopObject(EObject object) {

// DynamicEObject -> resolve forward references
if (object instanceof DynamicValueHolder) {
handleForwardReferences();
}

super.processTopObject(object);
}

This assumes stereotype applications appear in the file after the profile,
which is true in my case.
I hope I don't break things by adding this...

Sebastien
Re: Profile with enumeration in same file as model -> ClassCastException [message #470272 is a reply to message #470265] Mon, 12 February 2007 14:51 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Sebastien,

Yes, putting profiles in the same resource as models can only work if the
profiles appear before the models. Note that the problem you are seeing
happens regardless of whether idref resolution is deferred or not - as
you've suggested, we'll need to ensure that forward references are handled
after each profile has been parsed, to ensure that their metadata has been
completed processed before potentially being used in the model that follows.

Kenn

"Sebastien Boucard" <sboucard@sodius.com> wrote in message
news:a2f9d33ce2ffef19ac73c6cb986ec29b$1@www.eclipse.org...
> Thanks for the quick answer.
>
> Bug reported:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=173843
>
> My current workaround is to call resolveForwardReferences() in UMLHandler:
> protected void processTopObject(EObject object) {
> // DynamicEObject -> resolve forward references
> if (object instanceof DynamicValueHolder) {
> handleForwardReferences();
> }
> super.processTopObject(object);
> }
>
> This assumes stereotype applications appear in the file after the profile,
> which is true in my case.
> I hope I don't break things by adding this...
>
> Sebastien
>
Re: Profile with enumeration in same file as model -> ClassCastException [message #586832 is a reply to message #470230] Fri, 09 February 2007 22:02 Go to previous message
james bruck is currently offline james bruckFriend
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 Go to previous message
james bruck is currently offline james bruckFriend
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)
Re: Profile with enumeration in same file as model -> ClassCastException [message #586859 is a reply to message #470247] Mon, 12 February 2007 09:19 Go to previous message
Sebastien Boucard is currently offline Sebastien BoucardFriend
Messages: 9
Registered: July 2009
Junior Member
Thanks for the quick answer.

Bug reported:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=173843

My current workaround is to call resolveForwardReferences() in UMLHandler:

protected void processTopObject(EObject object) {

// DynamicEObject -> resolve forward references
if (object instanceof DynamicValueHolder) {
handleForwardReferences();
}

super.processTopObject(object);
}

This assumes stereotype applications appear in the file after the profile,
which is true in my case.
I hope I don't break things by adding this...

Sebastien
Re: Profile with enumeration in same file as model -> ClassCastException [message #586889 is a reply to message #470265] Mon, 12 February 2007 14:51 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Sebastien,

Yes, putting profiles in the same resource as models can only work if the
profiles appear before the models. Note that the problem you are seeing
happens regardless of whether idref resolution is deferred or not - as
you've suggested, we'll need to ensure that forward references are handled
after each profile has been parsed, to ensure that their metadata has been
completed processed before potentially being used in the model that follows.

Kenn

"Sebastien Boucard" <sboucard@sodius.com> wrote in message
news:a2f9d33ce2ffef19ac73c6cb986ec29b$1@www.eclipse.org...
> Thanks for the quick answer.
>
> Bug reported:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=173843
>
> My current workaround is to call resolveForwardReferences() in UMLHandler:
> protected void processTopObject(EObject object) {
> // DynamicEObject -> resolve forward references
> if (object instanceof DynamicValueHolder) {
> handleForwardReferences();
> }
> super.processTopObject(object);
> }
>
> This assumes stereotype applications appear in the file after the profile,
> which is true in my case.
> I hope I don't break things by adding this...
>
> Sebastien
>
Previous Topic:[Announce] MDT UML2 2.1.0 I200702091416 is available
Next Topic:Problems with type conformance and redefinition consistency
Goto Forum:
  


Current Time: Tue Apr 16 11:42:46 GMT 2024

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

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

Back to the top