Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem when loading a model instance
Problem when loading a model instance [message #538754] Tue, 08 June 2010 14:46 Go to next message
Eclipse UserFriend
Originally posted by: mdsamh.yahoo.com

This is a multi-part message in MIME format.

------=_NextPart_000_002B_01CB0721.CE621240
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_002C_01CB0721.CE621240"


------=_NextPart_001_002C_01CB0721.CE621240
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

BlankHi,

=20

I am new to EMF and would appreciate your help with the following =
problem that has been annoying me for days.

=20

When trying to load a model instance (in xmi), I get: =
=91ClassNotFoundException: Class 'SimpleModel' is not found or is =
abstract. I understand that I get this error because the load() =
operation is unable to locate 'SimpleModel' EClass identified in my =
simpleMeta (below) =96 but I am not sure how to fix it?

=20

I have defined an ecore metamodel. Basically : the model has a root =
class SimpleModel and 3 other classes : ClsA, ClsB and ClsC. Each =
linked to SimpleModel through containment relation. Each class also has =
a name attribute and ClsA, in addition, has a refAAttribute that =
references ClsB (below is the top part):

=20

<?xml version=3D"1.0" encoding=3D"UTF-8"?>

<ecore:EPackage xmi:version=3D"2.0"

xmlns:xmi=3D"http://www.omg.org/XMI" =
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"

xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore" =
name=3D"simpleMeta"

nsURI=3D"http://simpleMeta/2.0" nsPrefix=3D"myPrefix">

<eClassifiers xsi:type=3D"ecore:EClass" name=3D"SimpleModel">

<eStructuralFeatures xsi:type=3D"ecore:EReference" name=3D"aes" =
upperBound=3D"-1" eType=3D"#//ClsA" containment=3D"true"/>

<eStructuralFeatures xsi:type=3D"ecore:EReference" name=3D"bes" =
upperBound=3D"-1" eType=3D"#//ClsB" containment=3D"true"/>

<eStructuralFeatures xsi:type=3D"ecore:EAttribute" name=3D"SMName" =
eType=3D"ecore:EDataType =
http://www.eclipse.org/emf/2002/Ecore#//EString"/>

<eStructuralFeatures xsi:type=3D"ecore:EReference" name=3D"ces" =
upperBound=3D"-1" eType=3D"#//ClsC" containment=3D"true"/>

</eClassifiers>

=85

=20

I used =91Create Dynamic Instance=92 in Sample Ecore Model Editor, to =
get a model instance (below) =96 .

=20

<?xml version=3D"1.0" encoding=3D"ASCII"?>

<myPrefix:SimpleModel xmi:version=3D"2.0"=20

xmlns:xmi=3D"http://www.omg.org/XMI"=20

xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"=20

xmlns:myPrefix=3D"http://simpleMeta/2.0"=20

xsi:schemaLocation=3D"http://simpleMeta/2.0=20

=
E:/ECLIPSE_/WS_eclipse_galilio/mas.emf.test.compare1/models/ simpleMeta.ec=
ore"=20

SMName=3D"simple1">

<aes CAName=3D"c1" refA=3D"//@bes.1"/>

<bes CBName=3D"b1"/>

<bes CBName=3D"b2"/>

<ces CCName=3D"c1"/>

</myPrefix:SimpleModel>

=20

Clearly, in my source model (above), I do not see a node for =
=91SimpleModel=92. But I was assuming that when using =91Create Dynamic =
Instance=92 in Sample Ecore Model Editor, I will get a well-formed model =
instance.



I am doing these steps as a set up to get EMF Compare standalone =
example to run. I get the error message at :

final EObject model1 =3D ModelUtils.load(new File(args[0]), =
resourceSet1). =20



of this program : =
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.=
compare/examples/org.eclipse.emf.compare.examples.standalone /src/org/ecli=
pse/emf/compare/examples/standalone/ExampleLauncher.java?rev ision=3D1.6&r=
oot=3DModeling_Project&view=3Dmarkup

I was advised by Laurent to post this question here.=20

=20

This is how I registered xmi resource factory in the program:


=
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "=
xmi", new XMIResourceFactoryImpl());

=20

This is how I register my meta-model:

=20

EcoreFactory ecoreFactory =3D EcoreFactory.eINSTANCE;

EPackage simpleMeta =3D ecoreFactory.createEPackage();

simpleMeta.setName("simpleMeta");

simpleMeta.setNsURI("http://simpleMeta/2.0");

Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta);

=20

Would greatly appreciate any hints as to how to fix this problem.

=20

Best regards,

=20

=20



------=_NextPart_001_002C_01CB0721.CE621240
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE id=3DridTitle>Blank</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type><BASE=20
href=3D"file://C:\Program Files\Common Files\Microsoft =
Shared\Stationery\">
<STYLE>BODY {
MARGIN-TOP: 25px; FONT-FAMILY: Arial, Helvetica; COLOR: #000000; =
MARGIN-LEFT: 25px; FONT-SIZE: 10pt
}
P.msoNormal {
MARGIN-TOP: 0px; FONT-FAMILY: Helvetica, "Times New Roman"; COLOR: =
#ffffcc; MARGIN-LEFT: 0px; FONT-SIZE: 10pt
}
LI.msoNormal {
MARGIN-TOP: 0px; FONT-FAMILY: Helvetica, "Times New Roman"; COLOR: =
#ffffcc; MARGIN-LEFT: 0px; FONT-SIZE: 10pt
}
</STYLE>

<META name=3DGENERATOR content=3D"MSHTML 8.00.6001.18904"></HEAD>
<BODY id=3DridBody =
background=3Dcid:DA25289ABAFF4EAF8E2B9EAEEFE813B0@MASCOMP=20
bgColor=3D#ffffff>
<BLOCKQUOTE style=3D"MARGIN-RIGHT: 0px" dir=3Dltr>
<DIV>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><FONT=20
color=3D#000000>Hi,<?xml:namespace prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" =
/><o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><o:p><FONT=20
color=3D#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><FONT color=3D#000000>I =
am new to=20
EMF and would appreciate your help with the following problem that has =
been=20
annoying me for days.<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><o:p><FONT=20
color=3D#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT=20
color=3D#000000><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt">When trying to=20
load a model instance (in xmi), I get: =91</SPAN><FONT =
face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt">ClassNotFoundException:=20
Class 'SimpleModel' is not found or is abstract. <SPAN=20
style=3D"mso-spacerun: yes">&nbsp;</SPAN><FONT face=3DArial>I =
understand that I=20
get this error because <TT>the</TT></FONT></SPAN><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"> </SPAN><TT><SPAN=20
style=3D"FONT-SIZE: 10pt">load()</SPAN></TT><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"> operation is unable to =
locate=20
</SPAN><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt">'SimpleModel'=20
</SPAN><SPAN class=3Ddocemphstrong><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt">EClass</SPAN></SPAN><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"> identified in my =
simpleMeta=20
(below) =96 but I am not sure how to fix =
it?</SPAN><o:p></o:p></FONT></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><o:p><FONT=20
color=3D#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><FONT color=3D#000000>I =
have defined=20
an ecore metamodel.&nbsp; Basically :<FONT color=3D#000000><FONT =
face=3DArial> the=20
model has a root class SimpleModel and 3 other classes : ClsA, ClsB =
and=20
ClsC.&nbsp; Each linked to SimpleModel through containment =
relation.&nbsp;=20
Each class also has a name attribute and ClsA, in addition, has a=20
refAAttribute that references ClsB </FONT></FONT>(below is the top=20
part):<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;?<SPAN style=3D"COLOR: black">xml</SPAN> =
version=3D"1.0"=20
encoding=3D"UTF-8"?&gt;<o:p></o:p></FONT></SPAN></P >
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;ecore:EPackage=20
xmi:version=3D"2.0"<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000><SPAN style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp;=20
</SPAN>xmlns:xmi=3D"http://www.omg.org/XMI"=20
=
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"<o:p></o:p></FONT>=
</SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000><SPAN style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp;=20
</SPAN>xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
name=3D"simpleMeta"<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000><SPAN style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp;=20
</SPAN>nsURI=3D"http://simpleMeta/2.0"=20
nsPrefix=3D"myPrefix"&gt;<o:p></o:p></FONT></SPAN> </P>
<P style=3D"MARGIN: 0in 0in 0pt -27pt; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;eClassifiers xsi:type=3D"ecore:EClass"=20
name=3D"SimpleModel"&gt;<o:p></o:p></FONT></SPAN></P >
<P style=3D"MARGIN: 0in 0in 0pt -27pt; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;eStructuralFeatures xsi:type=3D"ecore:EReference" =
name=3D"<SPAN=20
style=3D"COLOR: black">aes</SPAN>" upperBound=3D"-1" eType=3D"#//ClsA" =

containment=3D"true"/&gt;<o:p></o:p></FONT></SPAN> </P>
<P style=3D"MARGIN: 0in 0in 0pt -27pt; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;eStructuralFeatures xsi:type=3D"ecore:EReference" =
name=3D"bes"=20
upperBound=3D"-1" eType=3D"#//ClsB"=20
containment=3D"true"/&gt;<o:p></o:p></FONT></SPAN> </P>
<P style=3D"MARGIN: 0in 0in 0pt -27pt; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;eStructuralFeatures xsi:type=3D"ecore:EAttribute"=20
name=3D"SMName" eType=3D"ecore:EDataType=20
=
http://www.eclipse.org/emf/2002/Ecore#//EString"/&gt;<o:p></o:p></FONT></=
SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -27pt; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><FONT=20
color=3D#000000>&lt;eStructuralFeatures xsi:type=3D"ecore:EReference" =
name=3D"<SPAN=20
style=3D"COLOR: black">ces</SPAN>" upperBound=3D"-1" eType=3D"#//ClsC" =

containment=3D"true"/&gt;<o:p></o:p></FONT></SPAN> </P>
<P style=3D"MARGIN: 0in 0in 0pt -27pt" class=3DMsoNormal><FONT =
color=3D#000000><FONT=20
face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt">&lt;/eClassifiers&gt;</SPAN><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -27pt" class=3DMsoNormal><FONT =
color=3D#000000><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt">=85</SPAN><o:p></o:p></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><FONT color=3D#000000>I =
used =91Create=20
Dynamic Instance=92 in Sample Ecore Model Editor,&nbsp;to get a model =
instance=20
(below) =96 </FONT></SPAN><FONT color=3D#000000><FONT =
face=3DArial>.<SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT color=3D#000000>&lt;?xml version=3D"1.0"=20
encoding=3D"ASCII"?&gt;<o:p></o:p></FONT></SPAN></P >
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT color=3D#000000>&lt;myPrefix:SimpleModel =
xmi:version=3D"2.0"=20
<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT =
color=3D#000000>xmlns:xmi=3D"http://www.omg.org/XMI"=20
<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT=20
=
color=3D#000000>xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"=20
<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT =
color=3D#000000>xmlns:myPrefix=3D"http://simpleMeta/2.0"=20
<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT =
color=3D#000000>xsi:schemaLocation=3D"http://simpleMeta/2.0=20
<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT=20
=
color=3D#000000>E:/ECLIPSE_/WS_eclipse_galilio/mas.emf.test.compare1/mode=
ls/simpleMeta.ecore"=20
<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT=20
color=3D#000000>SMName=3D"simple1"&gt;<o:p></o:p></FONT ></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT color=3D#000000><SPAN style=3D"mso-spacerun: =
yes">&nbsp;=20
</SPAN>&lt;aes CAName=3D"c1" =
refA=3D"//@bes.1"/&gt;<o:p></o:p></FONT></SPAN></P >
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT color=3D#000000><SPAN style=3D"mso-spacerun: =
yes">&nbsp;=20
</SPAN>&lt;bes CBName=3D"b1"/&gt;<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT color=3D#000000><SPAN style=3D"mso-spacerun: =
yes">&nbsp;=20
</SPAN>&lt;bes CBName=3D"b2"/&gt;<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT color=3D#000000><SPAN style=3D"mso-spacerun: =
yes">&nbsp;=20
</SPAN>&lt;ces CCName=3D"c1"/&gt;<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: =
EN-GB"=20
lang=3DEN-GB><FONT=20
=
color=3D#000000>&lt;/myPrefix:SimpleModel&gt;<o:p> </o:p></FONT></SPAN></P=
>
<P style=3D"MARGIN: 0in 0in 0pt" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT=20
color=3D#000000><FONT face=3DArial>Clearly, in my source model =
(above), I do not=20
see a node for =91SimpleModel=92. <SPAN style=3D"mso-spacerun: =
yes">&nbsp;</SPAN>But=20
I was assuming that when using =91Create Dynamic Instance=92 in Sample =
Ecore Model=20
Editor, I will get a well-formed model instance.<BR=20
style=3D"mso-special-character: line-break"><BR=20
style=3D"mso-special-character: line-break"><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial>I am doing these steps as a set up to get&nbsp;EMF =
Compare=20
standalone example to run.&nbsp;&nbsp;I get the error message at =
:</FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial>final EObject model1 =3D ModelUtils.load(new =
File(args[0]),=20
resourceSet1).&nbsp;<SPAN style=3D"mso-spacerun: =
yes">&nbsp;</SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial><SPAN style=3D"mso-spacerun: =
yes"></SPAN></FONT>&nbsp;</P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial><SPAN style=3D"mso-spacerun: yes">of this program : <A=20
=
href=3D" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .ecli=
pse.emf.compare/examples/org.eclipse.emf.compare.examples.st andalone/src/=
org/eclipse/emf/compare/examples/standalone/ExampleLauncher. java?revision=
=3D1.6&amp;root=3DModeling_Project&amp;view=3Dmarkup ">http://dev.eclipse.=
org/viewcvs/index.cgi/org.eclipse.emf/org.eclipse.emf.compar e/examples/or=
g.eclipse.emf.compare.examples.standalone/src/org/eclipse/em f/compare/exa=
mples/standalone/ExampleLauncher.java?revision=3D1.6&amp ;root=3DModeling_=
Project&amp;view=3Dmarkup</A></SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial>I was advised by Laurent to post this question here. =
</FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial>This is how I registered xmi resource factory in the=20
program:</FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><BR><FONT =
color=3D#000000=20
=
face=3DArial> resourceSet.getResourceFactoryRegistry().getExtensionToFacto =
ryMap().put("xmi",=20
new XMIResourceFactoryImpl());</FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
color=3D#000000=20
face=3DArial>This is how I register my meta-model:</FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><FONT face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">EcoreFactory=20
ecoreFactory =3D EcoreFactory.</SPAN><I><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: #0000c0; FONT-SIZE: =
10pt">eINSTANCE</SPAN></I><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">;</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><FONT face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">EPackage=20
simpleMeta =3D ecoreFactory.createEPackage();</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><FONT face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">simpleMeta.setName(</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: #2a00ff; FONT-SIZE: =
10pt">"simpleMeta"</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">);</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in; mso-layout-grid-align: none"=20
class=3DMsoNormal><FONT face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">simpleMeta.setNsURI(</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: #2a00ff; FONT-SIZE: =
10pt">"http://simpleMeta/2.0"</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">);</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt"><o:p></o:p></SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT =
face=3DArial><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">Registry.</SPAN><I><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: #0000c0; FONT-SIZE: =
10pt">INSTANCE</SPAN></I><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">.put(</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: #2a00ff; FONT-SIZE: =
10pt">"http://simpleMeta/2.0"</SPAN><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: =
10pt">,simpleMeta);</SPAN></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><o:p><FONT=20
color=3D#000000>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: Arial; FONT-SIZE: 10pt"><FONT =
color=3D#000000>Would greatly=20
appreciate any hints as to how to fix this=20
problem.<o:p></o:p></FONT></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><SPAN=20
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></SPAN></P>
<P style=3D"MARGIN: 0in 0in 0pt -0.5in" class=3DMsoNormal><FONT=20
color=3D#000000><SPAN style=3D"FONT-FAMILY: Arial; FONT-SIZE: =
10pt">Best=20
regards,</SPAN><o:p></o:p></FONT></P>
<P style=3D"MARGIN: 0in 0in 0pt" class=3DMsoNormal><o:p><FONT =
color=3D#000000=20
face=3DArial>&nbsp;</FONT></o:p></P>
<P style=3D"MARGIN: 0in 0in 0pt" class=3DMsoNormal><o:p><FONT =
color=3D#000000 size=3D3=20
face=3D"Times New Roman">&nbsp;</FONT></o:p></P></DIV>
<P>&nbsp;</P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_001_002C_01CB0721.CE621240--

------=_NextPart_000_002B_01CB0721.CE621240
Content-Type: image/gif;
name="Blank Bkgrd.gif"
Content-Transfer-Encoding: base64
Content-ID: <DA25289ABAFF4EAF8E2B9EAEEFE813B0@MASCOMP>

R0lGODlhLQAtAID/AP////f39ywAAAAALQAtAEACcAxup8vtvxKQsFon6d02 898pGkgiYoCm6sq2
7iqWcmzOsmeXeA7uPJd5CYdD2g9oPF58ygqz+XhCG9JpJGmlYrPXGlfr/Yo/ VW45e7amp2tou/lW
xo/zX513z+Vt+1n/tiX2pxP4NUhy2FM4xtjIUQAAOw==

------=_NextPart_000_002B_01CB0721.CE621240--
Re: Problem when loading a model instance [message #538790 is a reply to message #538754] Tue, 08 June 2010 15:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050203040905030309010505
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit

Medo,

Comments below.

medo samh wrote:
>
> Hi,
>
>
>
> I am new to EMF and would appreciate your help with the following
> problem that has been annoying me for days.
>
>
>
> When trying to load a model instance (in xmi), I get:
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem when loading a model instance [message #539074 is a reply to message #538790] Wed, 09 June 2010 14:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mdsamh.yahoo.com

BlankHi,



Thanks for your reply.



Although I got a more sensible URI by instantiating my metamodel
programmatically, I still get the same error of : ClassNotFoundException:
Class 'SimpleModel' is not found or is abstract.

I would really appreciate any help to allow solve this problem which is
bugging me for days.



I have generated a .genmodel and used the following code to instantiate my
metamodel and persisted the model instance:




//creating a model instance

SimpleModel aSimpleModel = SimpleMetaFactory.eINSTANCE.createSimpleModel();

aSimpleModel.setSMName("smNew");



ClsA aClsA = SimpleMetaFactory.eINSTANCE.createClsA();

aClsA.setCAName("a1");



ClsB aClsB = SimpleMetaFactory.eINSTANCE.createClsB();

aClsB.setCBName("b1");



ClsB a1ClsB = SimpleMetaFactory.eINSTANCE.createClsB();

a1ClsB.setCBName("b2");

aClsA.getRefA().add(a1ClsB);



aSimpleModel.getAes().add(aClsA);

aSimpleModel.getBes().add(aClsB);

aSimpleModel.getBes().add(a1ClsB);





//registering the metamodel

EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;

EPackage simpleMeta = ecoreFactory.createEPackage();

simpleMeta.setName("simpleMeta");

simpleMeta.setNsURI("http://simpleMeta/2.0");

Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta);





//Persisting the model.

ResourceSet resourceSet = new ResourceSetImpl();

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
new XMIResourceFactoryImpl());

URI fileURI = URI.createFileURI(new
File("C:/tmp/mySM_New1.xmi").getAbsolutePath());

Resource smResource = resourceSet.createResource(fileURI);
smResource.getContents().add(aSimpleModel);

try {

smResource.save(null);

} catch (IOException e) {

e.printStackTrace();

}



This code gave me the following model instance:



<?xml version="1.0" encoding="ASCII"?>

<myPrefix:SimpleModel xmi:version="2.0"

xmlns:xmi="http://www.omg.org/XMI"

xmlns:myPrefix="http://simpleMeta/2.0" SMName="smNew">

<aes CAName="a1" refA="//@bes.1"/>

<bes CBName="b1"/>

<bes CBName="b2"/>

</myPrefix:SimpleModel>



Which is supposed to be an instantiation of this metamodel:



<?xml version="1.0" encoding="UTF-8"?>

<ecore:EPackage xmi:version="2.0"

xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="simpleMeta"

nsURI="http://simpleMeta/2.0" nsPrefix="myPrefix">

<eClassifiers xsi:type="ecore:EClass" name="SimpleModel">

<eStructuralFeatures xsi:type="ecore:EReference" name="aes"
upperBound="-1" eType="#//ClsA"

containment="true"/>

<eStructuralFeatures xsi:type="ecore:EReference" name="bes"
upperBound="-1" eType="#//ClsB"

containment="true"/>

<eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>

<eStructuralFeatures xsi:type="ecore:EReference" name="ces"
upperBound="-1" eType="#//ClsC"

containment="true"/>

</eClassifiers>

<eClassifiers xsi:type="ecore:EClass" name="ClsA">

<eStructuralFeatures xsi:type="ecore:EAttribute" name="CAName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>

<eStructuralFeatures xsi:type="ecore:EReference" name="refA"
upperBound="-1" eType="#//ClsB"/>

</eClassifiers>

<eClassifiers xsi:type="ecore:EClass" name="ClsB">

<eStructuralFeatures xsi:type="ecore:EAttribute" name="CBName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>

</eClassifiers>

<eClassifiers xsi:type="ecore:EClass" name="ClsC">

<eStructuralFeatures xsi:type="ecore:EAttribute" name="CCName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>

</eClassifiers>

</ecore:EPackage>



But the load keeps failing, giving me the ClassNotFoundException



Sorry for this beginner question. Any help or advice is highly appreciated.



Regards,




















"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:hulp50$dck$1@build.eclipse.org...
Medo,

Comments below.

medo samh wrote:
Hi,

I am new to EMF and would appreciate your help with the following problem
that has been annoying me for days.

When trying to load a model instance (in xmi), I get:
Re: Problem when loading a model instance [message #539154 is a reply to message #539074] Wed, 09 June 2010 19:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Medo,

Comments below.

medo samh wrote:
> BlankHi,
>
>
>
> Thanks for your reply.
>
>
>
> Although I got a more sensible URI by instantiating my metamodel
> programmatically, I still get the same error of : ClassNotFoundException:
> Class 'SimpleModel' is not found or is abstract.
>
> I would really appreciate any help to allow solve this problem which is
> bugging me for days.
>
>
>
> I have generated a .genmodel and used the following code to instantiate my
> metamodel and persisted the model instance:
>
>
>
>
> //creating a model instance
>
> SimpleModel aSimpleModel = SimpleMetaFactory.eINSTANCE.createSimpleModel();
>
> aSimpleModel.setSMName("smNew");
>
>
>
> ClsA aClsA = SimpleMetaFactory.eINSTANCE.createClsA();
>
> aClsA.setCAName("a1");
>
>
>
> ClsB aClsB = SimpleMetaFactory.eINSTANCE.createClsB();
>
> aClsB.setCBName("b1");
>
>
>
> ClsB a1ClsB = SimpleMetaFactory.eINSTANCE.createClsB();
>
> a1ClsB.setCBName("b2");
>
> aClsA.getRefA().add(a1ClsB);
>
>
>
> aSimpleModel.getAes().add(aClsA);
>
> aSimpleModel.getBes().add(aClsB);
>
> aSimpleModel.getBes().add(a1ClsB);
>
>
>
>
>
> //registering the metamodel
>
> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
>
> EPackage simpleMeta = ecoreFactory.createEPackage();
>
> simpleMeta.setName("simpleMeta");
>
> simpleMeta.setNsURI("http://simpleMeta/2.0");
>
> Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta);
>
Why are you registering an empty package rather than
SimpleMetaPackage.eINSTANCE?
>
>
>
>
> //Persisting the model.
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
> new XMIResourceFactoryImpl());
>
> URI fileURI = URI.createFileURI(new
> File("C:/tmp/mySM_New1.xmi").getAbsolutePath());
>
> Resource smResource = resourceSet.createResource(fileURI);
> smResource.getContents().add(aSimpleModel);
>
> try {
>
> smResource.save(null);
>
> } catch (IOException e) {
>
> e.printStackTrace();
>
> }
>
>
>
> This code gave me the following model instance:
>
>
>
> <?xml version="1.0" encoding="ASCII"?>
>
> <myPrefix:SimpleModel xmi:version="2.0"
>
> xmlns:xmi="http://www.omg.org/XMI"
>
> xmlns:myPrefix="http://simpleMeta/2.0" SMName="smNew">
>
> <aes CAName="a1" refA="//@bes.1"/>
>
> <bes CBName="b1"/>
>
> <bes CBName="b2"/>
>
> </myPrefix:SimpleModel>
>
>
>
> Which is supposed to be an instantiation of this metamodel:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <ecore:EPackage xmi:version="2.0"
>
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="simpleMeta"
>
> nsURI="http://simpleMeta/2.0" nsPrefix="myPrefix">
>
> <eClassifiers xsi:type="ecore:EClass" name="SimpleModel">
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="aes"
> upperBound="-1" eType="#//ClsA"
>
> containment="true"/>
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="bes"
> upperBound="-1" eType="#//ClsB"
>
> containment="true"/>
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="ces"
> upperBound="-1" eType="#//ClsC"
>
> containment="true"/>
>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EClass" name="ClsA">
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="CAName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="refA"
> upperBound="-1" eType="#//ClsB"/>
>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EClass" name="ClsB">
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="CBName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EClass" name="ClsC">
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="CCName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>
> </eClassifiers>
>
> </ecore:EPackage>
>
>
>
> But the load keeps failing, giving me the ClassNotFoundException
>
>
>
> Sorry for this beginner question. Any help or advice is highly appreciated.
>
>
>
> Regards,
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:hulp50$dck$1@build.eclipse.org...
> Medo,
>
> Comments below.
>
> medo samh wrote:
> Hi,
>
> I am new to EMF and would appreciate your help with the following problem
> that has been annoying me for days.
>
> When trying to load a model instance (in xmi), I get:
> ‘ClassNotFoundException: Class 'SimpleModel' is not found or is abstract. I
> understand that I get this error because the load() operation is unable to
> locate 'SimpleModel' EClass identified in my simpleMeta (below) – but I am
> not sure how to fix it?
>
> I have defined an ecore metamodel. Basically : the model has a root class
> SimpleModel and 3 other classes : ClsA, ClsB and ClsC. Each linked to
> SimpleModel through containment relation. Each class also has a name
> attribute and ClsA, in addition, has a refAAttribute that references ClsB
> (below is the top part):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="simpleMeta"
> nsURI="http://simpleMeta/2.0" nsPrefix="myPrefix">
> <eClassifiers xsi:type="ecore:EClass" name="SimpleModel">
> <eStructuralFeatures xsi:type="ecore:EReference" name="aes" upperBound="-1"
> eType="#//ClsA" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="bes" upperBound="-1"
> eType="#//ClsB" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="ces" upperBound="-1"
> eType="#//ClsC" containment="true"/>
> </eClassifiers>
> …
>
> I used ‘Create Dynamic Instance’ in Sample Ecore Model Editor, to get a
> model instance (below) – .
>
> <?xml version="1.0" encoding="ASCII"?>
> <myPrefix:SimpleModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:myPrefix="http://simpleMeta/2.0"
> xsi:schemaLocation="http://simpleMeta/2.0
> E:/ECLIPSE_/WS_eclipse_galilio/mas.emf.test.compare1/models/ simpleMeta.ecore "
> This doesn't look like a good URI. I'd expect this to be a file:-based URI.
> I don't think the dynamic editor would produce this. I'd expect it to use
> " platform:/resource/mas.emf.test.compare1/models/simpleMeta.e core "
> SMName="simple1">
> <aes CAName="c1" refA="//@bes.1"/>
> <bes CBName="b1"/>
> <bes CBName="b2"/>
> <ces CCName="c1"/>
> </myPrefix:SimpleModel>
>
> Clearly, in my source model (above), I do not see a node for ‘SimpleModel’.
> But I was assuming that when using ‘Create Dynamic Instance’ in Sample Ecore
> Model Editor, I will get a well-formed model instance.
>
>
> I am doing these steps as a set up to get EMF Compare standalone example to
> run. I get the error message at :
> final EObject model1 = ModelUtils.load(new File(args[0]), resourceSet1).
>
> of this program :
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.compare/examples/org.eclipse.emf.compare.exampl es.standalone/src/org/eclipse/emf/compare/examples/standalon e/ExampleLauncher.java?revision=1.6&root=Modeling_Projec t&view=markup
> I was advised by Laurent to post this question here.
>
> This is how I registered xmi resource factory in the program:
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
> new XMIResourceFactoryImpl());
>
> This is how I register my meta-model:
>
> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
> EPackage simpleMeta = ecoreFactory.createEPackage();
> simpleMeta.setName("simpleMeta");
> simpleMeta.setNsURI("http://simpleMeta/2.0");
> Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta);
>
> Would greatly appreciate any hints as to how to fix this problem.
> I think the problem is the URIs you're using to open the resources.
>
>
> Best regards,
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem when loading a model instance [message #540198 is a reply to message #539154] Tue, 15 June 2010 10:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mdsamh.yahoo.com

Hi Ed,

I am not sure how to register an instance of my metamodel package instead of
registering an empty package. I am new to EMF and don
Re: Problem when loading a model instance [message #540259 is a reply to message #540198] Tue, 15 June 2010 13:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060802050703040203050008
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Medo,

Comments below.

medo samh wrote:
> Hi Ed,
>
> I am not sure how to register an instance of my metamodel package instead of
> registering an empty package. I am new to EMF and don't know how to do that.
> Any advice would be greatly appreciated.
>
SimpleMetaPackage.eINSTANCE.eClass() will register it as a side-effect
of initializing the package instance.
> I have done a lot of search and tried different things but all failed and I
> keep getting ClassNotFoundException: Class 'SimpleModel' is not found or is
> abstract. Where 'simpleModel' is the root element of model instance.
>
> For example, I tried:
>
> EcorePackage simpleMeta = EcorePackage.eINSTANCE;
>
> simpleMeta.setName("simpleMeta");
> simpleMeta.setNsPrefix("myPrefix");
> simpleMeta.setNsURI("http://simpleMeta/2.0");
>
You're corrupting the global EcorePackage instance. :-(
> EcorePackage simpleMeta1 = simpleMeta.eINSTANCE;
>
> Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta1);
>
> resourceSet1.getPackageRegistry().put(simpleMeta1.eNS_URI,
> simpleMeta.eINSTANCE);
> resourceSet2.getPackageRegistry().put(simpleMeta1.eNS_URI,
> simpleMeta.eINSTANCE);
>
> but this did not seem to work.
>
Invoking Generated Test Code and looking at
SimpleMetaPackageExample.java would have worked well.
> Thanks in advance for your help,
>
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:huoooq$a3b$1@build.eclipse.org...
>
>> Medo,
>>
>> Comments below.
>>
>> medo samh wrote:
>>
>>> BlankHi,
>>>
>>>
>>>
>>> Thanks for your reply.
>>>
>>>
>>>
>>> Although I got a more sensible URI by instantiating my metamodel
>>> programmatically, I still get the same error of :
>>> ClassNotFoundException: Class 'SimpleModel' is not found or is abstract.
>>>
>>> I would really appreciate any help to allow solve this problem which is
>>> bugging me for days.
>>>
>>>
>>>
>>> I have generated a .genmodel and used the following code to instantiate
>>> my metamodel and persisted the model instance:
>>>
>>>
>>>
>>>
>>> //creating a model instance
>>>
>>> SimpleModel aSimpleModel =
>>> SimpleMetaFactory.eINSTANCE.createSimpleModel();
>>>
>>> aSimpleModel.setSMName("smNew");
>>>
>>>
>>>
>>> ClsA aClsA = SimpleMetaFactory.eINSTANCE.createClsA();
>>>
>>> aClsA.setCAName("a1");
>>>
>>>
>>>
>>> ClsB aClsB = SimpleMetaFactory.eINSTANCE.createClsB();
>>>
>>> aClsB.setCBName("b1");
>>>
>>>
>>>
>>> ClsB a1ClsB = SimpleMetaFactory.eINSTANCE.createClsB();
>>>
>>> a1ClsB.setCBName("b2");
>>>
>>> aClsA.getRefA().add(a1ClsB);
>>>
>>>
>>>
>>> aSimpleModel.getAes().add(aClsA);
>>>
>>> aSimpleModel.getBes().add(aClsB);
>>>
>>> aSimpleModel.getBes().add(a1ClsB);
>>>
>>>
>>>
>>>
>>>
>>> //registering the metamodel
>>>
>>> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
>>>
>>> EPackage simpleMeta = ecoreFactory.createEPackage();
>>>
>>> simpleMeta.setName("simpleMeta");
>>>
>>> simpleMeta.setNsURI("http://simpleMeta/2.0");
>>>
>>> Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta);
>>>
>>>
>> Why are you registering an empty package rather than
>> SimpleMetaPackage.eINSTANCE?
>>
>>>
>>>
>>> //Persisting the model.
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
>>> new XMIResourceFactoryImpl());
>>>
>>> URI fileURI = URI.createFileURI(new
>>> File("C:/tmp/mySM_New1.xmi").getAbsolutePath());
>>>
>>> Resource smResource = resourceSet.createResource(fileURI);
>>> smResource.getContents().add(aSimpleModel);
>>>
>>> try {
>>>
>>> smResource.save(null);
>>>
>>> } catch (IOException e) {
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>>
>>>
>>> This code gave me the following model instance:
>>>
>>>
>>>
>>> <?xml version="1.0" encoding="ASCII"?>
>>>
>>> <myPrefix:SimpleModel xmi:version="2.0"
>>>
>>> xmlns:xmi="http://www.omg.org/XMI"
>>>
>>> xmlns:myPrefix="http://simpleMeta/2.0" SMName="smNew">
>>>
>>> <aes CAName="a1" refA="//@bes.1"/>
>>>
>>> <bes CBName="b1"/>
>>>
>>> <bes CBName="b2"/>
>>>
>>> </myPrefix:SimpleModel>
>>>
>>>
>>>
>>> Which is supposed to be an instantiation of this metamodel:
>>>
>>>
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>>
>>> <ecore:EPackage xmi:version="2.0"
>>>
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="simpleMeta"
>>>
>>> nsURI="http://simpleMeta/2.0" nsPrefix="myPrefix">
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="SimpleModel">
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="aes"
>>> upperBound="-1" eType="#//ClsA"
>>>
>>> containment="true"/>
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="bes"
>>> upperBound="-1" eType="#//ClsB"
>>>
>>> containment="true"/>
>>>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
>>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="ces"
>>> upperBound="-1" eType="#//ClsC"
>>>
>>> containment="true"/>
>>>
>>> </eClassifiers>
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="ClsA">
>>>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="CAName"
>>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="refA"
>>> upperBound="-1" eType="#//ClsB"/>
>>>
>>> </eClassifiers>
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="ClsB">
>>>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="CBName"
>>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>
>>> </eClassifiers>
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="ClsC">
>>>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="CCName"
>>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>
>>> </eClassifiers>
>>>
>>> </ecore:EPackage>
>>>
>>>
>>>
>>> But the load keeps failing, giving me the ClassNotFoundException
>>>
>>>
>>>
>>> Sorry for this beginner question. Any help or advice is highly
>>> appreciated.
>>>
>>>
>>>
>>> Regards,
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>>> news:hulp50$dck$1@build.eclipse.org...
>>> Medo,
>>>
>>> Comments below.
>>>
>>> medo samh wrote:
>>> Hi,
>>>
>>> I am new to EMF and would appreciate your help with the following problem
>>> that has been annoying me for days.
>>>
>>> When trying to load a model instance (in xmi), I get:
>>> 'ClassNotFoundException: Class 'SimpleModel' is not found or is abstract.
>>> I understand that I get this error because the load() operation is unable
>>> to locate 'SimpleModel' EClass identified in my simpleMeta (below) -- but
>>> I am not sure how to fix it?
>>>
>>> I have defined an ecore metamodel. Basically : the model has a root
>>> class SimpleModel and 3 other classes : ClsA, ClsB and ClsC. Each linked
>>> to SimpleModel through containment relation. Each class also has a name
>>> attribute and ClsA, in addition, has a refAAttribute that references ClsB
>>> (below is the top part):
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ecore:EPackage xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="simpleMeta"
>>> nsURI="http://simpleMeta/2.0" nsPrefix="myPrefix">
>>> <eClassifiers xsi:type="ecore:EClass" name="SimpleModel">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="aes"
>>> upperBound="-1" eType="#//ClsA" containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="bes"
>>> upperBound="-1" eType="#//ClsB" containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
>>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="ces"
>>> upperBound="-1" eType="#//ClsC" containment="true"/>
>>> </eClassifiers>
>>> ...
>>>
>>> I used 'Create Dynamic Instance' in Sample Ecore Model Editor, to get a
>>> model instance (below) -- .
>>>
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <myPrefix:SimpleModel xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:myPrefix="http://simpleMeta/2.0"
>>> xsi:schemaLocation="http://simpleMeta/2.0
>>> E:/ECLIPSE_/WS_eclipse_galilio/mas.emf.test.compare1/models/ simpleMeta.ecore "
>>> This doesn't look like a good URI. I'd expect this to be a file:-based
>>> URI. I don't think the dynamic editor would produce this. I'd expect it
>>> to use " platform:/resource/mas.emf.test.compare1/models/simpleMeta.e core "
>>> SMName="simple1">
>>> <aes CAName="c1" refA="//@bes.1"/>
>>> <bes CBName="b1"/>
>>> <bes CBName="b2"/>
>>> <ces CCName="c1"/>
>>> </myPrefix:SimpleModel>
>>>
>>> Clearly, in my source model (above), I do not see a node for 'SimpleModel'.
>>> But I was assuming that when using 'Create Dynamic Instance' in Sample
>>> Ecore Model Editor, I will get a well-formed model instance.
>>>
>>>
>>> I am doing these steps as a set up to get EMF Compare standalone example
>>> to run. I get the error message at :
>>> final EObject model1 = ModelUtils.load(new File(args[0]), resourceSet1).
>>>
>>> of this program :
>>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.compare/examples/org.eclipse.emf.compare.exampl es.standalone/src/org/eclipse/emf/compare/examples/standalon e/ExampleLauncher.java?revision=1.6&root=Modeling_Projec t&view=markup
>>> I was advised by Laurent to post this question here.
>>>
>>> This is how I registered xmi resource factory in the program:
>>>
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
>>> new XMIResourceFactoryImpl());
>>>
>>> This is how I register my meta-model:
>>>
>>> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
>>> EPackage simpleMeta = ecoreFactory.createEPackage();
>>> simpleMeta.setName("simpleMeta");
>>> simpleMeta.setNsURI("http://simpleMeta/2.0");
>>> Registry.INSTANCE.put("http://simpleMeta/2.0",simpleMeta);
>>>
>>> Would greatly appreciate any hints as to how to fix this problem.
>>> I think the problem is the URIs you're using to open the resources.
>>>
>>>
>>> Best regards,
>>>
>>>
>>>
>
>
>

--------------060802050703040203050008
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Medo,<br>
<br>
Comments below.<br>
<br>
medo samh wrote:
<blockquote cite="mid:hv7lu1$sch$1@build.eclipse.org" type="cite">
<pre wrap="">Hi Ed,

I am not sure how to register an instance of my metamodel package instead of
registering an empty package. I am new to EMF and don&#8217;t know how to do that.
Any advice would be greatly appreciated.
</pre>
</blockquote>
SimpleMetaPackage.eINSTANCE.eClass() will register it as a side-effect
of initializing the package instance.<br>
<blockquote cite="mid:hv7lu1$sch$1@build.eclipse.org" type="cite">
<pre wrap="">
I have done a lot of search and tried different things but all failed and I
keep getting ClassNotFoundException: Class 'SimpleModel' is not found or is
abstract. Where &#8216;simpleModel&#8217; is the root element of model instance.

For example, I tried:

EcorePackage simpleMeta = EcorePackage.eINSTANCE;

simpleMeta.setName("simpleMeta");
simpleMeta.setNsPrefix("myPrefix");
simpleMeta.setNsURI(<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>);
</pre>
</blockquote>
You're corrupting the global EcorePackage instance. :-(<br>
<blockquote cite="mid:hv7lu1$sch$1@build.eclipse.org" type="cite">
<pre wrap="">
EcorePackage simpleMeta1 = simpleMeta.eINSTANCE;

Registry.INSTANCE.put(<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>,simpleMeta1);

resourceSet1.getPackageRegistry().put(simpleMeta1.eNS_URI,
simpleMeta.eINSTANCE);
resourceSet2.getPackageRegistry().put(simpleMeta1.eNS_URI,
simpleMeta.eINSTANCE);

but this did not seem to work.
</pre>
</blockquote>
Invoking Generated Test Code and looking at
SimpleMetaPackageExample.java would have worked well.<br>
<blockquote cite="mid:hv7lu1$sch$1@build.eclipse.org" type="cite">
<pre wrap="">
Thanks in advance for your help,


"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:huoooq$a3b$1@build.eclipse.org">news:huoooq$a3b$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Medo,

Comments below.

medo samh wrote:
</pre>
<blockquote type="cite">
<pre wrap="">BlankHi,



Thanks for your reply.



Although I got a more sensible URI by instantiating my metamodel
programmatically, I still get the same error of :
ClassNotFoundException: Class 'SimpleModel' is not found or is abstract.

I would really appreciate any help to allow solve this problem which is
bugging me for days.



I have generated a .genmodel and used the following code to instantiate
my metamodel and persisted the model instance:




//creating a model instance

SimpleModel aSimpleModel =
SimpleMetaFactory.eINSTANCE.createSimpleModel();

aSimpleModel.setSMName("smNew");



ClsA aClsA = SimpleMetaFactory.eINSTANCE.createClsA();

aClsA.setCAName("a1");



ClsB aClsB = SimpleMetaFactory.eINSTANCE.createClsB();

aClsB.setCBName("b1");



ClsB a1ClsB = SimpleMetaFactory.eINSTANCE.createClsB();

a1ClsB.setCBName("b2");

aClsA.getRefA().add(a1ClsB);



aSimpleModel.getAes().add(aClsA);

aSimpleModel.getBes().add(aClsB);

aSimpleModel.getBes().add(a1ClsB);





//registering the metamodel

EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;

EPackage simpleMeta = ecoreFactory.createEPackage();

simpleMeta.setName("simpleMeta");

simpleMeta.setNsURI(<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>);

Registry.INSTANCE.put(<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>,simpleMeta);

</pre>
</blockquote>
<pre wrap="">Why are you registering an empty package rather than
SimpleMetaPackage.eINSTANCE?
</pre>
<blockquote type="cite">
<pre wrap="">


//Persisting the model.

ResourceSet resourceSet = new ResourceSetImpl();

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
new XMIResourceFactoryImpl());

URI fileURI = URI.createFileURI(new
File("C:/tmp/mySM_New1.xmi").getAbsolutePath());

Resource smResource = resourceSet.createResource(fileURI);
smResource.getContents().add(aSimpleModel);

try {

smResource.save(null);

} catch (IOException e) {

e.printStackTrace();

}



This code gave me the following model instance:



&lt;?xml version="1.0" encoding="ASCII"?&gt;

&lt;myPrefix:SimpleModel xmi:version="2.0"

xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://www.omg.org/XMI">"http://www.omg.org/XMI"</a>

xmlns:myPrefix=<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a> SMName="smNew"&gt;

&lt;aes CAName="a1" refA=<a class="moz-txt-link-rfc2396E" href="mailto://@bes.1">"//@bes.1"</a>/&gt;

&lt;bes CBName="b1"/&gt;

&lt;bes CBName="b2"/&gt;

&lt;/myPrefix:SimpleModel&gt;



Which is supposed to be an instantiation of this metamodel:



&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;ecore:EPackage xmi:version="2.0"

xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://www.omg.org/XMI">"http://www.omg.org/XMI"</a>
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>

xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a> name="simpleMeta"

nsURI=<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a> nsPrefix="myPrefix"&gt;

&lt;eClassifiers xsi:type="ecore:EClass" name="SimpleModel"&gt;

&lt;eStructuralFeatures xsi:type="ecore:EReference" name="aes"
upperBound="-1" eType="#//ClsA"

containment="true"/&gt;

&lt;eStructuralFeatures xsi:type="ecore:EReference" name="bes"
upperBound="-1" eType="#//ClsB"

containment="true"/&gt;

&lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
eType="ecore:EDataType <a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#//EString">http://www.eclipse.org/emf/2002/Ecore#//EString</a>"/&gt;

&lt;eStructuralFeatures xsi:type="ecore:EReference" name="ces"
upperBound="-1" eType="#//ClsC"

containment="true"/&gt;

&lt;/eClassifiers&gt;

&lt;eClassifiers xsi:type="ecore:EClass" name="ClsA"&gt;

&lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="CAName"
eType="ecore:EDataType <a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#//EString">http://www.eclipse.org/emf/2002/Ecore#//EString</a>"/&gt;

&lt;eStructuralFeatures xsi:type="ecore:EReference" name="refA"
upperBound="-1" eType="#//ClsB"/&gt;

&lt;/eClassifiers&gt;

&lt;eClassifiers xsi:type="ecore:EClass" name="ClsB"&gt;

&lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="CBName"
eType="ecore:EDataType <a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#//EString">http://www.eclipse.org/emf/2002/Ecore#//EString</a>"/&gt;

&lt;/eClassifiers&gt;

&lt;eClassifiers xsi:type="ecore:EClass" name="ClsC"&gt;

&lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="CCName"
eType="ecore:EDataType <a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#//EString">http://www.eclipse.org/emf/2002/Ecore#//EString</a>"/&gt;

&lt;/eClassifiers&gt;

&lt;/ecore:EPackage&gt;



But the load keeps failing, giving me the ClassNotFoundException



Sorry for this beginner question. Any help or advice is highly
appreciated.



Regards,




















"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:hulp50$dck$1@build.eclipse.org">news:hulp50$dck$1@build.eclipse.org</a>...
Medo,

Comments below.

medo samh wrote:
Hi,

I am new to EMF and would appreciate your help with the following problem
that has been annoying me for days.

When trying to load a model instance (in xmi), I get:
&#8216;ClassNotFoundException: Class 'SimpleModel' is not found or is abstract.
I understand that I get this error because the load() operation is unable
to locate 'SimpleModel' EClass identified in my simpleMeta (below) &#8211; but
I am not sure how to fix it?

I have defined an ecore metamodel. Basically : the model has a root
class SimpleModel and 3 other classes : ClsA, ClsB and ClsC. Each linked
to SimpleModel through containment relation. Each class also has a name
attribute and ClsA, in addition, has a refAAttribute that references ClsB
(below is the top part):

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;ecore:EPackage xmi:version="2.0"
xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://www.omg.org/XMI">"http://www.omg.org/XMI"</a>
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a> name="simpleMeta"
nsURI=<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a> nsPrefix="myPrefix"&gt;
&lt;eClassifiers xsi:type="ecore:EClass" name="SimpleModel"&gt;
&lt;eStructuralFeatures xsi:type="ecore:EReference" name="aes"
upperBound="-1" eType="#//ClsA" containment="true"/&gt;
&lt;eStructuralFeatures xsi:type="ecore:EReference" name="bes"
upperBound="-1" eType="#//ClsB" containment="true"/&gt;
&lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="SMName"
eType="ecore:EDataType <a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#//EString">http://www.eclipse.org/emf/2002/Ecore#//EString</a>"/&gt;
&lt;eStructuralFeatures xsi:type="ecore:EReference" name="ces"
upperBound="-1" eType="#//ClsC" containment="true"/&gt;
&lt;/eClassifiers&gt;
&#8230;

I used &#8216;Create Dynamic Instance&#8217; in Sample Ecore Model Editor, to get a
model instance (below) &#8211; .

&lt;?xml version="1.0" encoding="ASCII"?&gt;
&lt;myPrefix:SimpleModel xmi:version="2.0"
xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://www.omg.org/XMI">"http://www.omg.org/XMI"</a>
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xmlns:myPrefix=<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>
xsi:schemaLocation=<a class="moz-txt-link-rfc2396E" href=" http://simpleMeta/2.0E:/ECLIPSE_/WS_eclipse_galilio/mas.emf. test.compare1/models/simpleMeta.ecore">"http://simpleMeta/2.0
E:/ECLIPSE_/WS_eclipse_galilio/mas.emf.test.compare1/models/ simpleMeta.ecore "</a>
This doesn't look like a good URI. I'd expect this to be a <a class="moz-txt-link-freetext" href="file:-based">file:-based</a>
URI. I don't think the dynamic editor would produce this. I'd expect it
to use " platform:/resource/mas.emf.test.compare1/models/simpleMeta.e core "
SMName="simple1"&gt;
&lt;aes CAName="c1" refA=<a class="moz-txt-link-rfc2396E" href="mailto://@bes.1">"//@bes.1"</a>/&gt;
&lt;bes CBName="b1"/&gt;
&lt;bes CBName="b2"/&gt;
&lt;ces CCName="c1"/&gt;
&lt;/myPrefix:SimpleModel&gt;

Clearly, in my source model (above), I do not see a node for &#8216;SimpleModel&#8217;.
But I was assuming that when using &#8216;Create Dynamic Instance&#8217; in Sample
Ecore Model Editor, I will get a well-formed model instance.


I am doing these steps as a set up to get EMF Compare standalone example
to run. I get the error message at :
final EObject model1 = ModelUtils.load(new File(args[0]), resourceSet1).

of this program :
<a class="moz-txt-link-freetext" href=" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.compare/examples/org.eclipse.emf.compare.exampl es.standalone/src/org/eclipse/emf/compare/examples/standalon e/ExampleLauncher.java?revision=1.6&root=Modeling_Projec t&view=markup"> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.compare/examples/org.eclipse.emf.compare.exampl es.standalone/src/org/eclipse/emf/compare/examples/standalon e/ExampleLauncher.java?revision=1.6&amp;root=Modeling_Project&amp;view=markup</a>
I was advised by Laurent to post this question here.

This is how I registered xmi resource factory in the program:

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
new XMIResourceFactoryImpl());

This is how I register my meta-model:

EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
EPackage simpleMeta = ecoreFactory.createEPackage();
simpleMeta.setName("simpleMeta");
simpleMeta.setNsURI(<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>);
Registry.INSTANCE.put(<a class="moz-txt-link-rfc2396E" href="http://simpleMeta/2.0">"http://simpleMeta/2.0"</a>,simpleMeta);

Would greatly appreciate any hints as to how to fix this problem.
I think the problem is the URIs you're using to open the resources.


Best regards,


</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</body>
</html>

--------------060802050703040203050008--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF validation -- New and Noteworthy
Next Topic:java.lang.ClassCastException: java.lang.String cannot be cast to org.eclipse.emf.ecore.InternalEObje
Goto Forum:
  


Current Time: Tue Apr 23 10:58:40 GMT 2024

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

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

Back to the top