thegridman / coherence-k8s-example

0 stars 1 forks source link

Maven Build Failure after including Oracle Enterprise Coherence jar in pom.xml #3

Closed viju2008 closed 4 years ago

viju2008 commented 4 years ago

Hello,

I added the Commercial version of coherence as per the URL i have provided in mail.

However the build process failed. The POM.XML and build output are below

### I am attaching the 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">

4.0.0
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.3.RELEASE</version>
    <relativePath/>
</parent>

<groupId>org.example</groupId>
<artifactId>spring-boot-storage-service</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <version.lib.coherence>14.1.1.0.0</version.lib.coherence>
    <version.lib.hamcrest>1.3</version.lib.hamcrest>
    <version.lib.junit>5.6.1</version.lib.junit>
    <version.lib.mockito>3.3.3</version.lib.mockito>
    <version.lib.opentracing>0.33.0</version.lib.opentracing>
    <version.lib.opentracing.tracerresolver>0.1.8</version.lib.opentracing.tracerresolver>
    <version.lib.oracledb>19.7.0.0</version.lib.oracledb>

    <version.plugin.failsafe>2.22.2</version.plugin.failsafe>
    <version.plugin.jib>2.5.2</version.plugin.jib>
    <version.plugin.surefire>2.22.2</version.plugin.surefire>
</properties>

<dependencies>
    <!-- Dependency on the domain classes project -->
    <dependency>
        <groupId>com.oracle.coherence.examples</groupId>
        <artifactId>domain-model</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>

    <!-- Coherence dependencies -->
    <dependency>
        <groupId>com.oracle.coherence</groupId>
        <artifactId>coherence</artifactId>
        <version>${version.lib.coherence}</version>
    </dependency>
    <dependency>
        <groupId>com.oracle.coherence</groupId>
        <artifactId>coherence-management</artifactId>
        <version>${version.lib.coherence}</version>
    </dependency>
    <dependency>
        <groupId>com.oracle.coherence</groupId>
        <artifactId>coherence-metrics</artifactId>
        <version>${version.lib.coherence}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <!-- Oracle JDBC Driver -->
    <dependency>
        <groupId>com.oracle.database.jdbc</groupId>
        <artifactId>ojdbc10</artifactId>
        <version>${version.lib.oracledb}</version>
    </dependency>

    <dependency>
        <groupId>io.opentracing</groupId>
        <artifactId>opentracing-api</artifactId>
        <version>${version.lib.opentracing}</version>
    </dependency>
    <dependency>
        <groupId>io.opentracing</groupId>
        <artifactId>opentracing-noop</artifactId>
        <version>${version.lib.opentracing}</version>
    </dependency>
    <dependency>
        <groupId>io.opentracing</groupId>
        <artifactId>opentracing-util</artifactId>
        <version>${version.lib.opentracing}</version>
    </dependency>
    <dependency>
        <groupId>io.opentracing.contrib</groupId>
        <artifactId>opentracing-tracerresolver</artifactId>
        <version>${version.lib.opentracing.tracerresolver}</version>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>${version.lib.hamcrest}</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${version.lib.mockito}</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${version.lib.junit}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>${version.lib.junit}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${version.lib.junit}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <!-- Surefire plugin to run unit tests -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${version.plugin.surefire}</version>
            <configuration>
                <reuseForks>false</reuseForks>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-engine</artifactId>
                    <version>5.6.1</version>
                </dependency>
                <dependency>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                    <version>5.6.1</version>
                </dependency>
            </dependencies>
        </plugin>

        <!-- Failsafe plugin to run integration tests -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${version.plugin.failsafe}</version>
            <configuration>
                <reuseForks>false</reuseForks>
                <systemProperties>
                    <oracle.db.url>jdbc:oracle:thin:@localhost:1521/ORCLPDB1</oracle.db.url>
                    <oracle.db.user>jonathan</oracle.db.user>
                    <oracle.db.pwd>secret</oracle.db.pwd>
                </systemProperties>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-engine</artifactId>
                    <version>5.6.1</version>
                </dependency>
                <dependency>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                    <version>5.6.1</version>
                </dependency>
            </dependencies>
        </plugin>

        <!-- JIB plugin to build the OCI image -->
        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>jib-maven-plugin</artifactId>
            <version>${version.plugin.jib}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>dockerBuild</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <from>
                            <image>docker://gcr.io/distroless/java:11</image>
                        </from>
                        <to>
                            <image>coherence-example-spring-storage:${project.version}</image>
                        </to>
                        <container>
                            <mainClass>com.oracle.coherence.examples.storage.StorageApplication</mainClass>
                            <environment>
                                <!-- Setting the COH_MAIN_CLASS environment variable will make the Coherence K8s Operator use
                                     the correct main class without needing to specify it the class name in the Coherence
                                     resource yaml -->
                                <COH_MAIN_CLASS>com.oracle.coherence.examples.storage.StorageApplication</COH_MAIN_CLASS>
                                <!-- Jaeger tracing variables -->
                                <JAEGER_SAMPLER_TYPE>const</JAEGER_SAMPLER_TYPE>
                                <JAEGER_SAMPLER_PARAM>1</JAEGER_SAMPLER_PARAM>
                                <JAEGER_SERVICE_NAME>coherence</JAEGER_SERVICE_NAME>
                            </environment>
                            <jvmFlags>
                                <jvmFlag>-Dcoherence.log=jdk</jvmFlag>
                                <jvmFlag>-Dcoherence.metrics.http.enabled=true</jvmFlag>
                                <jvmFlag>-Dcoherence.metrics.http.port=9612</jvmFlag>
                                <jvmFlag>-Dcoherence.management.http=all</jvmFlag>
                                <jvmFlag>-Dcoherence.management.http.port=30000</jvmFlag>
                                <jvmFlag>-Dcoherence.extend.port=20000</jvmFlag>
                                <jvmFlag>-Dcoherence.ttl=0</jvmFlag>
                                <jvmFlag>-Dcoherence.tracing.ratio=1</jvmFlag>
                            </jvmFlags>
                            <ports>
                                <port>9612</port>
                                <port>30000</port>
                                <port>20000</port>
                            </ports>
                        </container>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

### The build output is below

ubuntu@master-node:/home/ubuntu4$ ./mvnw clean install -DskipTests -f spring-boot-storage-service/ [INFO] Scanning for projects... [INFO] [INFO] --------------< org.example:spring-boot-storage-service >--------------- [INFO] Building spring-boot-storage-service 1.0.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ spring-boot-storage-service --- [INFO] [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-boot-storage-service --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-boot-storage-service --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 6 source files to /home/ubuntu4/spring-boot-storage-service/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/ubuntu4/spring-boot-storage-service/src/main/java/com/oracle/coherence/examples/storage/StudentCacheStore.java:[15,8] com.oracle.coherence.examples.storage.StudentCacheStore is not abstract and does not override abstract method eraseAll(java.util.Collection<? extends com.oracle.coherence.examples.domain.StudentId>) in com.tangosol.net.cache.CacheStore [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.556 s [INFO] Finished at: 2020-09-20T11:31:01Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project spring-boot-storage-service: Compilation failure [ERROR] /home/ubuntu4/spring-boot-storage-service/src/main/java/com/oracle/coherence/examples/storage/StudentCacheStore.java:[15,8] com.oracle.coherence.examples.storage.StudentCacheStore is not abstract and does not override abstract method eraseAll(java.util.Collection<? extends com.oracle.coherence.examples.domain.StudentId>) in com.tangosol.net.cache.CacheStore [ERROR] [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [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 read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException[](url)

thegridman commented 4 years ago

This looks like it is due to a difference in the CacheStore and CacheLoader interfaces in Coherence CE 20.06 and in commercial 14.1.1.

In CE the methods on a loadAll method on CacheLoader and the storeAll and eraseAll on CacheStore have been implemented as default methods on the interfaces, in 14.1.1 they have not. The example code for the CacheStores needs to add the missing methods. I have committed changes to the example on GitHub, the missing methods look like this:

@Override
public Map<StudentId, Student> loadAll(Collection<? extends StudentId> colKeys) {
    Map<StudentId, Student> map = new HashMap<>();
    for (StudentId key : colKeys) {
        Student value = load(key);
        if (value != null) {
            map.put(key, value);
        }
    }
    return map;
}

@Override
public void eraseAll(Collection<? extends StudentId> colKeys) {
    boolean fRemove = true;

    for (Iterator<? extends StudentId> iter = colKeys.iterator(); iter.hasNext(); ) {
        erase(iter.next());
        if (fRemove) {
            try {
                iter.remove();
            }
            catch (UnsupportedOperationException e) {
                fRemove = false;
            }
        }
    }
}

@Override
public void storeAll(Map<? extends StudentId, ? extends Student> mapEntries) {
    boolean fRemove = true;

    for (Iterator<? extends Map.Entry<? extends StudentId, ? extends Student>> iter = mapEntries.entrySet().iterator();
            iter.hasNext(); ) {
        Map.Entry<? extends StudentId, ? extends Student> entry = iter.next();
        store(entry.getKey(), entry.getValue());
        if (fRemove) {
            try {
                iter.remove();
            }
            catch (UnsupportedOperationException e) {
                fRemove = false;
            }
        }
    }
}