Description:
We get the following error when trying to run an application built using the github connector. We get this issue only when we use a connector (can be Github/Twilio/etc. which have already been ported to SLP7) within a Ballerina application.
ballerina: Oh no, something really went wrong.
The `ballerina-internal.log` file located in the current directory
will indicate what the problem is.
We really appreciate it if you can share with us, the code
that broke Ballerina, together with this log file by creating a
bug report in https://github.com/ballerina-platform/ballerina-lang/issues.
The error log in the ballerina-internal.log file indicates the following,
[2020-12-09 13:28:29,546] SEVERE {b7a.log.crash} - ballerina/system/0_6_3/system
java.lang.NoClassDefFoundError: ballerina/system/0_6_3/system
at ballerina.file.0_6_1.$_init.$gen$$0046$0060init$0062(file:23)
at miyurud.github1.0_1_0.$_init.$moduleInit(github1)
at miyurud.github1.0_1_0.$_init.$lambda$$moduleInit$(github1)
at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(Scheduler.java:546)
at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:283)
at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:251)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: ballerina.system.0_6_3.system
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 7 more
Steps to reproduce:
ballerina new github1).main.bal file located inside the github1 folder and paste the following Ballerina code.import ballerina/io;
import ballerinax/github;
github:GitHubConfiguration gitHubConfig = {accessToken: ""};
github:Client githubClient = new (gitHubConfig);
public function main() {
var createdIssue = githubClient->createIssue("", "github-connector", "This is a conector test issue",
"This is the body of the test issue", ["bug", "critical"], [""]);
if (createdIssue is github:Issue) {
io:println("Issue Details: ", createdIssue);
} else {
io:println("Error: ", createdIssue);
}
}
Build the project (ballerina build github1)
ballerina run github1/target/bin/github1.jar)Affected Versions:
Ballerina SLP7
OS, DB, other environment details and versions:
Ubuntu 18.04
Related Issues (optional):
N/A
Suggested Labels (optional):
N/A
Suggested Assignees (optional):
N/A
Update: Twilio connector log had class not found error for config1.0.3, then I rebuilt the Twilio connector including config dependency in ballerina.toml. Then it was pushed to the central and pulled back then it worked fine.
I believe there should be a way to enforce the Ballerina library (e.g., connector) developers to declare their imports in their Ballerina.toml files. Otherwise, the same situation may arise again. For example, in this particular scenario the github connector got built successfully, and it was also pushed to the Ballerina central without any issues. The app developer who used the github connector also did not face any compilation error. But when running the app which used github connector the exception was thrown. Then only the connector developer gets to know that they must declare their connector code's dependencies in the connector project's Ballerina.toml file.
I checked the BALO of the github module and the dependency entry for ballerina/system which is used transitively (github -> file -> system) was missing in the dependencies list. When I tried building the github module locally, the ballerina/system dependency was there in the BALO and I could not reproduce the BadSad with the locally built BALO. I used the zip for building the github package.
@Dhanushkas, @miyurud Can you please let us know how you got the distribution? Was it using the installer, ballerina update ballerina dist pull or using the zip?
Yeah, looks like this module is pushed with a pre-release version of SLP7. Can we re-push this module and see?
Just to confirm, I also tried with the distribution gotten from the .deb and ballerina dist pull. None of them produced the BadSad.
Update: I re-pulled slp7 and tested it, this time it worked. However, We pushed the connector to ballerina central using docker environment in GitHub workflow. https://hub.docker.com/layers/ballerina/ballerina/swan-lake-preview7/images/sha256-cacc007f99a5ce1e90260b4a6887bcf3389b6a742ed5ccd179d7d66054bded34?context=explore
Did you re-push the GitHub package using SLP7?
Please reopen this if the issue still exists.
Yes, SL7 is used. Thank you all for the kind support
The ballerina GitHub connector code was forked and pushed to ballerina central with a private org and a name. then it worked and this issue was not there. However, the same issue occurred when the connector was released for ballerinax. Then the same repo was check by adding import ballerina/system as _ to a source file, then the internal log error was different and it was ClassNotFound for ballerina/config (1.0.3) and the previous error for ballerina/system has been resolved as I think.
We found the cause of this issue. While discussing with @sameerajayasoma, we figured out that this happens when a package is a transitive dependency as well as a test dependency. (i.e. system is a test dependency for github package and also a transitive dependency). @Dhanushkas The same applies to the config package and it was previously hidden due to the system package causing the BadSad before that. We will look into this and provide a fix in the next release
@Dhanushkas This issue will not be present if the tests are skipped while building the package. Therefore, until the fix is available, you can follow a workaround in the relevant workflow to get a working github package pushed to the Ballerina Central.
Break the package building into two stages as follows:
1) Ballerina test - ballerina test
2) Ballerina Build - ballerina build --skip-tests
@azinneera We tried the Github connector with the above temporary workaround by skipping tests before pushing the Balos to ballerina central. the workaround is functional, the Github connector works. Thank you all.
Closing since this is resolved by #28005
Most helpful comment
We found the cause of this issue. While discussing with @sameerajayasoma, we figured out that this happens when a package is a transitive dependency as well as a test dependency. (i.e. system is a test dependency for github package and also a transitive dependency). @Dhanushkas The same applies to the config package and it was previously hidden due to the system package causing the BadSad before that. We will look into this and provide a fix in the next release