I am creating a client and a server wrapper for a neural network. The client reads and sends an image to the server who runs the models and responds the results back to client. I have created a multimodule project for this reason. When i run client and server from IDE (intellij idea) everything works ok. However when i use maven to build and then run from terminal i get errors.
My main/parent pom.xml is the following:
<?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>gr.enomix</groupId>
<artifactId>imageClassificationWrapper</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<modules>
<module>Server</module>
<module>Client</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.0.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
My Server pom.xml is:
<?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">
<parent>
<artifactId>imageClassificationWrapper</artifactId>
<groupId>gr.enomix</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>gr.enomix</groupId>
<artifactId>Server</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
</project>
And my client pom.xml is:
<?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">
<parent>
<artifactId>imageClassificationWrapper</artifactId>
<groupId>gr.enomix</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>gr.enomix</groupId>
<artifactId>Client</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
</project>
I want all libraries from parent pom.xml to be inherited to both children client and server. Then i run from terminal mvn clean install and the project successfully builds without any error.
Then finally i execute
java -cp target/Server-1.0.jar RunServer
to run the server and
java -cp target/Client-1.0.jar RunClient
to run the client but i get errors
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
at ImageHttpClient.sendImage(ImageHttpClient.java:78)
at RunClient.main(RunClient.java:11)
from both client and server.
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/apache/commons/io/IOUtils
at Handlers.ConnectionHandler.readAndSaveImage(ConnectionHandler.java:39)
at Handlers.ConnectionHandler.run(ConnectionHandler.java:25)
at java.lang.Thread.run(Thread.java:745)
Maven dependencies are not build in class path??? Am i doing something wrong?? Please Help i am breaking my head two days now...