JBoss EAP7 server throws ClassNotFoundException:org.apache.commons.beanutils eventhough EAR contains beanutils.jar - apache-commons-beanutils

My Project structure is
parent
|---ejb-app.jar
|---restapi-app.war
|---ear-app.ear
I am using commons-beanutils to map the JavaEntity Bean to normal POJO class(DTO). The implementation of commons-beanutils is available inside ejb-app.jar.
Example: BeanUtils.copyProperties(destination, source);
My ear-app.ear aaplication packages the two modules such as ejb-app.jar & restapi-app.war. Below I have added pom.xml of ear-app.ear
<?xml version="1.0" encoding="UTF-8"?>
<parent>
<groupId>migration</groupId>
<artifactId>migration-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../migration-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.ear.app</groupId>
<artifactId>ear-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<name>ear-app</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.ejb.app</groupId>
<artifactId>ejb-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>org.restapi.app</groupId>
<artifactId>restapi-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2.redhat-1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<modules>
<ejbModule>
<groupId>org.ear.app</groupId>
<artifactId>ear-app</artifactId>
<bundleFileName>ejb-app-0.0.1-SNAPSHOT.jar</bundleFileName>
</ejbModule>
<webModule>
<groupId>org.restapi.app</groupId>
<artifactId>restapi-app</artifactId>
<contextRoot>/</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- WildFly plug-in to deploy EAR -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Problem:
When I deploy my aaplication in RedHat JBoss EAP7 server, I am getting the following error:
Caused by: java.lang.ClassNotFoundException: org.apache.commons.beanutils.BeanUtils from [Module "deployment.ear-app-0.0.1-SNAPSHOT.ear.ejb-app-0.0.1-SNAPSHOT.jar:main" from Service Module Loader]

Related

javafx gluon mobile : reflection classes not used

I am building a mobile gluon javafx application. App runs fine in the jvm but not on mobile.
I found out that i had ClassNotFoundException when loading the FXML and discovered that it would not find java.net.URL(!!) The unfound classes were not present in the projet arm64_ios reflection files, but i somewhat expected that as i did not directly use those classes in the code. Unfortunately, gluon seems not to be able to parse the fxml to add known classes. But i disgress.
Just to validate the problem, i added this class name to my POM reflectionList. As expected, it would find it but block on an other one, then an other one, this was endless.
I check out that when i ran gluonfx:runagent, the missing classes were correctly added to src/main/resources/META-INF/native-image/reflect-config.json.
As per https://docs.gluonhq.com/#_jni_and_reflection , i added a META-INF/substrate/congif/reflectionconfig.json file that was a copy of the META-INF/native-image/reflect-config.json. That did not help.
I do not know why the runagent files are not used, i think i might have fumbled somewhere. I will be very grateful for any hint. Thanks.
Here are the relevant parts of my POM.
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>17.0.2</javafx.version>
<attach.version>4.0.13</attach.version>
<gluonfx.plugin.version>1.0.12</gluonfx.plugin.version>
<javafx.plugin.version>0.0.8</javafx.plugin.version>
<mainClassName>com.blah</mainClassName>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
<artifactId>charm-glisten</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>display</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>statusbar</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>util</artifactId>
<version>${attach.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Gluon</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.plugin.version}</version>
<configuration>
<mainClass>${mainClassName}</mainClass>
</configuration>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
</execution>
<execution>
<!-- Configuration for manual attach debugging -->
<!-- Usage: mvn clean javafx:run#debug -->
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
</options>
</configuration>
</execution>
<execution>
<!-- Configuration for automatic IDE debugging -->
<id>ide-debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
</configuration>
</execution>
<execution>
<!-- Configuration for automatic IDE profiling -->
<id>ide-profile</id>
<configuration>
<options>
<option>${profiler.jvmargs.arg1}</option>
<option>${profiler.jvmargs.arg2}</option>
<option>${profiler.jvmargs.arg3}</option>
<option>${profiler.jvmargs.arg4}</option>
<option>${profiler.jvmargs.arg5}</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>${gluonfx.plugin.version}</version>
<configuration>
<verbose>true</verbose>
<target>${gluonfx.target}</target>
<attachList>
<list>display</list>
<list>lifecycle</list>
<list>statusbar</list>
<list>storage</list>
</attachList>
<reflectionList>
<list>java.net.URL</list>
</reflectionList>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.fxml</include>
<include>**/*.css</include>
<include>**/*.png</include>
<include>*.png</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.fxml</include>
<include>**/*.css</include>
<include>**/*.png</include>
<include>*.png</include>
</includes>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>ios</id>
<properties>
<gluonfx.target>ios</gluonfx.target>
</properties>
</profile>
<profile>
<id>android</id>
<properties>
<gluonfx.target>android</gluonfx.target>
</properties>
</profile>
</profiles>
Ok, now i found a solution, not sure i understood what happens.
Everything was caused by my resources includes. Not sure why/if i added them, not sure where they came from. It seems that configuring includes removes the default ones and that forbid the inclusion of the json files, and thus i had no other defined reflections than those that were found at compilation.
Removing the includes section of the POM and adding <nativeImageArgs>--allow-incomplete-classpath</nativeImageArgs> within the POM finally cleared all compilation blurps.
This post helped me for this last tip: Why is my JavaFX 17 Application not building with Gluon ? Logged as JNI / Reflection problem
Thanks José for coming by.

Wrong Characters on javafx dialog

I used JOptionPane.showInputDialog and TextInputDialog for getting user input like this:
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("ورودی");
dialog.setHeaderText("لطفا شماره انبار را وارد کنید");
dialog.getDialogPane().setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
Optional<String> anbarId = dialog.showAndWait();
anbarId.ifPresent(s ->
{
if (!s.equals("")) {
anbarLabel.setText(s);
}
}
);
but when i run executable jar file it shows me wrong characters:
Wrong characters on dialog
I used maven assembly plugin to create executable jar file here is 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.ansar</groupId>
<artifactId>Jeticket</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.2.1.jre8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.ansar.application.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
finally i solved this problem by changing my jre version to 1.8.271 and using 'String.valueOf()'

Could not find artifact javafx-packager:javafx-packager:

This is my pom.xml
<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>
<groupId>com.ginkgo</groupId>
<artifactId>csgo-cfg-helper-client</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>16</maven.compiler.release>
<javafx.version>16</javafx.version>
<javafx.maven.plugin.version>0.0.6</javafx.maven.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
<configuration>
<jlinkImageName>csgo_cfg_helper</jlinkImageName>
<launcher>launcher</launcher>
<mainClass>com.ginkgo.csgo.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>com.ginkgo.csgo.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
My Operating System: MacOs Big Sur 11.4
JDK: openjdk-16.0.1
I want to make a .dmg or .pkg file using command mvn clean jfx:native, however, it doesn't work.
[ERROR] Failed to execute goal com.zenjava:javafx-maven-plugin:8.8.3:jar (jar) on project csgo-cfg-helper-client: Execution jar of goal com.zenjava:javafx-maven-plugin:8.8.3:jar failed: Plugin com.zenjava:javafx-maven-plugin:8.8.3 or one of its dependencies could not be resolved: Could not find artifact javafx-packager:javafx-packager:jar:1.8.0_20 at specified path /Users/hll/Library/Java/JavaVirtualMachines/openjdk-16.0.1/Contents/Home/../lib/ant-javafx.jar -> [Help 1]
Is it Java Version too high? jLink work well and generate module success.
How should i do? This is my first time to bulid a JavaFX project. I find the same question in stackoverflow, but no useful answer.Thanks for your help.
You seem to follow an ancient tutorial. Just start with the official docs and not some crap pulled from the internet. https://openjfx.io/openjfx-docs/ And for packaging you app have a look here: https://docs.oracle.com/en/java/javase/16/jpackage

"No versions available" error running LocalDynamoDB

titan version = 1.0.0
gremlin version = 3.0.1-incubating.
Running local DynamoDB in Ubuntu 16.04 terminal gives me an error like this...
[ERROR] Failed to execute goal on project
dynamodb-titan100-storage-backend: Could not resolve dependencies for
project com.amazonaws:dynamodb-titan100-storage-backend:jar:1.0.0:
Failed to collect dependencies at
com.amazonaws:DynamoDBLocal:jar:[1.0.0,2.0.0]: No versions available
for com.amazonaws:DynamoDBLocal:jar:[1.0.0,2.0.0] within specified
range -> [Help 1].
pom.xml file look like this
<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.amazonaws</groupId>
<artifactId>dynamodb-titan100-storage-backend</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Amazon DynamoDB Storage Backend for Titan</name>
<url>https://github.com/awslabs/dynamodb-titan-storage-backend</url>
<description>The Amazon DynamoDB Storage Backend for Titan: Distributed Graph Database allows Titan graphs to use DynamoDB as a storage backend.</description>
<scm>
<url>git#github.com:awslabs/dynamodb-titan-storage-backend.git</url>
<tag>titan1.0.0-1.0.0</tag>
</scm>
<properties>
<test.extra.jvm.opts>-javaagent:${basedir}/target/jamm-${jamm.version}.jar </test.extra.jvm.opts>
<default.test.jvm.opts>-Xms256m -Xmx1280m -XX:+HeapDumpOnOutOfMemoryError -ea ${test.extra.jvm.opts} </default.test.jvm.opts>
<mem.jvm.opts>-Xms256m -Xmx768m -ea -XX:+HeapDumpOnOutOfMemoryError ${test.extra.jvm.opts} </mem.jvm.opts>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dynamodb-local.port>4567</dynamodb-local.port>
<dynamodb-local.endpoint>http://localhost:${dynamodb-local.port}</dynamodb-local.endpoint>
<jdk.version>1.8</jdk.version>
<aws.java.sdk.version>[1.0.0,2.0.0]</aws.java.sdk.version>
<titan.version>1.0.0</titan.version>
<tinkerpop.version>3.0.1-incubating</tinkerpop.version>
<dependency.plugin.version>2.10</dependency.plugin.version>
<maven.assembly.plugin.version>2.5.5</maven.assembly.plugin.version>
<maven.compiler.plugin.version>3.3</maven.compiler.plugin.version>
<maven.surefire.version>2.18.1</maven.surefire.version>
<maven.resources.plugin.version>2.7</maven.resources.plugin.version>
<exec.maven.plugin.version>1.2</exec.maven.plugin.version>
<slf4j.version>1.7.5</slf4j.version>
<jackson2.version>2.5.3</jackson2.version>
<opencsv.version>2.4</opencsv.version>
<metrics3.version>3.0.1</metrics3.version>
<commons.logging.version>1.1.1</commons.logging.version>
<sqlite4java.version>1.0.392</sqlite4java.version>
<hamcrest.version>1.3</hamcrest.version>
<hadoop.version>2.2.0</hadoop.version>
<!-- <test.excluded.groups> com.thinkaurelius.titan.testcategory.MemoryTests,com.thinkaurelius.titan.testcategory.PerformanceTests,com.thinkaurelius.titan.testcategory.BrittleTests,com.thinkaurelius.titan.testcategory.OrderedKeyStoreTests,com.thinkaurelius.titan.testcategory.SerialTests </test.excluded.groups> -->
</properties>
<developers>
<developer>
<name>Alexander Patrikalakis</name>
<email>amcp#me.com</email>
<url>https://www.linkedin.com/in/amcpatrix/en</url>
</developer>
<developer>
<name>Matthew Sowders</name>
<email>matthewsowders#gmail.com</email>
<url>https://www.linkedin.com/in/matthewsowders/en</url>
</developer>
<developer>
<name>Michael Rodaitis</name>
<email>mrodaitis#gmail.com</email>
</developer>
</developers>
<contributors>
<contributor>
<name>Zameer Merali</name>
<email>zmerali#amazon.com</email>
</contributor>
<contributor>
<name>Justin Panian</name>
<email>panianj#amazon.com</email>
</contributor>
</contributors>
<inceptionYear>2014</inceptionYear>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<!-- Libraries -->
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-core</artifactId>
<version>${titan.version}</version>
</dependency>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-test</artifactId>
<version>${titan.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-es</artifactId>
<version>${titan.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics3.version}</version>
</dependency>
<dependency>
<groupId>au.com.bytecode</groupId>
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
<version>${jackson2.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Gremlin -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>${tinkerpop.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-test</artifactId>
<version>${tinkerpop.version}</version>
<scope>test</scope>
</dependency>
<!-- for Gremlin console -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-console</artifactId>
<version>${tinkerpop.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<!-- Use the single-integration-tests and multi-integration-tests profiles below -->
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven.resources.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${dependency.plugin.version}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>start-dynamodb-local</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec.maven.plugin.version}</version>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<classpath/>
<argument>-Dsqlite4java.library.path=${basedir}/target/dependencies</argument>
<argument>com.amazonaws.services.dynamodbv2.local.main.ServerRunner</argument>
<!-- <argument> -inMemory </argument> -->
<argument>-dbPath</argument>
<argument>${basedir}/src/test/resources/com/amazon/titan/diskstorage/dynamodb/DynamoDBStoreManager</argument>
<argument>-port</argument>
<argument>${dynamodb-local.port}</argument>
<argument> -sharedDb </argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>single-integration-tests</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<executions>
<execution>
<id>surefire-it</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<!-- <excludedGroups>${test.excluded.groups},com.amazon.titan.testcategory.MultipleItemTests</excludedGroups> -->
<groups>com.amazon.titan.testcategory.SingleItemTests</groups>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>multi-integration-tests</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<executions>
<execution>
<id>surefire-it</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<!-- <excludedGroups>${test.excluded.groups},com.amazon.titan.testcategory.SingleItemTests</excludedGroups> -->
<groups>com.amazon.titan.testcategory.MultipleItemTests</groups>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>start-gremlin</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec.maven.plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Dsqlite4java.library.path=${basedir}/target/dependencies</argument>
<argument>-cp</argument>
<argument>${basedir}/target/dependencies/*${path.separator}${basedir}/target/dynamodb-titan100-storage-backend-1.0.0.jar</argument>
<argument>org.apache.tinkerpop.gremlin.console.Console</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>dynamodblocal</id>
<name>AWS DynamoDB Local Release Repository</name>
<url>http://dynamodb-local.s3-website-us-west-2.amazonaws.com/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
</dependency>
<dependency>
<groupId>com.almworks.sqlite4java</groupId>
<artifactId>sqlite4java</artifactId>
<version>${sqlite4java.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons.logging.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
The issue appears to be resolved now. Please try again.
According to this blog post, it looks like DynamoDB Local is now available in AWS Maven Repo. So you should simply substitute the <repository> node in your pom.xml with something like:
<repository>
<id>dynamodb-local</id>
<name>DynamoDB Local Release Repository</name>
<url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</url>
</repository>
Hope it helps.
In August 2018 Amazon announced new Docker image with Amazon DynamoDB Local onboard. It does not require downloading and running any JARs as well as adding using third-party OS-specific binaries like sqlite4java.
It is as simple as starting a Docker container before the tests:
docker run -p 8000:8000 amazon/dynamodb-local
You can do that manually for local development, as described above, or use it in your CI pipeline. Many CI services provide an ability to start additional containers during the pipeline that can provide dependencies for your tests. Here is an example for Gitlab CI/CD:
test:
stage: test
image: openjdk:8-alpine
services:
- name: amazon/dynamodb-local
alias: dynamodb-local
script:
- DYNAMODB_LOCAL_URL=http://dynamodb-local:8000 ./gradlew clean test
So, during the test task DynamoDB will be available on http://dynamodb-local:8000.
Another, more powerful tool is localstack. It supports two dozen of AWS services, DynamoDB is one of them. The isage is very similar, you have to start it before running the tests and it will expose AWS-compatible APIs on given ports:
test:
stage: test
image: openjdk:8-alpine
services:
- name: localstack/localstack
alias: localstack
script:
- ./gradlew clean test
Aaahhh! yes, i have resolve it making changes in pom file like this
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>1.11.0.1</version>
</dependency>
instead of
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>

ClassNotFoundException in Maven project

There is a maven based project, which can be built by maven install, but throw exception when run the out jar:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I want to know why java can not find the maven dependency library ?
<?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>
<groupId>org.artofsolving.jodconverter</groupId>
<artifactId>jodconverter-core</artifactId>
<version>3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JODConverter - Core Library</name>
<description>
JODConverter converts office documents using OpenOffice.org
</description>
<url>http://jodconverter.googlecode.com</url>
<licenses>
<license>
<name>GNU Lesser General Public License, Version 3 or later</name>
<url>http://www.gnu.org/licenses/lgpl.html</url>
</license>
</licenses>
<scm>
<url>http://jodconverter.googlecode.com/svn/trunk/jodconverter-core</url>
<connection>scm:svn:https://jodconverter.googlecode.com/svn/trunk/jodconverter-core/</connection>
</scm>
<inceptionYear>2003</inceptionYear>
<developers>
<developer>
<id>mirko.nasato</id>
<name>Mirko Nasato</name>
<email>mirko#artofsolving.com</email>
</developer>
</developers>
<contributors>
<contributor>
<name>Shervin Asgari</name>
<email>shervin#asgari.no</email>
</contributor>
</contributors>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<!-- required for org.hyperic:sigar -->
<id>jboss-public-repository-group</id>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
</repositories>
<dependencies>
<!-- Required dependencies -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>juh</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>ridl</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>unoil</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<!-- for the command line tool -->
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<!-- Optional dependencies -->
<dependency>
<!-- for more robust process management -->
<groupId>org.hyperic</groupId>
<artifactId>sigar</artifactId>
<version>1.6.5.132</version>
<optional>true</optional>
</dependency>
<dependency>
<!-- for JSON configuration -->
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<optional>true</optional>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<!-- don't run tests in parallel -->
<perCoreThreadCount>false</perCoreThreadCount>
<threadCount>1</threadCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<mainClass>org.artofsolving.jodconverter.cli.Convert</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</reporting>
</project>
When running your Jar with java -jar, you're no longer running with the maven resolving of dependencies. You have to make sure that all the jars you depend on are available at the relative loacation specificied in the MANIFEST.mf file in your Jar. Usually, you would use the assembly plugin to create a distributable archive that creates this structure. Or you could use a uberjar/onejar plugin to included everything inside your Jar.
You have 2 options to fix this:
Option 1 - use both plugins below to copy dependencies to a "lib" folder (see outputDirectory) and make your Runnable JAR know where they are (see classpathPrefix)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>example.MyMainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
Option 2 - Use maven-assembly-plugin to create a single JAR with all dependencies included. (all dependencies are extracted and compressed together in the same JAR)
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>compile</scope>
</dependencySet>
</dependencySets>
I've seen the problem, too. Cobertura creates instrumented copies of all compiled classfiles (in target/classes) by bytecode manipulation. My jar file contained the instrumented class files (from target/generated-classes/cobertura), but cobertura.jar was missing. So, ClassNotFoundException was the right reaction.
However, since my POM doesn't contain any hint, which are the intended classes for packaging, Maven has the free choice ... and it uses the instrumented set of files.
My solution was really simple: mvn clean and mvn package. The first call removes all instrumented classes. Then, the second call finds only the uninstrumented classes without any external references to Cobertura.

Resources