Jump to content
  • This is a short guide on how to run the JDBC basic sample using TIBCO Businessworks? Container Edition with Docker

    Manoj Chaurasia

    Table of Contents

    This is a short guide on how to run the JDBC basic sample using TIBCO Businessworks? Container Edition with Docker.

    The complete info can be found on the TIBCO Businessworks documentation, the purpose of this post it's only to add extra info that can be helpful to run the sample. The sample by default use oracle, We use mysql because is the db used by the monitoring application by default so we have already the container running on my machine.

    The first step is to start the mysql container.

    We use the docker-compose.yml file provided with the SW. In this compose file are specified 4 containers (the monitoring app, mysql, postgres, and mongodb). For this sample is required only mysql so feel free to comment or delete the other containers or lines not needed.

    Note :

    We have modified the default file to add a network (my_network) so the containers mysql and monitoring app are on the same network and the monitoring app can talk to mysql directly. A monitoring app is not used in this sample but the same concept is used to link the sample JDBC application with the mysql db container at runtime.

     version: '3.0' services:    mysql_db:      image: mysql:5.5     container_name: mon-mysql     ports:       - "3306:3306"     environment:       MYSQL_DATABASE: bwcemon       MYSQL_ROOT_PASSWORD: admin     volumes:       - mysql_data:/var/lib/mysql       - ./dbscripts/mysql:/docker-entrypoint-initdb.d     networks:       - my_network    postgres_db:      image: postgres:latest     container_name: mon-postgres     ports:       - "5432:5432"     environment:       POSTGRES_DB: bwcemon       POSTGRES_PASSWORD: admin     volumes:       - postgres_data:/var/lib/postgres       - ./dbscripts/postgres:/docker-entrypoint-initdb.d     networks:       - my_network    mon_app:      build: .     ports:       - "8080:8080"     #-links:       #- mysql_db       #- postgres_db     environment:       DB_URL: mysql://admin:admin@mon-mysql:3306/bwcemon       PERSISTENCE_TYPE: mysql       #DB_URL: postgresql://admin:admin@mon-postgres:5432/bwcemon       #PERSISTENCE_TYPE: postgres     networks:       - my_network  volumes:   #mongo:   mysql_data:   postgres_data:  networks:   my_network: To start the containers defined in the file from the folder containg the yml file:  docker-compose up -d



    In this case, the folder containing the file is bwce-mon so the folder name is used as a prefix for the network. Run the docker-compose up in that folder so you can use the relative path used for the db scripts.

    We can see the my-sql container running :

     docker container ls CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES d8f187397115        mysql:latest        "docker-entrypoint.s?"   39 minutes ago      Up 39 minutes>3306/tcp   mon-mysql 3dd22c7b8ab6        bwcemon_mon_app     "npm start"              39 minutes ago      Up 39 minutes>8080/tcp   bwcemon_mon_app_1


    The compose file exposes the mysql port 3306 on the host. In this way, the db can be accessed externally by applications that are not in the same docker network (bwcemon_my_network) . You can use sql developer to browse the db. Now we can use the business studio to run our sample. In the attachment, the zip file with the sample modified to use mysql db. The only changes are to use the mysqldriver and the url string:



    The hostname is localhost. This is important. It means our application is connecting to mysql on the exposed port on the host.

    Note :

    We're using the bwcemon database used for the monitoring app. This is just for simplicity, feel free to create another one.

    How to install my-sql driver for local testing is not shown. It's the same procedure used for TIBCO Businessworks 6 and it's explained in the documentation.

    Once checked the sample is running fine at debug time we can move to the next step and create a container for our application. Remember to set Docker as a Container platform before creating the ear file and set the docker profile as default. To use JDBC driver in our container we need to add these drivers to the TIBCO Businessworks Container Edition runtime image (instructions on how to build the first time this image are in the doc).

    Move to the folder :

     /bwce/2.3/config/drivers/shells/jdbc.mysql.runtime/runtime/plugins and copy the folder :  com.tibco.bw.jdbc.datasourcefactory.mysql


    in the same directory where you have the following Dockerfile :

     FROM tibco/bwce:latest COPY com.tibco.bw.jdbc.datasourcefactory.mysql /resources/addons/jars/com.tibco.bw.jdbc.datasourcefactory.mysql


    This is only done to avoid inserting the full path in the copy statement if the dockerfile is in a different folder.

    tibco/bwce:latest is the default TIBCO Businessworks Container Edition image. We are going to create a new image adding another layer.

     docker build -t tibco/bwce_jdbc .


    tibco/bwce_jdbc is the name we chose for this image. The '.' is to specify to use of the Dockerfile in that folder. Now we can create a new image (or modify the existing one, your choice) by adding the ear file. As done for the previous image the simple way is to have the Dockerfile and the ear in the same folder :

     FROM tibco/bwce_jdbc:latest MAINTAINER Tibco ADD tibco.bwce.sample.palette.jdbc.Basic.application_1.0.0.ear /



     docker build -t jdbc_mysql .

    In this case, I called my image jdbc_mysql. The name can be of course changed. Now we have an image with the JDBC drivers and the ear, we can now create a container. Also in this case I use a compose file :

     version: '3.0' services:   bwce-jdbc-basic-app:     image: jdbc_mysql     container_name: bwce-jdbc-basic-app     environment:       DB_USERNAME: admin       DB_PASSWORD: admin       DB_URL: jdbc:mysql://mon-mysql:3306/bwcemon networks:   default:     external:       name: bwcemon_my_network


    There are 3 important things to note :

    1. image name is jdbc_mysql . If you change the image in the previous step, update the value in the compose file

    2. In theDB URL jdbc:mysql://mon-mysql:3306/bwcemon mon-mysql is used for the hostname (in the studio was localhost). In this case the container we'll connect directly to the mysql container and this is possible because they are on the same network. It works also if the mysql port is not externally exposed.

    3. bwcemon_mynetwork is added at the end of the file to specify to use an exiting network.

    So let's run this container:

     docker-compose up -d


    To check is running :

     docker container ls CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES 51dcafe10386        jdbc_mysql          "/scripts/start.sh"      46 seconds ago      Up 45 seconds                                bwce-jdbc-basic-app d8f187397115        mysql:latest        "docker-entrypoint.s?"   About an hour ago   Up About an hour>3306/tcp   mon-mysql 3dd22c7b8ab6        bwcemon_mon_app     "npm start"              About an hour ago   Up About an hour>8080/tcp   bwcemon_mon_app_1


    We can check the appnode logs:

     docker container logs bwce-jdbc-basic-app

    It's possible to check the containers are in the same network:

     docker network inspect bwcemon_my_network


    A subset of the output of the previous command show containers mon-mysql bwce-jdbc-basic-app are in the same network:

     Containers": {             "3dd22c7b8ab6a73798057f9357f421bc0192c2ccee85f9b3968cd30423058dcc": {                 "Name": "bwcemon_mon_app_1",                 "EndpointID": "363b6509560449dcb660654f707d3a6e309ae9777b4bba487d5569343793486f",                 "MacAddress": "02:42:ac:17:00:03",                 "IPv4Address": "",                 "IPv6Address": ""             },             "51dcafe103867f4712a35952a26b85f90c42dd54f9820ab313a9ab8e94d928fd": {                 "Name": "bwce-jdbc-basic-app",                 "EndpointID": "92b542ca3f33edea791fa5321a482b43c05b0917f1fa75f6fb3232fe5308289e",                 "MacAddress": "02:42:ac:17:00:05",                 "IPv4Address": "",                 "IPv6Address": ""             },             "c2ff062453e8fee8c465bce700eaf196e48c445acb1b8f993a7dbece76ea0717": {                 "Name": "mon-postgres",                 "EndpointID": "58b5907acc900fd40d85c28dc980e4bcab0a8eea2c24eb9ee8b792a7d7ac3ba6",                 "MacAddress": "02:42:ac:17:00:02",                 "IPv4Address": "",                 "IPv6Address": ""             },             "d8f18739711506581c4338acb599284c859d16a52b3698d5fac8a1aab3b9b5ce": {                 "Name": "mon-mysql",                 "EndpointID": "5d093629cb99c30450580ee001b2bb9fdb3cb638eb723d7ed501fbeae7f376ee",                 "MacAddress": "02:42:ac:17:00:04",                 "IPv4Address": "",                 "IPv6Address": ""             }         }


    This is only one of the possible configurations to use to run the sample. Having both containers in the same network is an easy way for them to communicate in a simple setup. Using a compose file is the best option to run a container so you have more control over the parameters used and the same file can be also used in a multi-node environment using Docker Swarm.

    Hope this guide is helpful.




    User Feedback

    Recommended Comments

    There are no comments to display.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...