我在使用 Rational Software Architect 8.0 时遇到问题。我正在开发一个为模型提供一些额外功能的插件。我正在尝试编写单元测试以确保我的插件按预期运行。
作为其中一些测试的一部分,我需要打开一个 UML 模型(emx 格式)并对其进行一些操作。我使用com.ibm.xtools.modeler.ui.UMLModeler.openModelResource(..)
它,但它会引发一个奇怪的异常。这是代码片段:
Element root = null;
try {
root = UMLModeler.openModelResource(fileName);
} catch (IOException e) {
System.out.println("Error while opening model " + fileName + ": " + e.getMessage());
}
return root;
这是抛出的异常:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at org.eclipse.gmf.runtime.emf.core.internal.domain.MSLEditingDomain$MSLResourceSet.addURIHandlers(MSLEditingDomain.java:2282)
at org.eclipse.gmf.runtime.emf.core.internal.domain.MSLEditingDomain$MSLResourceSet.<init>(MSLEditingDomain.java:2315)
at org.eclipse.gmf.runtime.emf.core.internal.domain.MSLEditingDomain.<init>(MSLEditingDomain.java:255)
at org.eclipse.gmf.runtime.emf.core.internal.domain.MSLEditingDomain.<init>(MSLEditingDomain.java:234)
at org.eclipse.gmf.runtime.emf.core.edit.MEditingDomain.createDefaultEditingDomain(MEditingDomain.java:112)
at org.eclipse.gmf.runtime.emf.core.edit.MEditingDomain.<clinit>(MEditingDomain.java:70)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at org.eclipse.gmf.runtime.emf.core.util.ResourceUtil.findResource(ResourceUtil.java:163)
at com.ibm.xtools.modeler.ui.UMLModeler.openUMLResource(UMLModeler.java:1144)
at com.ibm.xtools.modeler.ui.UMLModeler.openModelResource(UMLModeler.java:451)
at uk.ac.open.rbacuml.dsml.plugin.research.fixing.SSoDConstraintFixingTest.loadModel(SSoDConstraintFixingTest.java:23)
at uk.ac.open.rbacuml.dsml.plugin.research.fixing.SSoDConstraintFixingTest.testSSoDConstraintFixing(SSoDConstraintFixingTest.java:32)
at uk.ac.open.rbacuml.dsml.plugin.research.fixing.SSoDConstraintFixingTest.main(SSoDConstraintFixingTest.java:17)
Caused by: java.lang.NullPointerException
at org.eclipse.gmf.runtime.common.core.util.Log.<clinit>(Log.java:42)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 14 more
我显然做错了什么,但我不知道是什么。有什么建议么?