0

以下是我在执行mvn clean install项目时遇到的错误。这是我尝试使用 WCMUse 的 AEM 6.1 中的一个简单 AEM 应用程序。

[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.7.4:scr (gene
rate-scr-descriptor) on project myproject-bundle: Execution generate-scr-descrip
tor of goal org.apache.felix:maven-scr-plugin:1.7.4:scr failed: An API incompati
bility was encountered while executing org.apache.felix:maven-scr-plugin:1.7.4:s
cr: java.lang.VerifyError: Constructor must call super() or this() before return

[ERROR] Exception Details:
[ERROR] Location:
[ERROR] com/adobe/cq/sightly/WCMUsePojo.<init>()V @1: return
[ERROR] Reason:
[ERROR] Error exists in the bytecode
[ERROR] Bytecode:
[ERROR] 0x0000000: 2ab1
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.felix:maven-scr-plugin:1.7.4
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/D:/Maven_Repo/org/apache/felix/maven-scr-plugin/1.7.4/ma
ven-scr-plugin-1.7.4.jar
[ERROR] urls[1] = file:/D:/Maven_Repo/org/apache/maven/maven-archiver/2.2/maven-
archiver-2.2.jar
[ERROR] urls[2] = file:/D:/Maven_Repo/org/codehaus/plexus/plexus-utils/1.0.4/ple
xus-utils-1.0.4.jar
[ERROR] urls[3] = file:/D:/Maven_Repo/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[4] = file:/D:/Maven_Repo/org/codehaus/plexus/plexus-archiver/1.0-al
pha-7/plexus-archiver-1.0-alpha-7.jar
[ERROR] urls[5] = file:/D:/Maven_Repo/org/apache/felix/org.apache.felix.scr.gene
rator/1.1.4/org.apache.felix.scr.generator-1.1.4.jar
[ERROR] urls[6] = file:/D:/Maven_Repo/com/thoughtworks/qdox/qdox/1.12/qdox-1.12.
jar
[ERROR] urls[7] = file:/D:/Maven_Repo/asm/asm-all/3.1/asm-all-3.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[project>my-group-id:myprojec
t-bundle:1.0-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContaine
rException

下面是我使用 WCMUsePojo 的代码。

package com.mycompany.myproject.controllers;
import com.adobe.cq.sightly.WCMUsePojo;;
public class TestController extends WCMUsePojo{

    @Override
    public void activate() throws Exception {
        // TODO Auto-generated method stub
        testMethod();
    }

    void testMethod()
    {
        System.out.println("test method");
    }

}

如果我删除 extends WCMUsePojo 没有错误并且构建运行良好。

请在我正在使用的 pom 下方找到:

<?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/maven-v4_0_0.xsd ">
    <modelVersion>4.0.0</modelVersion>
    <!-- ====================================================================== -->
    <!-- P A R E N T P R O J E C T D E S C R I P T I O N -->
    <!-- ====================================================================== -->
    <parent>
        <groupId>my-group-id</groupId>
        <artifactId>myproject</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <!-- ====================================================================== -->
    <!-- P R O J E C T D E S C R I P T I O N -->
    <!-- ====================================================================== -->

    <artifactId>myproject-bundle</artifactId>
    <packaging>bundle</packaging>
    <name>My Project Bundle</name>

    <dependencies>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.scr.annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>biz.aQute</groupId>
            <artifactId>bndlib</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.api</artifactId>
        </dependency>        
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>uber-jar</artifactId>
            <version>6.1.0</version>
            <classifier>obfuscated-apis</classifier>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <!-- ====================================================================== -->
    <!-- B U I L D D E F I N I T I O N -->
    <!-- ====================================================================== -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-scr-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-scr-descriptor</id>
                        <goals>
                            <goal>scr</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>my-group-id.myproject-bundle</Bundle-SymbolicName>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>maven-sling-plugin</artifactId>
                <configuration>
                    <slingUrl>http://${crx.host}:${crx.port}/apps/myproject/install</slingUrl>
                    <usePut>true</usePut>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                 <configuration>
                    <excludePackageNames>
                        *.impl
                    </excludePackageNames>
                 </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>auto-deploy</id>
            <build>
                <plugins>
                    <!-- Use the sling plugin to automatically deploy the bundle to the 
                        JCR tree -->
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>maven-sling-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-bundle</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <configuration>
                                    <slingUrl>http://${cq.host}:${cq.port}</slingUrl>
                                    <slingUrlSuffix>/apps/myproject/install</slingUrlSuffix>
                                    <user>${cq.user}</user>
                                    <password>${cq.password}</password>
                                    <usePut>true</usePut>
                                    <failOnError>true</failOnError>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                </plugins>

            </build>
        </profile>
    </profiles>
</project>
4

1 回答 1

0

这主要是因为混淆的 uber-jar 仅提供依赖类的接口,而 WcmUsePojo 是一个类而不是您看到此问题的接口。解决此问题的一种方法是为 Adob​​e 获取未混淆的 jar 并使用它,另一种方法是显式地将明显的依赖项添加到您的 pom.xml 中。您可以从 bundles 控制台检查版本号和其他详细信息。在您的情况下,您只需要com.adobe.cq.sightly.cq-wcm-sightly-extension捆绑作为 POM 中的依赖项

于 2016-09-01T15:57:35.510 回答