首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >资源未使用资源集获取

资源未使用资源集获取
EN

Stack Overflow用户
提问于 2018-03-29 17:28:44
回答 2查看 294关注 0票数 0

我尝试使用资源获取输入文件的输入内容。

代码语言:javascript
复制
val resourceSet = new AutosarResourceSetImpl();

var uri = URI.createFileURI(inputfilepath); 

resource = resourceSet.getResource(uri,true)

resourceSet.resources.add(resource);

在这里,如果我把我的输入文件放在默认工作空间之外的任何文件夹中,如果我把输入文件放在工作空间文件夹(默认情况下,每次都会创建)中,那么它就是working.But,这是我得到的以下异常。

代码语言:javascript
复制
!MESSAGE IllegalArgumentException occurred when invoking code from plug-in "org.eclipse.sphinx.emf": Path must include project and resource name: /inputfile.arxml.
!STACK 0
java.lang.IllegalArgumentException: Path must include project and resource name: /inputfile.arxml
    at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
    at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2074)
    at org.eclipse.core.internal.resources.Container.getFile(Container.java:193)
    at org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(WorkspaceSynchronizer.java:344)
    at org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(WorkspaceSynchronizer.java:273)
    at org.eclipse.sphinx.emf.util.EcorePlatformUtil.getFile(EcorePlatformUtil.java:916)
    at org.eclipse.sphinx.emf.util.EcorePlatformUtil.getFile(EcorePlatformUtil.java:902)
    at org.eclipse.sphinx.emf.resource.SphinxManagedModelFileContentHandlerImpl.canHandle(SphinxManagedModelFileContentHandlerImpl.java:55)
    at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.contentDescription(URIHandlerImpl.java:280)
    at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.contentDescription(ExtensibleURIConverterImpl.java:372)
    at org.eclipse.sphinx.emf.util.EcoreResourceUtil.getContentTypeId(EcoreResourceUtil.java:333)
    at org.eclipse.sphinx.emf.resource.ExtendedResourceSetImpl.demandCreateResource(ExtendedResourceSetImpl.java:290)
    at org.eclipse.sphinx.emf.resource.ExtendedResourceSetImpl.getResource(ExtendedResourceSetImpl.java:264)
    at com.avin.ecuc.gautosar.codegen.xtend.headless.BswCodeGenApplication.bswSearchBswModel(BswCodeGenApplication.java:127)
    at com.avin.ecuc.gautosar.codegen.xtend.headless.BswCodeGenApplication.interrogate(BswCodeGenApplication.java:684)
    at org.eclipse.sphinx.platform.cli.AbstractCLIApplication.doRun(AbstractCLIApplication.java:224)
    at org.eclipse.sphinx.platform.cli.AbstractCLIApplication.start(AbstractCLIApplication.java:182)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
!SUBENTRY 1 org.eclipse.sphinx.emf 4 0 2018-03-29 14:55:36.615
!MESSAGE Path must include project and resource name: /inputfile.arxml
!STACK 0
java.lang.IllegalArgumentException: Path must include project and resource name: /inputfile.arxml
    at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
    at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2074)
    at org.eclipse.core.internal.resources.Container.getFile(Container.java:193)
    at org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(WorkspaceSynchronizer.java:344)
    at org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile(WorkspaceSynchronizer.java:273)
    at org.eclipse.sphinx.emf.util.EcorePlatformUtil.getFile(EcorePlatformUtil.java:916)
    at org.eclipse.sphinx.emf.util.EcorePlatformUtil.getFile(EcorePlatformUtil.java:902)
    at org.eclipse.sphinx.emf.resource.SphinxManagedModelFileContentHandlerImpl.canHandle(SphinxManagedModelFileContentHandlerImpl.java:55)
    at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.contentDescription(URIHandlerImpl.java:280)
    at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.contentDescription(ExtensibleURIConverterImpl.java:372)
    at org.eclipse.sphinx.emf.util.EcoreResourceUtil.getContentTypeId(EcoreResourceUtil.java:333)
    at org.eclipse.sphinx.emf.resource.ExtendedResourceSetImpl.demandCreateResource(ExtendedResourceSetImpl.java:290)
    at org.eclipse.sphinx.emf.resource.ExtendedResourceSetImpl.getResource(ExtendedResourceSetImpl.java:264)
    at com.avin.ecuc.gautosar.codegen.xtend.headless.BswCodeGenApplication.bswSearchBswModel(BswCodeGenApplication.java:127)
    at com.avin.ecuc.gautosar.codegen.xtend.headless.BswCodeGenApplication.interrogate(BswCodeGenApplication.java:684)
    at org.eclipse.sphinx.platform.cli.AbstractCLIApplication.doRun(AbstractCLIApplication.java:224)
    at org.eclipse.sphinx.platform.cli.AbstractCLIApplication.start(AbstractCLIApplication.java:182)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
EN

回答 2

Stack Overflow用户

发布于 2018-04-24 22:44:43

阅读异常,问题可能来自您表达URI的方式。

代码语言:javascript
复制
java.lang.IllegalArgumentException: Path must include project and resource name: /inputfile.arxml

如果您想要使用File URI,如您的示例中所示,您应该具有如下内容:

代码语言:javascript
复制
var uri = URI.createFileURI("c:/path/to/inputfile.arxml");

您应该查看URI类的各种创建方法,以选择与您最相关的方法。

顺便说一句,在从resourceSet获取资源后,您不需要在resourceSet中添加资源……

代码语言:javascript
复制
    resource = resourceSet.getResource(uri,true)
    //resourceSet.resources.add(resource);
票数 2
EN

Stack Overflow用户

发布于 2018-04-16 14:43:09

您的代码使用特殊的sphinx代码,它可能会在org.eclipse.sphinx.emf.util.EcorePlatformUtil.getFile中发挥一些魔力,这取决于您获得的URL类型。它调用WorkspaceSynchronizer.getFile,后者声明它需要一个platform-resource URI

因此,正如错误消息所暗示的那样,您的URL /inputfile.arxml不遵循该方案。您需要向URL添加更具体的与工作空间相关的信息,比如遵循前面提到的平台URI模式的插件或资源

代码语言:javascript
复制
platform:/plugin/org.eclipse.mybundle/inputfile.arxml 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49552474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档