Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans and Bad service configuration file, or exception thrown while constructing Processor object

Here a error getting from diagnostic throught 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

I trying to dynamic comppile a simple java class from file, using JavaCompiler. This class looks like:

package web.others;

public class User {

}

My Project is Maven Project Type

as you can see the class conatins nothing special. One thing what i need it is geting a Class object from this class. But at runtime. I would like to compile dynamic this class and get Class object. Problem is that I working on Netbeans Plaform and i want do that in this IDE (i develop a simple plugin)

To compile and run im using a following code:

 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);
 }

And always i getting a following error from diagnostics:

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

Anybody can help with this issue i will be a greatful for help!

UPDATE:

here my 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>
like image 269
Michał Ziembiński Avatar asked Nov 08 '14 14:11

Michał Ziembiński


1 Answers

I faced this exact same problem. The problem was that this line was missing from maven-complier-plugin's <configuration>:

<compilerArgument>-proc:none</compilerArgument>

The purpose of this is to tell the compiler not to use this processor for ourselves. If you do not have it, it is going to try to use that processor during the compilation of the processor and (as obvious) it is not going to find it since it is being compiled.

(or at least that is the way I understand the matter, please correct me if I am wrong).

like image 128
Ordiel Avatar answered Oct 25 '22 15:10

Ordiel