If you have multiple jar files with the same class, Mendix will pick one during the runtime. However, if it chooses the wrong version, your app can crash. The only way to avoid this is to ensure that you have only one jar file in the userlib that contains the specific class. The best way of figuring out which jars have duplicate classes is a time-consuming, trial and error method with a bit of luck. The Java Libraries feature shows you what Jars have identical classes and where they are located.
With the Java Libraries feature, we enable Mendix developers to remove redundant jar files and reduce the risks of applications hanging or crashing, improving the overall maintainability of your Mendix application.
How to solve it?
Solving the issue of duplicate classes is a complicated matter since there is no straightforward solution. In general duplicate classes are a bad idea and a sign of (unforced) redundancy, however, there might also be a valid reason behind it. Therefore we recommend you investigate the case(s) with duplicate classes by finding its references and trying to understand the relation between jars with duplicate classes.
- Please make a backup of all the jars and remove them from the userlib folder. Then you run your application, check what errors you get, and figure out what Jars you need to add to solve them. Repeat this until you get it to work.
- Try to determine what jars are causing the issue through the error messages and remove them.
Either way, it is not a solution but merely an approach that, in time, will solve the problem. But, unfortunately, it takes up a lot of time and is based on guessing.
The pain
The pain here is that it is challenging to determine what jar your Mendix application uses. Mendix doesn’t show you the dependencies, making it very difficult to solve the classloader issue.
Related ACR Rule
– Prevent duplicate classes in jars