title: Applying stereotype to property as association end throws IllegalArgumentException
body: <p>The same question I have asked at <a href="http://www.eclipse.org/forums/index.php/t/367608/" rel="nofollow">http://www.eclipse.org/forums/index.php/t/367608/</a></p>
  
  <p>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.</p>
  
  <p>Here is a code snippet from the exception throwing part:</p>
  
  <pre><code>helper def: getStereotype(name: String): UML!Stereotype =
  UML!Stereotype.allInstancesFrom('PRO') -&gt; select(p | p.name = name) -&gt; first();
  -- ...
  p1: UML!Property(
  
      upper &lt;-a.associationEnds.first().conformance.upperBound,
      lower &lt;- a.associationEnds.first().conformance.lowerBound,
      name &lt;- a.associationEnds.first().name,
      type &lt;- firstMemberType,
      opposite &lt;- p2,
      isComposite &lt;- true
  ),
  
  p2: UML!Property(
  
          upper &lt;-a.associationEnds.last().conformance.upperBound,
          lower &lt;- a.associationEnds.last().conformance.lowerBound,
          name &lt;- a.associationEnds.last().name,
          type &lt;- secondMemberType,
          opposite &lt;- p1
      ),
  
  as:UML!Association(
          name &lt;- a.name,
          ownedEnd &lt;- Set{p2}
          navigableOwnedEnd &lt;- Set{p1}
          )
      do {
  p1.applyStereotype(thisModule.getStereotype('xsdElement')); -- here an exception is thrown: see below
  }
  </code></pre>
  
  <p>The following IllegalArgumentException is thrown.</p>
  
  <pre><code>Here appear some other resulting stacktraces.
  ......
  
  Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@21ee05 (name: xsdElement, visibility: &lt;unset&gt;) (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
  </code></pre>
  
  <p>I've used <code>UML=http://www.eclipse.org/uml2/3.0.0/UML</code>.</p>
  
  <p>It seems like that p1 is not a property any longer. Anyone an idea? Would be great. thanks,
  Martin</p>
  
  <p><strong>EDIT1:</strong></p>
  
  <p>After doing some debugging, I've found that the call of the method in the flow is first successful. Until the method finalizeModel is called, everthing is fine. When the method finalizeModel in the ATL UML2ModelAdapter is called the stack trace is thrown:</p>
  
  <pre><code>Java Stack:
  org.eclipse.m2m.atl.engine.emfvm.VMException
      at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:51)
      at org.eclipse.m2m.atl.engine.emfvm.lib.ExecEnv.terminated(ExecEnv.java:2557)
      at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:210)
      at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
      at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
      at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
      at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
      at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
      at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
      at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
      at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937)
      at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.applyDelayedInvocations(UML2ModelAdapter.java:136)
      at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:49)
      ... 12 more
  Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@580b29 (name: xsdElement, visibility: &lt;unset&gt;) (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)
      ... 17 more
  </code></pre>