Need to Include all nested JARs in user lib

Hi All, I am consuming an external jar XYZ.jar in my mendix project’s java action. This external jar XYZ consumes another PQR.jar internally. When I only add XYZ.jar file in the userlib folder of my mendix project then the java action throws compile time error for missing dependency of PQR.jar file. So I have to add both XYZ.jar and PQR.jar in the userlib folder. Idly we should include only top level jar (XYZ.jar) in the user lib folder and all internal jars on which the XYZ.jar depends should be included by mendix automatically. Is this the correct way mendix works or I am missing something over here. Please suggest the correct way to consume an external jar which itself depends on some other jar in mendix java action.
1 answers

This is indeed how Mendix works. Unfortunately, Mendix does not support a more modern dependency manager such as Maven or Gradle.
A way to workaround this is to find or prepare a so called fat-jar. This is a jar that contains all transitive dependencies for a java library. Then you can include this in Mendix as a single jar file. Doing this with Gradle is very easy and requires just a few lines of configuration. Here is a minimal example that packages selenium and all its dependencies in a fat jar using gradle

  1. Install gradle
  2. Run gradle init in an empty folder
  3. Put the following in build.gradle
plugins {
    id 'com.github.johnrengelman.shadow' version '5.1.0'  
    id 'java'

repositories {

dependencies {
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'

       4 . run gradle shadowJar

       5 . under build/libs you will find the generated fat jar

For more details check out this blog post: