简体   繁体   中英

Xtext error: Registered resource factory is needed

I have an application that accepts a file as an input. Since the files are located in different location, the path will be relative to the .jar location.

Example: D:\\Test\\JAVA_App\\Exe is where that tester.jar is placed. So when ran in the windows command line, I do this: tester.jar D:\\Test\\JAVA_App\\Exe....\\testcase1.txt

To process the file, my code is calling ResourceSet from org.eclipse.emf.ecore.resource.ResourceSet. This is the code I have:

ResourceSet set = resourceSetProvider.get()
Resource resource = set.getResource(URI.createURI(<inputted path of file>))

I found out that the "registered resource factory is needed" error is not caused by an incorrect path (I can open it if I run the whole path in the commandline), but because of the "..\\" in between. If I use "....\\testcase1.txt" only, it works fine. But if it has the "D:\\" in the beginning with "..\\" in between, the error occurs.

Is there another way to use "D:\\Test\\JAVA_App\\Exe....\\testcase1.txt" in xtext?

I guess that the D: is interpreted as a scheme. Try using 'URI.createFileURI()' instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM