Java.lang.VerifyError quando si utilizza WCMUsePojo in una semplice applicazione AEM


Di seguito è riportato l'errore che ottengo quando faccio un mvn clean install del progetto. È una semplice applicazione AEM in AEM 6.1 in cui sto cercando di usare WCMUse.

[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

Di seguito è riportato il codice in cui sto usando 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");
    }

}

Se rimuovo extends WCMUsePojo non ci sono errori e la build funziona correttamente.

Si prega di trovare sotto il pom che sto usando:

<?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>
Author: Tunaki, 2016-09-01

1 answers

Questo è principalmente a causa di uber-jar offuscato che fornisce solo interfacce delle classi dipendenti, mentre WcmUsePojo è una classe e non un'interfaccia che vedi questo problema. Un modo per risolvere questo problema è ottenere un jar non offuscato per Adobe e usarlo, un altro è aggiungere esplicitamente le dipendenze sightly al tuo pom. È possibile controllare il numero di versione e altri dettagli dalla console bundle. Nel tuo caso avresti bisogno solo di com.adobe.cq.sightly.cq-wcm-sightly-extension bundle come dipendenza nel tuo POM

 0
Author: Ameesh Trikha, 2016-09-01 15:57:35