VAr
VAr

Reputation: 2601

Failed to execute goal (generate-scr-scrdescriptor) on project Unable to load compiled class

Have any one faced below error. why it causes.? am using the below version of plugins.

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.2</version>
    </plugin>

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-scr-plugin</artifactId>
                <version>1.20.0</version>
                <executions>
                    <execution>
                        <id>generate-scr-scrdescriptor</id>
                        <goals>
                            <goal>scr</goal>
                        </goals>
                        <configuration>
                            <!-- Private service properties for all services. -->
                            <properties>
                                <service.vendor>Adobe</service.vendor>
                            </properties>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                           <outputDirectory>${project.build.directory}/classes</outputDirectory>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-simple</artifactId>
                        <version>1.5.11</version>
                    </dependency>
                </dependencies>
            </plugin>

[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-scrdescriptor) on project osgiexample.core: E:\MY-Work\TESTProj\osgiexample\core\src\main\java\osgiexample\core\servlets\MyDataProviderServlet.java : Unable to load compiled class: osgiexample.core.servlets.MyDataProviderServlet -> [Help 1]

Upvotes: 4

Views: 3037

Answers (1)

toniedzwiedz
toniedzwiedz

Reputation: 18563

This means that the SCR plugin is unable to find a compiled class file corresponding to the file MyDataProviderServlet.java

I've only seen this happen in the following situations:

  1. I had special characters in the path to my project, which caused the SCR plugin to fail to find the compiled classes.
  2. I had a *.java file but its contents were temporarily commented out. The SCR plugin expected to find a compiled *.class file but there was nothing to compile (just comments). This caused an error message exactly like the one you saw.

Off the top of my head, I can't think of other cases where a class file would not be found by the SCR plugin without the Compiler plugin failing first.

I'd look for something unusual in the Java class itself. Does this happen for other classes with SCR annotations or just this one?

As a next step, I'd look at the file system. Could be a strange character or a file link confusing the plugin.

Finally, I'd inspect the rest of the Maven build. Perhaps you're using other plugins that might remove or otherwise mangle the class file prior to the SCR Plugin's execution?

Upvotes: 1

Related Questions