简体   繁体   English

Xtext错误:需要注册资源工厂

[英]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. 由于文件位于不同的位置,因此路径将相对于.jar位置。

Example: D:\\Test\\JAVA_App\\Exe is where that tester.jar is placed. 示例:D:\\ Test \\ JAVA_App \\ Exe是放置tester.jar的位置。 So when ran in the windows command line, I do this: tester.jar D:\\Test\\JAVA_App\\Exe....\\testcase1.txt 所以当在Windows命令行中运行时,我这样做: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. 为了处理文件,我的代码从org.eclipse.emf.ecore.resource.ResourceSet调用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. 如果我只使用“.... \\ testcase1.txt”,它可以正常工作。 But if it has the "D:\\" in the beginning with "..\\" in between, the error occurs. 但如果它的开头有“D:\\”,中间有“.. \\”,则会发生错误。

Is there another way to use "D:\\Test\\JAVA_App\\Exe....\\testcase1.txt" in xtext? 还有另一种方法在xtext中使用“D:\\ Test \\ JAVA_App \\ Exe .... \\ testcase1.txt”吗?

I guess that the D: is interpreted as a scheme. 我猜D:被解释为一个方案。 Try using 'URI.createFileURI()' instead. 请尝试使用'URI.createFileURI()'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载资源时出现“需要注册工厂”异常 - “Registered factory needed” exception when loading resource Java Xtext / EMF资源工厂Impl NoClassDefFoundError - Java Xtext/EMF Resource Factory Impl NoClassDefFoundError 如何从Xtext中的INode获取资源? - How to get resource from INode in Xtext? 是否允许在 Xtext 验证器中访问另一个资源? - Is it allowed to access another Resource in an Xtext validator? 在解析Xtext资源时初始化(瞬态)EAttribute - Initializing a (transient) EAttribute while parsing an Xtext resource 实体管理器工厂名称已注册 - Entity manager factory name is already registered 没有为“sql”语言注册的查询执行器工厂 - No query executer factory registered for the 'sql' language 打印xtext解析器错误的行内容 - Print line content of a xtext parser error 错误org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名称为“ dataSource”的bean时出错 - Error org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource 错误 org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名称为“entityManagerFactory”的 bean 时出错 - ERROR org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM