最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wso2 - Compilation error for social media demo (Ballerina training 1) - Stack Overflow

programmeradmin0浏览0评论

In the wso2 Ballerina training "Integration with Ballerina", the associated code project is social media demo

When I try to build it, I got a compilation error. This error occurs on the sub project "slack_message_sender".

error: compilation failed: The compiler extension in package 'ballerina:cloud:2.11.3' failed to complete. 'java.util.List io.ballerina.c2c.util.ProjectServiceInfo.getClientList()'

This seems to be an issue with a library (package ballerina:cloud).

I'm using Ballerina 2201.10.3 (Swan Lake Update 10) Language specification 2024R1

  • I tried to build the whole stack with ./build-docker-images.sh in WSL2 ubuntu.

  • I also tried to run only the slack_message_sender service in VS code With same result

Thank you in advance,
Best regards

If you want to reproduce the error

1/Set-up project

Create a folder named slack_message_sender
Create the 4 following files

Ballerina.toml

[package]
org = "wso2"
name = "slackmessagesender"
version = "0.1.0"
distribution = "2201.6.0"

[build-options]
cloud="docker"
observabilityIncluded = true

Cloud.toml

[container.image]
repository="wso2"
name="slack-message-sender"
tag="0.0.1"

[[container.copy.files]]
sourceFile="./Config.toml"
target="./Config.toml"

Config.toml

natsUrl = "nats://localhost:4222"

[slackConfig]
authToken = "token123"
channelName = "follower-notification"

Dependencies.toml

# AUTO-GENERATED FILE. DO NOT MODIFY.

# This file is auto-generated by Ballerina for managing dependency versions.
# It should not be modified by hand.

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.7.0"

[[package]]
org = "ballerina"
name = "auth"
version = "2.9.0"
dependencies = [
    {org = "ballerina", name = "crypto"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.array"},
    {org = "ballerina", name = "lang.string"},
    {org = "ballerina", name = "log"}
]

[[package]]
org = "ballerina"
name = "cache"
version = "3.6.0"
dependencies = [
    {org = "ballerina", name = "constraint"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "task"},
    {org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "cloud"
version = "2.10.0"
modules = [
    {org = "ballerina", packageName = "cloud", moduleName = "cloud"}
]

[[package]]
org = "ballerina"
name = "constraint"
version = "1.3.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "crypto"
version = "2.4.1"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "file"
version = "1.8.1"
dependencies = [
    {org = "ballerina", name = "io"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "os"},
    {org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "http"
version = "2.9.11"
dependencies = [
    {org = "ballerina", name = "auth"},
    {org = "ballerina", name = "cache"},
    {org = "ballerina", name = "constraint"},
    {org = "ballerina", name = "crypto"},
    {org = "ballerina", name = "file"},
    {org = "ballerina", name = "io"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "jwt"},
    {org = "ballerina", name = "lang.array"},
    {org = "ballerina", name = "lang.decimal"},
    {org = "ballerina", name = "lang.int"},
    {org = "ballerina", name = "lang.regexp"},
    {org = "ballerina", name = "lang.runtime"},
    {org = "ballerina", name = "lang.string"},
    {org = "ballerina", name = "lang.value"},
    {org = "ballerina", name = "log"},
    {org = "ballerina", name = "mime"},
    {org = "ballerina", name = "oauth2"},
    {org = "ballerina", name = "observe"},
    {org = "ballerina", name = "time"},
    {org = "ballerina", name = "url"}
]

[[package]]
org = "ballerina"
name = "io"
version = "1.5.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.value"}
]

[[package]]
org = "ballerina"
name = "jballerina.java"
version = "0.0.0"

[[package]]
org = "ballerina"
name = "jwt"
version = "2.9.0"
dependencies = [
    {org = "ballerina", name = "cache"},
    {org = "ballerina", name = "crypto"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.int"},
    {org = "ballerina", name = "lang.string"},
    {org = "ballerina", name = "log"},
    {org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.object"}
]

[[package]]
org = "ballerina"
name = "lang.array"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.__internal"}
]

[[package]]
org = "ballerina"
name = "lang.decimal"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.int"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.__internal"},
    {org = "ballerina", name = "lang.object"}
]

[[package]]
org = "ballerina"
name = "lang.object"
version = "0.0.0"

[[package]]
org = "ballerina"
name = "lang.regexp"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.runtime"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.string"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.regexp"}
]

[[package]]
org = "ballerina"
name = "lang.value"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "log"
version = "2.8.1"
dependencies = [
    {org = "ballerina", name = "io"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.value"},
    {org = "ballerina", name = "observe"}
]
modules = [
    {org = "ballerina", packageName = "log", moduleName = "log"}
]

[[package]]
org = "ballerina"
name = "mime"
version = "2.8.0"
dependencies = [
    {org = "ballerina", name = "io"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.int"}
]

[[package]]
org = "ballerina"
name = "oauth2"
version = "2.9.0"
dependencies = [
    {org = "ballerina", name = "cache"},
    {org = "ballerina", name = "crypto"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "log"},
    {org = "ballerina", name = "time"},
    {org = "ballerina", name = "url"}
]

[[package]]
org = "ballerina"
name = "observe"
version = "1.1.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "os"
version = "1.7.0"
dependencies = [
    {org = "ballerina", name = "io"},
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "regex"
version = "1.4.3"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "lang.string"}
]

[[package]]
org = "ballerina"
name = "task"
version = "2.4.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "time"
version = "2.3.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "url"
version = "2.3.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerinai"
name = "observe"
version = "0.0.0"
dependencies = [
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerina", name = "observe"}
]
modules = [
    {org = "ballerinai", packageName = "observe", moduleName = "observe"}
]

[[package]]
org = "ballerinax"
name = "client.config"
version = "1.0.1"
dependencies = [
    {org = "ballerina", name = "http"},
    {org = "ballerina", name = "oauth2"}
]

[[package]]
org = "ballerinax"
name = "nats"
version = "2.9.1"
dependencies = [
    {org = "ballerina", name = "crypto"},
    {org = "ballerina", name = "jballerina.java"},
    {org = "ballerinai", name = "observe"}
]
modules = [
    {org = "ballerinax", packageName = "nats", moduleName = "nats"}
]

[[package]]
org = "ballerinax"
name = "slack"
version = "3.3.0"
dependencies = [
    {org = "ballerina", name = "http"},
    {org = "ballerina", name = "lang.runtime"},
    {org = "ballerina", name = "log"},
    {org = "ballerina", name = "mime"},
    {org = "ballerina", name = "os"},
    {org = "ballerina", name = "regex"},
    {org = "ballerina", name = "url"},
    {org = "ballerinax", name = "client.config"}
]
modules = [
    {org = "ballerinax", packageName = "slack", moduleName = "slack"}
]

[[package]]
org = "wso2"
name = "slackmessagesender"
version = "0.1.0"
dependencies = [
    {org = "ballerina", name = "cloud"},
    {org = "ballerina", name = "log"},
    {org = "ballerinai", name = "observe"},
    {org = "ballerinax", name = "nats"},
    {org = "ballerinax", name = "slack"}
]
modules = [
    {org = "wso2", packageName = "slackmessagesender", moduleName = "slackmessagesender"}
]

slack_message_sender.bal

// Copyright (c) 2023, WSO2 LLC. () All Rights Reserved.
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// .0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/log;
import ballerinax/nats;
import ballerinax/slack;

configurable string natsUrl = ?;

type SlackConfig record {|
    string authToken;
    string channelName;
|};
configurable SlackConfig slackConfig = ?;
final slack:Client slackClient = check new({
    auth: {
        token: slackConfig.authToken
    }
});

type NotificationEvent record {|
    int leaderId;
|};

service "ballerina.social.media" on new nats:Listener(natsUrl) {
    public function init() returns error? {
        log:printInfo("Slack message sender service started");
    }

    remote function onMessage(NotificationEvent event) returns error? {
        check sendSlackMessage(event);
    }
}

function sendSlackMessage(NotificationEvent event) returns error? {
    slack:Message message = {
        channelName: slackConfig.channelName,
        text: string `User ${event.leaderId} has a new post.`
    };
    _ = check slackClient->postMessage(message);
}

2/ Install Ballerina : /

3/ Go to VS Code

  1. Install Ballerina plugin

  2. Restart VS Code

  3. Browse the folder \slack_message_sender in workspace

  4. execute in terminal

bal run
发布评论

评论列表(0)

  1. 暂无评论