I am trying to compile my project which uses Gradle and Maven. The project use another library on my local maven repository. The library is referenced in Gradle and Maven:
Gradle:
dependencies{
compile 'cf.charly1811.java.utils:MimeType:1.0'
}
Maven:
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>cf.charly1811.java.utils</groupId>
<artifactId>MimeType</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
When I try compile the project using mvn clean package
or gradle clean jar
it success. The error arises when the MimeType class is called:
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: cf/charly1811/java/utils/MimeType at cf.charly1811.java.web.RequestHandlerThread.process(RequestHandlerThread.java:120)
at cf.charly1811.java.web.RequestHandlerThread.handleRequest(RequestHandlerThread.java:85)
at cf.charly1811.java.web.RequestHandlerThread.run(RequestHandlerThread.java:64)
Caused by: java.lang.ClassNotFoundException: cf.charly1811.java.utils.MimeType
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
I don't know what causing this error... Please help.
EDIT: MimeType pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<name>MimeType</name>
<description>Library to easily get the type of a file</description>
<groupId>cf.charly1811.java.utils</groupId>
<artifactId>MimeType</artifactId>
<version>1.0</version>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
</project>
HttpServer (Main project) pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<name>HttpServer</name>
<description>A simple HTTP Server written in JAVA</description>
<groupId>cf.charly1811.java.web</groupId>
<artifactId>HttpServer</artifactId>
<version>1.0</version>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>cf.charly1811.java.utils</groupId>
<artifactId>MimeType</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<!-- License -->
<licenses>
<license>
<name>Private use</name>
<url>http://choosealicense.com/licenses/no-license/</url>
<comments>This Software is for private use Only</comments>
</license>
</licenses>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>cf.charly1811.java.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
EDIT I forgot to clarify 1 thing: I use IntelliJ IDEA. When I try to compile the project using "Run" It compile everything and I don't get this error. It only happen when I use Gradle or Maven to compile the project