[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.emf] NEWBIE. Question. [Loading xmi]

Using the tutorial I generated 'My.library' as the instance xmi file.
I am now trying to read this file using EMF API's and it gives errors.


Here is the sample code:-
public class TestLoad {

public static void main(String args[]) {

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new
XMIResourceFactoryImpl() {

public Resource createResource(URI uri) {

XMIResource xmiResource= new XMIResourceImpl(uri);

return xmiResource;

}

});

EcorePackage pkg = EcorePackage.eINSTANCE;

ResourceSet resSet= new ResourceSetImpl();

Resource res=
resSet.getResource(URI.createFileURI("C:\\programs\\Eclipse\\eclipse\\test\\
My.library"), true);

Iterator it= res.getContents().iterator();

while (it.hasNext()) {

System.out.println("object in resource: " + (EObject) it.next());

}

}

}



It throws this exception:-

Wrapped exception

Wrapped exception

java.net.ConnectException: Connection refused: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)

at java.net.Socket.<init>(Socket.java:268)

at java.net.Socket.<init>(Socket.java:95)

at sun.net.NetworkClient.doConnect(NetworkClient.java:45)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:334)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:520)

at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)

at sun.net.www.http.HttpClient.<init>(HttpClient.java:280)

at sun.net.www.http.HttpClient.New(HttpClient.java:292)

at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:4
17)

at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:510)

at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createURLInputStream(UR
IConverterImpl.java:463)

at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createInputStream(URICo
nverterImpl.java:401)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:752)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetIm
pl.java:220)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetI
mpl.java:286)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:7
79)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.jav
a:722)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:41
9)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:346
)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:62)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:333)

at
org.eclipse.emf.ecore.xmi.impl.SAXWrapper.startElement(SAXWrapper.java:71)

at
org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.j
ava:446)

at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXML
DocumentParser.java:216)

at
org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.ja
va:594)

at
org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java
:830)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDo
cumentFragmentScannerImpl.java:748)

at
org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElem
entHook(XMLDocumentScannerImpl.java:926)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch(XMLDocumentFragmentScannerImpl.java:1523)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocume
ntFragmentScannerImpl.java:333)

at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserCo
nfiguration.java:525)

at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserCo
nfiguration.java:581)

at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)

at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:115
8)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:394)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:76)

at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:1
35)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:881)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:755)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetIm
pl.java:220)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetI
mpl.java:286)

at Tst01.main(Tst01.java:29)

Wrapped by

org.eclipse.emf.common.util.WrappedException: Connection refused: connect

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetI
mpl.java:294)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:7
79)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.jav
a:722)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:41
9)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:346
)

at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:62)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:333)

at
org.eclipse.emf.ecore.xmi.impl.SAXWrapper.startElement(SAXWrapper.java:71)

at
org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.j
ava:446)

at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXML
DocumentParser.java:216)

at
org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.ja
va:594)

at
org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java
:830)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDo
cumentFragmentScannerImpl.java:748)

at
org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElem
entHook(XMLDocumentScannerImpl.java:926)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch(XMLDocumentFragmentScannerImpl.java:1523)

at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocume
ntFragmentScannerImpl.java:333)

at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserCo
nfiguration.java:525)

at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserCo
nfiguration.java:581)

at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)

at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:115
8)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:394)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:76)

at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:1
35)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:881)

at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:755)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetIm
pl.java:220)

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetI
mpl.java:286)

at Tst01.main(Tst01.java:29)

Wrapped by

org.eclipse.emf.common.util.WrappedException: Connection refused: connect

at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetI
mpl.java:290)

at Tst01.main(Tst01.java:29)

Exception in thread "main"