Search code examples
wso2wso2-identity-server

wso2 Enabling Notifications for User Operations-template path error


i'm trying to enable notifactions for user operations on wso2-is 5.11 started via docker desktop on a windows11 machine.

somone can explain me what is wrong in that? P.S. sorry for my english

The problem is in runtime'cause the logs of docker displays the following error:

ERROR {org.wso2.carbon.identity.notification.mgt.NotificationMgtConfigBuilder} - Error while reading email template from location C:\Users\rocco\Documents\WSO2\docker-wso2\conf\is-as-km\repository\template.xml java.io.FileNotFoundException: C:\Users\rocco\Documents\WSO2\docker-wso2\conf\is-as-km\repository\template.xml (No such file or directory)

msg-mgt.properties file:

module.name.1=email
email.subscription.1=userOperation
email.subscription.userOperation.template=
C:\Users\rocco\Documents\WSO2\docker-wso2\conf\is-as- 
km\repository\template.xml
#email.subscription.userOperation.salutation=Admin
email.subscription.userOperation.subject=User operation 
change information
email.subscription.userOperation.endpoint.1=wso2iamtest
email.subscription.userOperation.endpoint.privateMail.address
[email protected]
#email.subscription.userOperation.endpoint.privateMail
.salutation=Admin private mail
#email.subscription.userOperation.endpoint.privateMail
.subject= 
User operation change information to private mail
#

Solution

  • As per the error log, you have configured the wrong path for the email template location.

    Even though you use a Windows machine, wso2is is running as a docker instance. WSO2 IS docker images are based on ubutu/ alpine/ centos OS base images (see the available variants here https://hub.docker.com/r/wso2/wso2is). So, you also should have used one of them.

    When configuring the path for email.subscription.userOperation.template=, we have to give the absolute path inside the WSO2 IS server where the particular template file is located.

    In order to find the exact path correctly,

    1. Log in to the docker container giving docker exec -it <container id> bash command
    2. Once you logged in, you can see wso2is-5.11.0 folder natigate to the correct location where your template is placed, and give pwd command. You can get the path to the file. Then append the file name and put the value for email.subscription.userOperation.template= property.

    As per the example, I created a file named template.txt. Added the following content to it.

    Hi {username}
    
    This is a test mail to your private mail. The operation occurred was: {operation}.
    

    Moved the created template into the docker container. Here you can see the path I have added the template file.

    enter image description here

    According to my case, the msg-mgt.properties file should have the config as follows.

    email.subscription.userOperation.template=/home/wso2carbon/wso2is-5.11.0/repository/template.txt