Generate Barcode JavaAction works locally, but not in the cloud

0
Hello, we have a JavaAction for generating very specific barcodes. Locally everything works fine, but not in the cloud, there is always an error message. In the app, data from an Athena database is called, the following jar file can be found in the userlib: AthenaJDBC42-2.2.2.1000.jarThe error in the Java Action always comes at this line: Core.storeFileDocumentContent(getContext(), __destination, stream);This error message can then be found in the logs:Caused by: com.mendix.modules.microflowengine.MicroflowException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Barcode generation failed: NoClassDefFoundError: Could not initialize class com.amazonaws.services.s3.internal.ConstantsHas anyone ever had such a problem or a similar one and was able to solve it?
asked
3 answers
2

Hi,


This issue is not related to the barcode generation itself, but to a missing dependency in the cloud environment.

The key error is:

NoClassDefFoundError: Could not initialize class com.amazonaws.services.s3.internal.Constants

This indicates that required AWS SDK classes are not available at runtime in the Mendix cloud, even though it works locally.

Root cause

Your AthenaJDBC42-2.2.2.1000.jar depends on AWS SDK libraries, but those dependencies are either:

  • Not included in your /userlib, or
  • Conflicting with existing Mendix/runtime libraries

Locally, your IDE may be resolving them implicitly, but in the cloud only /userlib is used.

Working solution

1. Add missing AWS dependencies explicitly

Download and place the required AWS SDK JARs into /userlib, for example:

  • aws-java-sdk-core
  • aws-java-sdk-s3
  • aws-java-sdk-athena (if required)

Make sure versions are compatible with your Athena JDBC driver.

2. Avoid version conflicts

Mendix runtime already includes some AWS libraries. If versions mismatch, you can get this exact error.

To fix:

  • Use the same or compatible AWS SDK version as expected by the Athena driver
  • Remove duplicate/conflicting JARs from /userlib

3. Re-deploy cleanly

  • Do a full deployment (clean build)
  • Clear old deployment directory if needed

4. Verify in logs

After deployment, confirm:

  • No NoClassDefFoundError
  • No ClassNotFoundException for AWS classes

Important note

The error appears at:

Core.storeFileDocumentContent(...)

but that is only where the failure surfaces. The actual issue happens earlier when the AWS-dependent class is initialized.

This is a classic dependency/classpath issue in Mendix cloud. Ensuring all required AWS SDK JARs are present and version-aligned in /userlib resolves the problem reliably.

answered
1

Hi Anja,

Mendix always includes the AWS SDK, having these S3 jars, even if they are not present in the userlib or vendorlib folders, because S3 is natively used for file storage.

As of version 10.24.14, Mendix upgraded to a newer version of this SDK (see Mendix docs). Please check for which version the Java Action was written and which version you are currently running your Mendix app.

If that doesn't seem to be the cause, please also confirm the origin of the action (self-build?) and the cloud you're hosting (Mendix cloud?).

Kind regards,

Johan

answered
0

Hi Anja Sperling


You are missing one or more AWS SDK dependencies in your userlib when deployed to the cloud.

Athena JDBC drivers are not fully self-contained they rely on external AWS libraries unless you use a bundled version. The best way is to use the Athena with-dependencies driver so that it will come with all the jar it needs. If all jars are there properly cross check whether those jar are include in the project and there in userlib.

And more over check for any duplicate jars in userlib

aws-java-sdk-*.jar

aws-java-sdk-s3-*.jar

httpclient-*.jar

jackson-*.jar


I hope this helps

answered