Home » Modeling » UML2 » Applying stereotype to property as association end throws IllegalArgumentException
Applying stereotype to property as association end throws IllegalArgumentException [message #896064] |
Tue, 17 July 2012 03:02  |
Eclipse User |
|
|
|
I have a problem in an M2M-transformation with ATL, but I think this is more a UML2 specific problem, so I decided to post my question here.
I want to apply a stereotype which is defined for UML-Property to a property used in an association. The problem I have is that an IllegalArgumentException is thrown in the case of using the stereotype for an association-associated property. If I apply the stereotype to an property which is used in a class as an attribute everything is fine.
Here is a code snippet from the exception throwing part:
-- ...
p1: UML!Property(
upper <-a.associationEnds.first().conformance.upperBound,
lower <- a.associationEnds.first().conformance.lowerBound,
name <- a.associationEnds.first().name,
type <- firstMemberType,
opposite <- p2,
isComposite <- true
),
p2: UML!Property(
upper <-a.associationEnds.last().conformance.upperBound,
lower <- a.associationEnds.last().conformance.lowerBound,
name <- a.associationEnds.last().name,
type <- secondMemberType,
opposite <- p1
),
as:UML!Association(
name <- a.name,
ownedEnd <- Set{p2}
navigableOwnedEnd <- Set{p1}
)
do {
p1.applyStereotype(thisModule.getStereotype('xsdElement')); -- here an exception is thrown: see below
}
The following IllegalArgumentException is thrown.
Here appear some other resulting stacktraces.
......
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@21ee05 (name: xsdElement, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1413)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)
... 18 more
It seems like that p1 is not a property any longer. Anyone an idea? Would be great. thanks,
Martin
EDIT: I've missed to mention that I use UML=http://www.eclipse.org/uml2/3.0.0/UML.
|
|
|
Re: Applying stereotype to property as association end throws IllegalArgumentException [message #896072 is a reply to message #896064] |
Tue, 17 July 2012 03:18   |
Eclipse User |
|
|
|
Hi
This looks like an ATL/ATL-user problem. UML provides APIs and it
appears that they are not being used correctly.
I've never understood ATL semantics so I cannot comment on the validity
of your p1 or getStereotype() usage; both are potentially suspect.
I suggest using the debugger, though if you're lucky someone on the ATL
newsgroup might rexcognise the problem.
Regards
Ed Willink
On 17/07/2012 08:02, Martin Benedict wrote:
> I have a problem in an M2M-transformation with ATL, but I think this
> is more a UML2 specific problem, so I decided to post my question here.
>
> I want to apply a stereotype which is defined for UML-Property to a
> property used in an association. The problem I have is that an
> IllegalArgumentException is thrown in the case of using the stereotype
> for an association-associated property. If I apply the stereotype to
> an property which is used in a class as an attribute everything is fine.
> Here is a code snippet from the exception throwing part:
>
>
>
> -- ...
> p1: UML!Property(
>
> upper <-a.associationEnds.first().conformance.upperBound,
> lower <- a.associationEnds.first().conformance.lowerBound,
> name <- a.associationEnds.first().name,
> type <- firstMemberType,
> opposite <- p2,
> isComposite <- true
> ),
>
> p2: UML!Property(
>
> upper <-a.associationEnds.last().conformance.upperBound,
> lower <- a.associationEnds.last().conformance.lowerBound,
> name <- a.associationEnds.last().name,
> type <- secondMemberType,
> opposite <- p1
> ),
>
> as:UML!Association(
> name <- a.name,
> ownedEnd <- Set{p2}
> navigableOwnedEnd <- Set{p1}
> )
> do {
> p1.applyStereotype(thisModule.getStereotype('xsdElement')); -- here an
> exception is thrown: see below
> }
>
>
> The following IllegalArgumentException is thrown.
>
>
>
> Here appear some other resulting stacktraces.
> ......
>
> Caused by: java.lang.IllegalArgumentException:
> org.eclipse.uml2.uml.internal.impl.StereotypeImpl@21ee05 (name:
> xsdElement, visibility: <unset>) (isLeaf: false, isAbstract: false)
> (isActive: false)
> at
> org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1413)
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)
> ... 18 more
>
>
> It seems like that p1 is not a property any longer. Anyone an idea?
> Would be great. thanks,
> Martin
>
> EDIT: I've missed to mention that I use
> UML=http://www.eclipse.org/uml2/3.0.0/UML.
|
|
| | | | | | | | | | | | |
Re: Applying stereotype to property as association end throws IllegalArgumentException [message #991105 is a reply to message #990670] |
Mon, 17 December 2012 06:38   |
Eclipse User |
|
|
|
Dear all,
to solve the problem you have to initialize resourseSet without calling UMLResourcesUtil.init but with this code:
String JAR_FILE_ECLIPSE_UML2_UML_RESOURCES = "jar:file:C:/org.eclipse.uml2.uml.resources_4.0.1.v20120913-1441.jar!/";
File test = new File(JAR_FILE_ECLIPSE_UML2_UML_RESOURCES.substring(9,JAR_FILE_ECLIPSE_UML2_UML_RESOURCES.length()-2)).getAbsoluteFile();
if (!test.exists()){
throw new NullPointerException("JAR_FILE_ECLIPSE_UML2_UML_RESOURCES PATH ERROR, "+test.toString()+"not found!");
}
_resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
_resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,UMLResource.Factory.INSTANCE);
Map<URI, URI> _resourceSetURIMap = _resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(JAR_FILE_ECLIPSE_UML2_UML_RESOURCES);
_resourceSetURIMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
_resourceSetURIMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
_resourceSetURIMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
Obviously you have to modify String "C:/org.eclipse.uml2.uml.resources_4.0.1.v20120913-1441.jar" with the path of your org.eclipse.uml2.uml.resources.*.jar file.
Federico solved in this way, let me know if anyone has problems.
Thanks also to Mauro Faella that found the solution.
Dario Imparato
|
|
| | | | |
Goto Forum:
Current Time: Wed Jul 23 17:35:08 EDT 2025
Powered by FUDForum. Page generated in 0.06485 seconds
|