Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » arrayIndexOutOfBound Exception with ResourceSet.getResource(My model loader throws and exception when I'm trying to read a uml model)
arrayIndexOutOfBound Exception with ResourceSet.getResource [message #1834802] Wed, 18 November 2020 09:19 Go to next message
Hira Naveed is currently offline Hira NaveedFriend
Messages: 1
Registered: November 2020
Junior Member
Code:
public class ModelLoader {
private final ResourceSet RESOURCE_SET;
public ModelLoader() {
RESOURCE_SET = new ResourceSetImpl();
}

public Object loadModel(String uri){
URI modelUri = URI.createURI(uri);
registerPackages(RESOURCE_SET);
registerResourceFactories();
String relPath = null;
try {
relPath = new File(".").getCanonicalPath();
} catch (IOException e1) {
e1.printStackTrace();
}
URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/"),
URI.createURI("jar:file:"+relPath+"/EMF_Lib/org.eclipse.uml2.uml_5.5.0.v20181203-1331.jar!/"));
Resource resource = null;
try {
resource = RESOURCE_SET.getResource(modelUri, true); //ERROR occurs here

}
catch (Exception e) {
e.printStackTrace();
}

//some code

return result;
}

public class UMLClassDiagramReader {
ModelLoader umlModel = new ModelLoader();

String uri = null;
try {
uri = umlModel.getFileURI(umlFilePath);
} catch (Exception e) {
e.printStackTrace();
}
//other code to read class
}

Added a uml file I'm trying to read

Stack Trace
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 4
at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:354)
at org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.createObject(UML22UMLHandler.java:57)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1813)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1023)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:87)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:169)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:518)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1406)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2725)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:541)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1511)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1290)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
at mdse.emf.util.ModelLoader.loadModel(ModelLoader.java:67)
at mdse.emf.main.UMLClassDiagramReader.ReadClassDiagram(UMLClassDiagramReader.java:50)
at mdse.emf.main.UMLObjectDiagramCreator.objectDiagramCreator(UMLObjectDiagramCreator.java:39)
at mdse.emf.main.Runner$1.run(Runner.java:19)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
  • Attachment: Package.uml
    (Size: 1.18KB, Downloaded 15 times)
Re: arrayIndexOutOfBound Exception with ResourceSet.getResource [message #1834825 is a reply to message #1834802] Wed, 18 November 2020 16:12 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31849
Registered: July 2009
Senior Member
The code here rg.eclipse.uml2.uml.internal.resource.UML22UMLHandler.createObject(UML22UMLHandler.java:57) is not provided by EMF so I can't comment on what's going on here.

It's probably better to ask on the UML2 forum:

https://www.eclipse.org/forums/index.php?t=thread&frm_id=117


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Some observations after upgrading to the current integration build
Next Topic:Parsing of xml with xs:any element with different namespaces
Goto Forum:
  


Current Time: Fri Apr 23 15:28:54 GMT 2021

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

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

Back to the top