Netbeans和错误服务配置文件,或在构造Processor对象时引发的异常

MichałZiembiński

这是通过javaCompiler taska从诊断获得的错误:

  Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider org.netbeans.modules.openide.modules.PatchedPublicProcessor not a subtype

我试图使用JavaCompiler从文件动态编译一个简单的Java类。这个类看起来像:

package web.others;

public class User {

}

我的项目是Maven项目类型

正如您所看到的,类拉丁元素没什么特别的。我需要做的一件事是从此类获取Class对象。但是在运行时。我想动态编译此类并获取Class对象。问题是我正在研究Netbeans Plaform,并且想在此IDE中进行(我开发了一个简单的插件)

使用以下代码编译并运行im:

 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
 DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
 StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
 Iterable<? extends JavaFileObject> compilationUnits = Arrays.asList(file);
 JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, null,null,compilationUnits);
 boolean success = task.call();

 try {
   fileManager.close();
 } catch (IOException ex) {
    Exceptions.printStackTrace(ex);
 }
 System.out.println("Success: " + success);
 if (!success) {
    List<Diagnostic<? extends JavaFileObject>> dia = diagnostics.getDiagnostics();
    System.out.println("Diagnostic: " + dia);
 }

而且我总是从诊断中得到以下错误:

error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider org.netbeans.modules.openide.modules.PatchedPublicProcessor not a subtype

任何人都可以帮助解决这个问题,我将竭诚为您服务!

更新:

这是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany</groupId>
  <artifactId>mavenproject2</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>nbm</packaging>
  <build>
    <plugins>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>nbm-maven-plugin</artifactId>
            <version>3.13</version>
            <extensions>true</extensions>
            <configuration>
                <publicPackages>
                    <publicPackage>org.netbeans.modules</publicPackage>
                </publicPackages>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>  
                <source>1.7</source>   
                <target>1.7</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <useDefaultManifestFile>true</useDefaultManifestFile>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>netbeans</id>
        <name>Repository hosting NetBeans modules</name>
        <url>http://bits.netbeans.org/nexus/content/groups/netbeans</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>unknown-jars-temp-repo</id>
        <name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
        <url>file:${project.basedir}/lib</url>
    </repository>
</repositories>
<dependencies>

    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-core-ide</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-util</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-awt</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-nodes</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-filesystems</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-loaders</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-windows</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-util-lookup</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-io</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-explorer</artifactId>
        <version>RELEASE80</version>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-dialogs</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-text</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>


    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-openide-modules</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>

    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-projectuiapi</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-settings</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-projectapi</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-db</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-editor-lib2</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-editor-lib</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-editor-mimelookup</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-parsing-api</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-editor-indent</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-api-java-classpath</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-java-source</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-libs-javacapi</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-modules-java-project</artifactId>
        <version>RELEASE80</version>
        <type>jar</type>
    </dependency>









    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.6.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.1.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-envers</artifactId>
        <version>4.3.6.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>4.3.6.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-proxool</artifactId>
        <version>4.3.6.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-infinispan</artifactId>
        <version>4.3.6.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>4.3.6.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.1.3.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>unknown.binary</groupId>
        <artifactId>postgresql-9.2-1002.jdbc4</artifactId>
        <version>SNAPSHOT</version>
    </dependency>


    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.3.GA</version>
        <type>jar</type>
    </dependency>

    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.5.Final</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.18.1-GA</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.sun.codemodel</groupId>
        <artifactId>codemodel</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.0.5.RELEASE</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.0.5.RELEASE</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>unknown.binary</groupId>
        <artifactId>postgresql-9.3-1102.jdbc4</artifactId>
        <version>SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
        <version>2.5.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.reflections</groupId>
        <artifactId>reflections</artifactId>
        <version>0.9.9-RC1</version>
    </dependency>

   </dependencies>
   <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
 </project>
奥迪尔

我遇到了同样的问题。问题是,这条线是从缺少maven-complier-plugin<configuration>

<compilerArgument>-proc:none</compilerArgument>

这样做的目的是告诉编译器不要自己使用该处理器。如果您没有该处理器,它将在编译处理器时尝试使用该处理器,并且(很明显)它将因为编译而无法找到它。

(或者至少这就是我理解问题的方式,如果我错了,请纠正我)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Netbeans和外部配置文件

Infinispan未使用指定的JGroups配置文件并引发异常

SQL配置文件给服务器找不到异常

使用配置文件连接到Kubernetes服务器时处理错误

Windows服务读取配置文件时,如何编写代码以避免错误?

Amazon EC2 Linux - Azure devops 代理安装在运行配置文件时引发错误

Spring配置文件和属性占位符异常

生成配置文件和证书时出现NativeScript Sidekick错误

Firefox配置文件设置使用硒webdriver配置在量角器中引发错误

在C ++中的对象的构造函数中引发异常时,销毁对象的成员变量

配置代码清除配置文件以删除对象初始化程序构造函数的括号

从实例配置文件元数据服务器检索凭据时出错,PHP PHP sdk错误

从实例配置文件元数据服务器检索凭证时出现 AWS 错误

Windows Git:读取配置文件时发生未知错误

使用 xcodebuild 命令时错误的团队/配置文件

当我的函数在 .h 和 .c 文件中具有相同的配置文件时,冲突类型编译错误

Xcode自动登录和设置配置文件错误

Ammonite 和 Akka-Http 配置文件错误

导入证书和配置文件时出现问题

Microsoft.Extensions.DependencyInjection将null注入构造方法,而不是在缺少服务时引发异常

配置文件包含错误

构造分层的用户配置文件

Jenkins和配置文件

配置文件和PhoneGap

使用Unity XML配置文件在构造函数中注入复杂的对象

UNIX服务器上的用户配置文件和bash配置文件有什么区别

CMake错误(配置文件):配置文件错误配置文件

NetBeans配置文件(netbeans.conf)在哪里?

如何在配置文件中转换文本字符串,运行时会引发异常