Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » java.lang.IllegalArgumentException at applyStereotype
java.lang.IllegalArgumentException at applyStereotype [message #621886] Fri, 22 June 2007 18:27
Andrew Jackson is currently offline Andrew JacksonFriend
Messages: 24
Registered: July 2009
Junior Member
Hi,

I am new to UML2 so please forgive the newbie question.

When i try to apply a stereotype to a package i get the follwing exception
and trace.

Exception in thread "main" java.lang.IllegalArgumentException:
org.eclipse.uml2.uml.internal.impl.StereotypeImpl@ec12f3 (name: theme,
visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
false) (isActive: false, isAbstract: false)
at
org.eclipse.uml2.uml.internal.operations.ElementOperations.a pplyStereotype(ElementOperations.java:1410)
at
org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereoty pe(ElementImpl.java:500)
at uml_gen.AHHHH.main(AHHHH.java:26)


The code that is triggering this is as follows:

public class AHHHH {

public static void main(String [] args)
{
Model model = null;
Profile themeUMLProfile = null;
themeUMLProfile = (Profile)
FileManager.getInstance().load(URI.createURI("./model/ThemeUML.profile.uml "));
model = UMLFactory.eINSTANCE.createModel();

model.applyProfile(themeUMLProfile);
model.setName("MyModel");
Stereotype themeStereotype = themeUMLProfile.getOwnedStereotype("theme");


Package themePackage = (Package) model.createNestedPackage("package1");
themePackage.applyStereotype(themeStereotype);
}

}

public class FileManager {
private static final ResourceSet resourceSet = new ResourceSetImpl();
private static FileManager instance = null;

public static FileManager getInstance() {
if (instance == null)
instance = new FileManager();
return instance;
}

protected static void registerPathmaps(URI uri) {
URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_LIBRARIES/"), uri
.appendSegment("libraries").appendSegment(""));
URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_METAMODELS/"),
uri.appendSegment("metamodels").appendSegment(""));
URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_PROFILES/"), uri
.appendSegment("profiles").appendSegment(""));
}

private FileManager() {

// This stuff only must happen once
// Make it a singleton?
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,
UMLPackage.eINSTANCE);

}

org.eclipse.uml2.uml.Package load(URI uri) {
registerPathmaps(URI
.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml.resource s_2.0.3.v200702141227.jar!/ "));

org.eclipse.uml2.uml.Package package_ = null;

try {
Resource resource = resourceSet.getResource(uri, true);

package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
.getObjectByType(resource.getContents(),
UMLPackage.Literals.PACKAGE);
} catch (WrappedException we) {
System.err.println(we.getMessage());
System.exit(1);
}

return package_;
}

}

The profile that i am loading is of the follwing version
<uml:Profile xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
xmi:id="_AmOUYAquEdyJK936NUOrHg" name="ThemeUML"
metamodelReference="_AmQwoAquEdyJK936NUOrHg">

The profile also imports some external elements.

<packageImport xmi:id="_AmQwoAquEdyJK936NUOrHg" visibility="private">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
</packageImport>
<packageImport xmi:id="_AmQwoQquEdyJK936NUOrHg">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packageImport xmi:id="_AmQwogquEdyJK936NUOrHg">
<importedPackage xmi:type="uml:Model"
href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
</packageImport>


I would be very greatful if you can help. I hope i have provided you with
enough information to help me.

Thank you and best regards,
Andrew Jackson
Previous Topic:how to save a model with applied stereotypes and tag values
Next Topic:java.lang.IllegalArgumentException at applyStereotype
Goto Forum:
  


Current Time: Fri Mar 29 06:19:07 GMT 2024

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

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

Back to the top