【问题标题】:org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/../Less.xtext'org.eclipse.xtext.resource.FileNotFoundOnClasspathException:找不到类路径上的资源。 URI 是“类路径:/../Less.xtext”
【发布时间】:2014-04-29 05:18:31
【问题描述】:

在尝试 mavenize 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

【问题讨论】:

    标签: eclipse maven xtext tycho xtend


    【解决方案1】:

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

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

    eclipse创建的默认语法URI是: “类路径:/.../Less.xtext”。

    项目maven化后,grammarURI必须是“平台:/资源”,因为它不在类路径中,所以应该改为: "平台:/resource/${projectName}/.../Less.xtext"

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

    因此,**.mwe2 中的声明最终应如下所示:

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

    【讨论】:

      猜你喜欢
      • 2016-06-15
      • 2023-03-13
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-11
      • 2013-03-20
      • 2010-12-08
      相关资源
      最近更新 更多