Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » runtime error when creating a simple class in a java program
runtime error when creating a simple class in a java program [message #696778] Thu, 14 July 2011 20:00 Go to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
I try to use java to create a simple class diagram. But I get some runtime error.
Here is the code:

Model myModel = UMLFactory.eINSTANCE.createModel();
//myModel.setName("MyFirstModel");
Class department = UMLFactory.eINSTANCE.createClass();
Property dept_name = UMLFactory.eINSTANCE.createProperty();

dept_name.setName("address");
dept_name.setType(department);

department.getOwnedAttributes().add(dept_name);

It seems the above setter methods dont work and neither does add. The error I got
is:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/uml2/common/util/CacheAdapter
at org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
at org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
at MyUML.main(MyUML.java:17)


Thanks.
Re: runtime error when creating a simple class in a java program [message #696817 is a reply to message #696778] Thu, 14 July 2011 21:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

Looks familiar. I suspect that you haven't replicated the Eclipse plugin
registrations for standalone usage.

You may find org.eclipse.ocl.uml.OCL.initialize(ResourceSet) helpful.

Regards

Ed Willink

On 14/07/2011 21:00, Wuwei wrote:
> I try to use java to create a simple class diagram. But I get some
> runtime error.
> Here is the code:
>
> Model myModel = UMLFactory.eINSTANCE.createModel();
> //myModel.setName("MyFirstModel");
> Class department = UMLFactory.eINSTANCE.createClass();
> Property dept_name = UMLFactory.eINSTANCE.createProperty();
>
> dept_name.setName("address");
> dept_name.setType(department);
>
> department.getOwnedAttributes().add(dept_name);
>
> It seems the above setter methods dont work and neither does add. The
> error I got
> is:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/uml2/common/util/CacheAdapter
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
> at
> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
> at MyUML.main(MyUML.java:17)
>
>
> Thanks.
>
Re: runtime error when creating a simple class in a java program [message #696818 is a reply to message #696817] Thu, 14 July 2011 21:50 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
Hi, Ed,
I don't get your idea. Can you tell me what I should do in details. What I did
is to just create a Java Project and then add those jar files to the library since
I only want to play with the UML2's implemenation. Thanks.


Edward Willink wrote on Thu, 14 July 2011 17:12
HI

Looks familiar. I suspect that you haven't replicated the Eclipse plugin
registrations for standalone usage.

You may find org.eclipse.ocl.uml.OCL.initialize(ResourceSet) helpful.

Regards

Ed Willink

On 14/07/2011 21:00, Wuwei wrote:
> I try to use java to create a simple class diagram. But I get some
> runtime error.
> Here is the code:
>
> Model myModel = UMLFactory.eINSTANCE.createModel();
> //myModel.setName("MyFirstModel");
> Class department = UMLFactory.eINSTANCE.createClass();
> Property dept_name = UMLFactory.eINSTANCE.createProperty();
>
> dept_name.setName("address");
> dept_name.setType(department);
>
> department.getOwnedAttributes().add(dept_name);
>
> It seems the above setter methods dont work and neither does add. The
> error I got
> is:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/uml2/common/util/CacheAdapter
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
> at
> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
> at MyUML.main(MyUML.java:17)
>
>
> Thanks.
>

Re: runtime error when creating a simple class in a java program [message #696833 is a reply to message #696818] Thu, 14 July 2011 22:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
In which jar is the CacheAdapter class and have you put it on your
classpath? I assume you've looked it
http://wiki.eclipse.org/MDT/UML2/FAQ too...


On 14/07/2011 2:50 PM, Wuwei wrote:
> Hi, Ed,
> I don't get your idea. Can you tell me what I should do in details.
> What I did
> is to just create a Java Project and then add those jar files to the
> library since
> I only want to play with the UML2's implemenation. Thanks.
>
>
> Edward Willink wrote on Thu, 14 July 2011 17:12
>> HI
>>
>> Looks familiar. I suspect that you haven't replicated the Eclipse
>> plugin registrations for standalone usage.
>>
>> You may find org.eclipse.ocl.uml.OCL.initialize(ResourceSet) helpful.
>>
>> Regards
>>
>> Ed Willink
>>
>> On 14/07/2011 21:00, Wuwei wrote:
>> > I try to use java to create a simple class diagram. But I get some
>> > runtime error.
>> > Here is the code:
>> >
>> > Model myModel = UMLFactory.eINSTANCE.createModel();
>> > //myModel.setName("MyFirstModel");
>> > Class department = UMLFactory.eINSTANCE.createClass();
>> > Property dept_name = UMLFactory.eINSTANCE.createProperty();
>> >
>> > dept_name.setName("address");
>> > dept_name.setType(department);
>> >
>> > department.getOwnedAttributes().add(dept_name);
>> >
>> > It seems the above setter methods dont work and neither does add.
>> The > error I got
>> > is:
>> >
>> > Exception in thread "main" java.lang.NoClassDefFoundError: >
>> org/eclipse/uml2/common/util/CacheAdapter
>> > at >
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
>> > at >
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
>> > at >
>> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
>> > at MyUML.main(MyUML.java:17)
>> >
>> >
>> > Thanks.
>> >
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: runtime error when creating a simple class in a java program [message #696834 is a reply to message #696818] Thu, 14 July 2011 22:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
In which jar is the CacheAdapter class and have you put it on your
classpath? I assume you've looked it
http://wiki.eclipse.org/MDT/UML2/FAQ too...


On 14/07/2011 2:50 PM, Wuwei wrote:
> Hi, Ed,
> I don't get your idea. Can you tell me what I should do in details.
> What I did
> is to just create a Java Project and then add those jar files to the
> library since
> I only want to play with the UML2's implemenation. Thanks.
>
>
> Edward Willink wrote on Thu, 14 July 2011 17:12
>> HI
>>
>> Looks familiar. I suspect that you haven't replicated the Eclipse
>> plugin registrations for standalone usage.
>>
>> You may find org.eclipse.ocl.uml.OCL.initialize(ResourceSet) helpful.
>>
>> Regards
>>
>> Ed Willink
>>
>> On 14/07/2011 21:00, Wuwei wrote:
>> > I try to use java to create a simple class diagram. But I get some
>> > runtime error.
>> > Here is the code:
>> >
>> > Model myModel = UMLFactory.eINSTANCE.createModel();
>> > //myModel.setName("MyFirstModel");
>> > Class department = UMLFactory.eINSTANCE.createClass();
>> > Property dept_name = UMLFactory.eINSTANCE.createProperty();
>> >
>> > dept_name.setName("address");
>> > dept_name.setType(department);
>> >
>> > department.getOwnedAttributes().add(dept_name);
>> >
>> > It seems the above setter methods dont work and neither does add.
>> The > error I got
>> > is:
>> >
>> > Exception in thread "main" java.lang.NoClassDefFoundError: >
>> org/eclipse/uml2/common/util/CacheAdapter
>> > at >
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
>> > at >
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
>> > at >
>> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
>> > at MyUML.main(MyUML.java:17)
>> >
>> >
>> > Thanks.
>> >
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: runtime error when creating a simple class in a java program [message #696865 is a reply to message #696834] Fri, 15 July 2011 01:44 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
Ed,
Sorry, how do I know which jar has CacheAdapter? I tried to read the
FAQ but not quite understand it. I think Q. 6 might be relevant to my
problem but have no idea how to solve it. Thanks.


Ed Merks wrote on Thu, 14 July 2011 18:41
In which jar is the CacheAdapter class and have you put it on your
classpath? I assume you've looked it
http://wiki.eclipse.org/MDT/UML2/FAQ too...


On 14/07/2011 2:50 PM, Wuwei wrote:
> Hi, Ed,
> I don't get your idea. Can you tell me what I should do in details.
> What I did
> is to just create a Java Project and then add those jar files to the
> library since
> I only want to play with the UML2's implemenation. Thanks.
>
>
> Edward Willink wrote on Thu, 14 July 2011 17:12
>> HI
>>
>> Looks familiar. I suspect that you haven't replicated the Eclipse
>> plugin registrations for standalone usage.
>>
>> You may find org.eclipse.ocl.uml.OCL.initialize(ResourceSet) helpful.
>>
>> Regards
>>
>> Ed Willink
>>
>> On 14/07/2011 21:00, Wuwei wrote:
>> > I try to use java to create a simple class diagram. But I get some
>> > runtime error.
>> > Here is the code:
>> >
>> > Model myModel = UMLFactory.eINSTANCE.createModel();
>> > //myModel.setName("MyFirstModel");
>> > Class department = UMLFactory.eINSTANCE.createClass();
>> > Property dept_name = UMLFactory.eINSTANCE.createProperty();
>> >
>> > dept_name.setName("address");
>> > dept_name.setType(department);
>> >
>> > department.getOwnedAttributes().add(dept_name);
>> >
>> > It seems the above setter methods dont work and neither does add.
>> The > error I got
>> > is:
>> >
>> > Exception in thread "main" java.lang.NoClassDefFoundError: >
>> org/eclipse/uml2/common/util/CacheAdapter
>> > at >
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
>> > at >
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
>> > at >
>> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
>> > at MyUML.main(MyUML.java:17)
>> >
>> >
>> > Thanks.
>> >
>
>

Re: runtime error when creating a simple class in a java program [message #696877 is a reply to message #696865] Fri, 15 July 2011 02:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ctrl-Shift-T can be very helpful for finding a class. You can use the
"Link with Editor" button in the project explorer to find out where that
file is located. I'll bet you can guess which jar it's in just from the
package name and looking at the bundle names...


On 14/07/2011 6:44 PM, Wuwei wrote:
> Ed,
> Sorry, how do I know which jar has CacheAdapter? I tried to read the
> FAQ but not quite understand it. I think Q. 6 might be relevant to my
> problem but have no idea how to solve it. Thanks.
>
>
> Ed Merks wrote on Thu, 14 July 2011 18:41
>> In which jar is the CacheAdapter class and have you put it on your
>> classpath? I assume you've looked it
>> http://wiki.eclipse.org/MDT/UML2/FAQ too...
>>
>>
>> On 14/07/2011 2:50 PM, Wuwei wrote:
>> > Hi, Ed,
>> > I don't get your idea. Can you tell me what I should do in
>> details. > What I did
>> > is to just create a Java Project and then add those jar files to
>> the > library since
>> > I only want to play with the UML2's implemenation. Thanks.
>> >
>> >
>> > Edward Willink wrote on Thu, 14 July 2011 17:12
>> >> HI
>> >>
>> >> Looks familiar. I suspect that you haven't replicated the Eclipse
>> >> plugin registrations for standalone usage.
>> >>
>> >> You may find org.eclipse.ocl.uml.OCL.initialize(ResourceSet) helpful.
>> >>
>> >> Regards
>> >>
>> >> Ed Willink
>> >>
>> >> On 14/07/2011 21:00, Wuwei wrote:
>> >> > I try to use java to create a simple class diagram. But I get
>> some >> > runtime error.
>> >> > Here is the code:
>> >> >
>> >> > Model myModel = UMLFactory.eINSTANCE.createModel();
>> >> > //myModel.setName("MyFirstModel");
>> >> > Class department = UMLFactory.eINSTANCE.createClass();
>> >> > Property dept_name = UMLFactory.eINSTANCE.createProperty();
>> >> >
>> >> > dept_name.setName("address");
>> >> > dept_name.setType(department);
>> >> >
>> >> > department.getOwnedAttributes().add(dept_name);
>> >> >
>> >> > It seems the above setter methods dont work and neither does
>> add. >> The > error I got
>> >> > is:
>> >> >
>> >> > Exception in thread "main" java.lang.NoClassDefFoundError: > >>
>> org/eclipse/uml2/common/util/CacheAdapter
>> >> > at > >>
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.getCacheAdapter(ElementImpl.java:714)
>> >> > at > >>
>> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotificationRequired(ElementImpl.java:852)
>> >> > at > >>
>> org.eclipse.uml2.uml.internal.impl.NamedElementImpl.setName(NamedElementImpl.java:263)
>> >> > at MyUML.main(MyUML.java:17)
>> >> >
>> >> >
>> >> > Thanks.
>> >> >
>> >
>> >
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:UML2 installation question
Next Topic:Fundamental question on array/list instance specifications for UML interaction call messages
Goto Forum:
  


Current Time: Fri Apr 19 20:13:20 GMT 2024

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

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

Back to the top