1

我正在使用Maven 插件为一种新语言构建一个 NetBeans 插件。我已经(大致)遵循了本教程,但最终无法编译(下面的堆栈跟踪)。

使用与标准(基于 Ant)NetBeans 模块项目相同的代码和模块依赖项,它可以正确编译。它找不到的类似乎在另一个模块(org-netbeans-modules-editor-codetemplates)中可用,但是当我使用基于 Ant 的项目时,我不需要该模块。此外,如果我确实添加了该模块,我会在另一个模块中找不到另一个类的类似错误,这让我觉得我做错了什么。我错过了什么吗?

堆栈跟踪:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:


An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NoClassDefFoundError: org/netbeans/lib/editor/codetemplates/CodeTemplateCompletionProvider
    at org.netbeans.modules.csl.core.LanguageRegistrationProcessor.registerCodeCompletion(LanguageRegistrationProcessor.java:270)
    at org.netbeans.modules.csl.core.LanguageRegistrationProcessor.handleProcess(LanguageRegistrationProcessor.java:160)
    at org.openide.filesystems.annotations.LayerGeneratingProcessor.process(LayerGeneratingProcessor.java:121)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    at com.sun.tools.javac.main.Main.compile(Main.java:353)
    at com.sun.tools.javac.main.Main.compile(Main.java:342)
    at com.sun.tools.javac.main.Main.compile(Main.java:333)
    at com.sun.tools.javac.Main.compile(Main.java:94)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess0(JavacCompiler.java:551)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:526)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:167)
    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:678)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.netbeans.lib.editor.codetemplates.CodeTemplateCompletionProvider
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 45 more

我的依赖

    <!-- Common Scripting Language API (new) -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-csl-api</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Datasystems API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-loaders</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Dialogs API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-dialogs</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- File System API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-filesystems</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Lexer API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-lexer</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Lookup API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-util-lookup</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Nodes API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-nodes</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Text API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-text</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- UI Utilities API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-awt</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Utilities API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-util</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <!-- Window System API -->
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-windows</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
4

1 回答 1

3

您可能在为平台的工件生成 maven 的 pom.xml 文件时发现了错误。虽然 org-netbeans-modules-csl-api jar 包含对 codetemplates 模块的模块依赖项(org.netbeans.modules.editor.codetemplates/1 = 1),但它不存在于已解决的依赖项列表中。请针对https://netbeans.org/bugzilla组件:apisupport 子组件:maven 提出问题。

谢谢。

PS:解决方法确实是您尝试过但没有完成的路径。继续添加缺少的依赖项,直到满足注释处理器的运行时依赖项。

所需的依赖项(对于 NetBeans 7.3.1)是:

    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-editor-codetemplates</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
    <dependency>
        <groupId>org.netbeans.modules</groupId>
        <artifactId>org-netbeans-modules-editor-errorstripe</artifactId>
        <version>${netbeans.version}</version>
    </dependency>
于 2013-07-12T13:20:05.840 回答