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 07:02 |
Martin Benedict Messages: 22 Registered: June 2012 |
Junior Member |
|
|
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 07:18 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
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 #896143 is a reply to message #896064] |
Tue, 17 July 2012 12:05 |
Martin Benedict Messages: 22 Registered: June 2012 |
Junior Member |
|
|
As suggested by Mauro I have searched for problems with my profile respectively OUT-model. I have checked out the ATL source code and done some debugging. I've analyzed the finalizeModel()-method and all called methods and the contents of the variables.
I have found that the problem was appearing because my associations were in the root package of my uml-out-model, but the profile application happend unintentionally on a subordinated package. So the stereotypes couldn't be applied to objects in the root package. I've applied the profile to the root package and everthing was working.
Thanks for any help.
Also asked and answered at: stackoverflow.com/questions/11518396/applying-stereotype-to-property-as-association-end-throws-illegalargumentexcepti/11522179#11522179
[Updated on: Tue, 17 July 2012 12:14] Report message to a moderator
|
|
| | | | | | | | | | |
Re: Applying stereotype to property as association end throws IllegalArgumentException [message #991105 is a reply to message #990670] |
Mon, 17 December 2012 11:38 |
Dario Imparato Messages: 20 Registered: August 2012 |
Junior Member |
|
|
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: Thu Sep 26 02:38:41 GMT 2024
Powered by FUDForum. Page generated in 0.05535 seconds
|