gpt4 book ai didi

java - 资源未使用资源集

转载 作者:行者123 更新时间:2023-12-02 02:14:02 27 4
gpt4 key购买 nike

我尝试使用资源获取输入文件的输入内容。我为此编写了以下代码

val resourceSet = new AutosarResourceSetImpl();

var uri = URI.createFileURI(inputfilepath);

resource = resourceSet.getResource(uri,true)

resourceSet.resources.add(resource);

在这里,如果我将输入文件放在默认工作区以外的任何文件夹中,它就可以工作。但是如果我将输入文件放在工作区文件夹中(默认情况下它每次都会创建),我会收到以下异常。

!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)

最佳答案

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

java.lang.IllegalArgumentException: Path must include project and resource name: /inputfile.arxml

如果您想使用文件 URI(如您的示例所示),您应该具有以下内容:

var uri = URI.createFileURI("c:/path/to/inputfile.arxml");

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

顺便说一句,从资源集中获取资源后,您不需要将资源添加到资源集中...

    resource = resourceSet.getResource(uri,true)
//resourceSet.resources.add(resource);

关于java - 资源未使用资源集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49552474/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com