Home » Modeling » UML2 » java.lang.IllegalArgumentException at applyStereotype
java.lang.IllegalArgumentException at applyStereotype [message #473273] |
Fri, 22 June 2007 14:27  |
Eclipse User |
|
|
|
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
|
|
|
Re: java.lang.IllegalArgumentException at applyStereotype [message #473274 is a reply to message #473273] |
Fri, 22 June 2007 16:03  |
Eclipse User |
|
|
|
Hi Andrew,
It looks like you are using 2.0.3 to open up a profile saved with 2.1, you
might want to upgrade to 2.1.
From the code it looks like one of 3 things could be hapening ..
either ...
1. the definition can't be found ( the ecore representation kept under an
annotation at the root of the profile) or
2. the extension wasn't set properly or is inappropriate or
3. the stereotype has already been applied.
I would have to look at the complete profile to narrow down what is going
on.
You might want to set a breakpoint in the
ElementOperations#applyStereotype() to pinpoint the problem.
Cheers,
- James.
"Andrew Jackson" <Andrew.Jackson@cs.tcd.ie> wrote in message
news:70b14299c90eedd7ddb3a2a4cd9058d8$1@www.eclipse.org...
> 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(E
lementOperations.java:1410)
> at
>
org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereoty pe(ElementImpl.j
ava: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
>
|
|
|
Re: java.lang.IllegalArgumentException at applyStereotype [message #621888 is a reply to message #473273] |
Fri, 22 June 2007 16:03  |
Eclipse User |
|
|
|
Hi Andrew,
It looks like you are using 2.0.3 to open up a profile saved with 2.1, you
might want to upgrade to 2.1.
From the code it looks like one of 3 things could be hapening ..
either ...
1. the definition can't be found ( the ecore representation kept under an
annotation at the root of the profile) or
2. the extension wasn't set properly or is inappropriate or
3. the stereotype has already been applied.
I would have to look at the complete profile to narrow down what is going
on.
You might want to set a breakpoint in the
ElementOperations#applyStereotype() to pinpoint the problem.
Cheers,
- James.
"Andrew Jackson" <Andrew.Jackson@cs.tcd.ie> wrote in message
news:70b14299c90eedd7ddb3a2a4cd9058d8$1@www.eclipse.org...
> 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(E
lementOperations.java:1410)
> at
>
org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereoty pe(ElementImpl.j
ava: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
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 08:42:03 EDT 2025
Powered by FUDForum. Page generated in 0.07538 seconds
|