ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.68k stars 753 forks source link

[Bug]: `NoClassDefFoundError` when running a Ballerina application with runtime platform dependencies in a docker container #43515

Open ayeshLK opened 1 month ago

ayeshLK commented 1 month ago

Description

Some Ballerina connectors have platform dependencies which required to be passed at runtime. Ballerina IBM CTG connector is one such connector and when running an application with the aforementioned connector, we get a NoClassDefFoundError for a platform dependency.

error: java.lang.NoClassDefFoundError {"message":"com/ibm/ctg/client/GatewayRequest","cause":error("java.lang.ClassNotFoundException",message="com.ibm.ctg.client.GatewayRequest")}
    at ballerinax.ibm.ctg.0.Client:externInit(client.bal:38)
       ballerinax.ibm.ctg.0.Client:init(client.bal:31)
       ayeshalmeida.ibm_ctg_simple.0:main(main.bal:11)

Steps to Reproduce

  1. Currently the IBM CTG connector is not released to the central. You could publish it to the local-central by executing the following command from the connector repository root [1]
    ./gradlew clean build -PpublishToLocalCentral=true
  1. Build the attached project [2] with --cloud=docker args.
    bal build --cloud=docker
  1. Run the docker container and check the logs.
    docker run -d ibm-ctg-simple:latest

[1] - https://github.com/ballerina-platform/module-ballerinax-ibm.ctg [2] - ibm-ctg-simple.zip

Affected Version(s)

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

ayeshLK commented 1 month ago

As a workaround we can add following configuration to the Cloud.toml and build the docker image.

[settings]
thinJar = false