Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL/UML Help
OCL/UML Help [message #4078] Thu, 08 February 2007 17:49 Go to next message
Andrew Carton is currently offline Andrew Carton
Messages: 104
Registered: July 2009
Senior Member
Hi,
I'm just trying to get OCL working with UML and having a few problems.
Below is the source and the exception trace that I keep getting. I'd
really appreciate it if someone could give me a quick hand. The
tutorials only illustrate Ecore metamodels and I can't find any simple
tutorials that shows you how to use queries over UML/Ecore. My uml model
is a simple one - at its root it has a Model and its packagedElements
are two packages. I thought passing in the .eClass() from the Model
element would work but it doesn't seem to. I tried this query on the OCL
console with my model and it works!

Thanks in advance,
Andrew

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xmi",
new XMIResourceFactoryImpl());


resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,UMLP ackage.eINSTANCE);

Model p = (Model) load(URI.createURI("My.uml"));
boolean valid;
EList e = p.getPackagedElements();
try {
Query query = QueryFactory.eINSTANCE.createQuery(
"self.nestedPackage->collect( e | e.packagedElement->collect(f |
f.name))",
p.eClass());
valid = true;
} catch (IllegalArgumentException s) {
valid = false;
System.err.println(s.getLocalizedMessage());
}


Exception in thread "main" java.lang.NoClassDefFoundError:
lpg/lpgjavaruntime/RuleAction
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at
org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createP arser(ExpressionsUtil.java:680)
at
org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createP arser(ExpressionsUtil.java:663)
at
org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createQ uery(ExpressionsUtil.java:177)
at
org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createQ uery(ExpressionsUtil.java:156)
at org.eclipse.emf.ocl.query.impl.QueryUtil.makeOCLQuery(QueryU til.java:66)
at
org.eclipse.emf.ocl.query.impl.QueryFactoryImpl.createQuery( QueryFactoryImpl.java:127)
at PackageMerge.main(PackageMerge.java:98)
Re: OCL/UML Help [message #4166 is a reply to message #4078] Fri, 09 February 2007 07:15 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Andew,

It sounds like you are running standalone but haven't put the
net.sourceforge.lpg.lpgjavaruntime jar on the classpath.


Andrew Carton wrote:
>
> Hi,
> I'm just trying to get OCL working with UML and having a few problems.
> Below is the source and the exception trace that I keep getting. I'd
> really appreciate it if someone could give me a quick hand. The
> tutorials only illustrate Ecore metamodels and I can't find any simple
> tutorials that shows you how to use queries over UML/Ecore. My uml
> model is a simple one - at its root it has a Model and its
> packagedElements are two packages. I thought passing in the .eClass()
> from the Model element would work but it doesn't seem to. I tried this
> query on the OCL console with my model and it works!
>
> Thanks in advance,
> Andrew
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xmi",
> new XMIResourceFactoryImpl());
>
>
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,UMLP ackage.eINSTANCE);
>
>
> Model p = (Model) load(URI.createURI("My.uml"));
> boolean valid;
> EList e = p.getPackagedElements();
> try {
> Query query = QueryFactory.eINSTANCE.createQuery(
> "self.nestedPackage->collect( e | e.packagedElement->collect(f |
> f.name))",
> p.eClass());
> valid = true;
> } catch (IllegalArgumentException s) {
> valid = false;
> System.err.println(s.getLocalizedMessage());
> }
>
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> lpg/lpgjavaruntime/RuleAction
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.access$000(Unknown Source)
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> at
> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createP arser(ExpressionsUtil.java:680)
>
> at
> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createP arser(ExpressionsUtil.java:663)
>
> at
> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createQ uery(ExpressionsUtil.java:177)
>
> at
> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createQ uery(ExpressionsUtil.java:156)
>
> at
> org.eclipse.emf.ocl.query.impl.QueryUtil.makeOCLQuery(QueryU til.java:66)
> at
> org.eclipse.emf.ocl.query.impl.QueryFactoryImpl.createQuery( QueryFactoryImpl.java:127)
>
> at PackageMerge.main(PackageMerge.java:98)
Re: OCL/UML Help [message #4307 is a reply to message #4166] Fri, 09 February 2007 17:24 Go to previous message
Andrew Carton is currently offline Andrew Carton
Messages: 104
Registered: July 2009
Senior Member
Thanks very much Ed!

Ed Merks wrote:
> Andew,
>
> It sounds like you are running standalone but haven't put the
> net.sourceforge.lpg.lpgjavaruntime jar on the classpath.
>
>
> Andrew Carton wrote:
>>
>> Hi,
>> I'm just trying to get OCL working with UML and having a few problems.
>> Below is the source and the exception trace that I keep getting. I'd
>> really appreciate it if someone could give me a quick hand. The
>> tutorials only illustrate Ecore metamodels and I can't find any simple
>> tutorials that shows you how to use queries over UML/Ecore. My uml
>> model is a simple one - at its root it has a Model and its
>> packagedElements are two packages. I thought passing in the .eClass()
>> from the Model element would work but it doesn't seem to. I tried this
>> query on the OCL console with my model and it works!
>>
>> Thanks in advance,
>> Andrew
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xmi",
>> new XMIResourceFactoryImpl());
>>
>>
>> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,UMLP ackage.eINSTANCE);
>>
>>
>> Model p = (Model) load(URI.createURI("My.uml"));
>> boolean valid;
>> EList e = p.getPackagedElements();
>> try {
>> Query query = QueryFactory.eINSTANCE.createQuery(
>> "self.nestedPackage->collect( e | e.packagedElement->collect(f |
>> f.name))",
>> p.eClass());
>> valid = true;
>> } catch (IllegalArgumentException s) {
>> valid = false;
>> System.err.println(s.getLocalizedMessage());
>> }
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> lpg/lpgjavaruntime/RuleAction
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(Unknown Source)
>> at java.security.SecureClassLoader.defineClass(Unknown Source)
>> at java.net.URLClassLoader.defineClass(Unknown Source)
>> at java.net.URLClassLoader.access$000(Unknown Source)
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>> at
>> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createP arser(ExpressionsUtil.java:680)
>>
>> at
>> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createP arser(ExpressionsUtil.java:663)
>>
>> at
>> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createQ uery(ExpressionsUtil.java:177)
>>
>> at
>> org.eclipse.emf.ocl.expressions.util.ExpressionsUtil.createQ uery(ExpressionsUtil.java:156)
>>
>> at
>> org.eclipse.emf.ocl.query.impl.QueryUtil.makeOCLQuery(QueryU til.java:66)
>> at
>> org.eclipse.emf.ocl.query.impl.QueryFactoryImpl.createQuery( QueryFactoryImpl.java:127)
>>
>> at PackageMerge.main(PackageMerge.java:98)
Previous Topic:[Announce] MDT OCL 1.1.0 I200702081544 is available
Next Topic:OCL fan-in & fan-out
Goto Forum:
  


Current Time: Tue Jul 29 07:01:58 EDT 2014

Powered by FUDForum. Page generated in 0.02180 seconds