org.eclipse.xtext.resource.FileNotFoundOnClasspathException:无法在类路径上找到资源。 URI是'classpath:/../ Less.xtext'

时间:2014-04-29 05:18:31

标签: eclipse maven xtext tycho xtend

尝试对Eclipse plugin for LESS进行问题时遇到问题#210

在#208中添加了提交https://github.com/PaulVI/ow/commit/7c9db5373fcc09278e3314a7ceea616a3cd2d35a

    <!-- adapted from http://www.eclipse.org/forums/index.php/t/639454/ -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <configuration>
            <filesets>
                <fileset>
                    <directory>${basedir}/src-gen</directory>
                </fileset>
                <fileset>
                    <directory>${basedir}/xtend-gen</directory>
                </fileset>
                <!-- clean ui plugin as well -->
                <fileset>
                    <directory>${basedir}/../${project.groupId}.${project.artifactId}.ui/src-gen</directory>
                </fileset>
                <fileset>
                    <directory>${basedir}/../${project.groupId}.${project.artifactId}.ui/xtend-gen</directory>
                </fileset>
                <!-- clean test fragment as well 
                <fileset>
                    <directory>${basedir}/../${project.groupId}.${project.artifactId}.tests/src-gen</directory>
                </fileset>
                <fileset>
                    <directory>${basedir}/../${project.groupId}.${project.artifactId}.tests/xtend-gen</directory>
                </fileset>
                -->
            </filesets>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>java</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <includeProjectDependencies>false</includeProjectDependencies>
            <includePluginDependencies>true</includePluginDependencies>
            <mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
            <arguments>
                <argument>file://${project.basedir}/src/net/vtst/ow/eclipse/less/GenerateLess.mwe2</argument>
                <argument>
                    -p
                </argument>
                <argument>
                    runtimeProject=/${project.basedir}
                </argument>
            </arguments>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>org.eclipse.xtext</groupId>
                <artifactId>org.eclipse.xtext.xtext</artifactId>
                <version>2.5.4</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.xtext</groupId>
                <artifactId>org.eclipse.xtext.xbase</artifactId>
                <version>2.5.4</version>
            </dependency>
        </dependencies>
    </plugin>
    <plugin>
        <groupId>org.eclipse.xtend</groupId>
        <artifactId>xtend-maven-plugin</artifactId>
        <version>2.5.4</version>
    </plugin>

现在它更接近maven / tycho构建,但它有错误 org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/net/vtst/ow/eclipse/less/Less.xtext' 路径似乎正确。

[INFO] --- exec-maven-plugin:1.2.1:java (default) @ net.vtst.ow.eclipse.less ---
0    [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering platform uri 'C:\Users\weibl\git\ow\src\eclipse'
745  [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems instantiating module net.vtst.ow.eclipse.less.GenerateLess: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: Problems instantiating module net.vtst.ow.eclipse.less.GenerateLess: java.lang.reflect.InvocationTargetException
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:95)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.reflect.InvocationTargetException
    at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:56)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:143)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:142)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalApplyAssignments(Mwe2ExecutionEngine.java:142)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:114)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.inCase(Mwe2ExecutionEngine.java:80)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.internalSwitch(Mwe2ExecutionEngine.java:66)
    at org.eclipse.emf.mwe2.language.factory.Mwe2ExecutionEngine.create(Mwe2ExecutionEngine.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:93)
    ... 10 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:54)
    ... 43 more
Caused by: org.eclipse.xtext.resource.ClasspathUriResolutionException: org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/net/vtst/ow/eclipse/less/Less.xtext'
    at org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(ClassloaderClasspathUriResolver.java:48)
    at org.eclipse.xtext.resource.XtextResourceSet.resolveClasspathURI(XtextResourceSet.java:160)
    at org.eclipse.xtext.resource.XtextResourceSet.access$0(XtextResourceSet.java:159)
    at org.eclipse.xtext.resource.XtextResourceSet$1.normalize(XtextResourceSet.java:216)
    at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:178)
    at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:205)
    ... 48 more
Caused by: org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/net/vtst/ow/eclipse/less/Less.xtext'
    at org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.findResourceOnClasspath(ClassloaderClasspathUriResolver.java:60)
    at org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(ClassloaderClasspathUriResolver.java:45)
    ... 53 more

1 个答案:

答案 0 :(得分:3)

我知道这是一个迟到的回复,但我遇到了同样的问题,并且花了一些时间才找到问题根。

错误消息实际上指向**。mwe2文件中的grammarURI。

eclipse创建的默认语法是:      &#34;类路径:/.../ Less.xtext&#34;

在对项目进行了大规模化之后,语法必须是平台:/资源&#34;因为它不在类路径上,所以它应该改为:      &#34;平台:/资源/ $ {PROJECTNAME} /.../ Less.xtext&#34;

当然,要修复解析错误,请将projectName声明移到grammarURI的前面。

所以**。mwe2中的声明最终应该是这样的:

// ... var projectName = "net.vtst.ow.eclipse.less" var grammarURI = "platform:/resource/${projectName}/src/net/vtst/ow/eclipse/less/Less.xtext" // ...