Thursday, January 25, 2018

Oracle Weblogic - repair URL format in management REST messages

Whenever using the REST management API for Oracle Weblogic and you start to look into the JSON response files provided by Oracle Weblogic you will find that some (all) of the URL's in the JSON response are being constructed in a manner that slashes have been escaped in a generic manner. This is done, most likely, to ensure that nothing breaks when it is called by some other application. However, if you expect clean URL's this is a bit frustrating.

The example below showcases a part of the original JSON message as it it presented by the Weblogic REST API.

[vagrant@docker ~]$ curl -s --user weblogic -H "Accept: application/json"
Enter host password for user 'weblogic':
    "links": [
            "rel": "self",
            "href": "http:\/\/\/management\/weblogic"
            "rel": "canonical",
            "href": "http:\/\/\/management\/weblogic"
            "rel": "current",
            "href": "http:\/\/\/management\/weblogic\/"
    "items": [

If you are using Oracle Linux and if you are using curl to get the content of the file you can pipe the result into sed to ensure you remove the unwanted slashes from the URL's in the reponse.

For this you pipe the result into the below sed command to get the expected output:

| sed 's|[\,]||g'

This will give you the below clean output as an example:
[vagrant@docker ~]$ curl -s --user weblogic -H "Accept: application/json" | sed 's|[\,]||g'
Enter host password for user 'weblogic':
    "links": [
            "rel": "self"
            "href": ""
            "rel": "canonical"
            "href": ""
            "rel": "current"
            "href": ""
    "items": [

As you can see this is a much more clean way of looking at the response and much more easy to understand and handle from a coding point of view.

Oracle Weblogic - RESTful Management Services

When using Oracle Weblogic there are a couple of ways on how you can manage and monitor your deployment. In the most basic form a Weblogic deployment comes with a management service providing you a web console to do most monitoring and management tasks. Additionally you can do everything from the Oracle Linux command line and you will have the option to hook things up to an Oracle Enterprise manager setup to do a more consolidated way of management and monitoring.

Even though all the options mentioned above are good and have their pros and cons, another option is available which, for some reason, is not that well known. You can also use the RESTful Management Services with Oracle Weblogic 12C.

In some versions the REST API is enabled and in some not. To ensure that it is enabled you will have to check the general configuration for your domain. Under the advanced section you will find the "enable RESTfull Management Services" which you will have to ensure is activated to be able to make use of it.

The REST API services can now be accessed via http://{IP}:{port}/management/ . Having the option to administer and monitor your Weblogic instance via a REST API will increase the options on including it in a more automated fashion a lot more.

Whenever you are looking into automation and custom building some management solutions for IT footprints that include Weblogic the REST API's are a must look into area. 

Wednesday, January 24, 2018

Oracle Linux - installing WebLogic font error

When installing Oracle WebLogic server on Oracle Linux 7 one would expect an easy installation without any issues along the way. However, for some reason you might run into a strange error which is not that clear in the beginning on what the root cause might be. Installing the combination of Weblogic Server on A Oracle Linux 4.1.12-61.1.28.el7uek.x86_64 machine in combiantion with Java 9.0.4 caused the below strange issue as soon as the universal installer was about to start:

After some research it became clear that the issue is being caused by something as simple as missing fonts. In case you do encounter this issue the solution is to create a file /etc/fonts/local.conf and ensure the below content is in the file.

This should ensure your installer is working fine. 

Monday, January 15, 2018

Oracle Linux - convert XML to JSON

for people who are not that big a fan of XML files and still need to use XML structures every now and than when they get data from another system the xml2json solution might be a good thing to look into. The xml2json util is an opensource utility written in Python which will convert XML data into JSON data, as well as the other way arround. Using this on the Oracle Linux commandline when you code bash scripting can save a lot of time. Especially if you use xml2json in combination with jq you can save a lot of time in most cases.

As an example, we take an example XML file we found on the Microsoft website. And for convenience I create a gist from it so you can more easily grab it from the command line. The XML contains a list of books and the details of the books.

If we now would like to do something with it in a JSON format we can can use the xml2sjon command as shown below to get a valid JSON structure we can work with.

./ -t xml2json -o test1.json test1.xml --strip_text

As we have a JSON strcuture we can also use jq on it. You can find jq also on the Oracle YUM repository for your use. the xml2json utility is however not included in the Oracle YUM repository at this moment so you will have to grab it from github where you will find the file which you need to ensure is on your Oracle Linux system to be able to use it.

Saturday, January 06, 2018

Oracle Linux - Build Raspberry Pi SD card on a mac

Some time ago the people from the Oracle Linux team have taken the time to build a Oracle Linux 7 version for the Raspberry pi. The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries. The original model became far more popular than anticipated, selling outside its target market for uses such as robotics. It does not include peripherals (such as keyboards, mice and cases).
The operating system you use will have to be placed on a single Micro SD card. Using a mac the below command was useful to place the downloaded Oracle Linux 7 distribution for the Raspberry Pi on the Micro SD card:

sudo dd bs=1m if=/Users/louwersj/Downloads/rpi3-ol7.3-image.img of=/dev/disk2 conv=sync

If you face the issue of the below error, you most likely have mounted the SD card to your operating system. You will have to unmount it (via the disk utility app) and retry the command. Do note this could take some time to complete.

dd: /dev/disk2: Resource busy

A bit of care is needed when executing the command. If your Micro SD card is NOT mounted on /dev/disk2 you might run into the issue that you damage an existing other disk. Meaning, you need to check if /dev/disk2 is indeed the SD card in your case. Using a Mac you can use the below command to check your disks:

diskutil list

When your dd command is finished and you place the SD card in your Raspberry Pi and start it you should end up with a running Oracle Linux 7 operating system on your Raspberry Pi

Thursday, January 04, 2018

Oracle Dev – making Docker containers dynamic

When adopting Docker containers as a way to deploy applications and functionality in your landscape one of the tricks is to make sure you do not have to many different types of containers. Even though it is relatively simple to build a container and bake all configuration into it this might cause issues at a later stage. All container images need to be maintained and have some level of lifecycle management applied to them.

For this reason, it is better to limit the number of containers and ensure you can dynamically control the behaviour. This might cause a bit more work when developing the container image and will need to have some thinking about how to dynamically configure a container based upon a limited set of input parameters.

The reason you want to limit the number of parameters you provide a container during startup is that it is relative inflexible and will cause an additional burden on the teams responsible for ensuring the containers are always up and running in the right manner.

A better way is to store configuration data externally and have the container collect the configuration data based upon one (or max two) parameters. This can be for example the role of a container or the environment name where it will be deployed.

As an example, if we build a container for Oracle ORDS which will connect on one side to an Oracle database and on the other side provide a REST API interface to consumers you can make use of this principle. You do want to build a ORDS Docker container only once and would like to inform the container with a parameter which configuration details it needs to gather to start in the right role and manner within the landscape.

We have been building Oracle ORDS containers based upon Oracle Linux 7 Slim, as part of the script that starts ORDS in the container we have included parts that will ensure it will connect to a Consul Key Value store and collect the needed data to dynamically build the configuration files that are used by ORDS to start.

As an example, our ORDS container already knows it is an ORDS container, at startup we provide the input parameter that informs the container that the application name is “app0”. Based upon this knowledge the scripting will be able to fetch the needed configuration data from the Consul REST API.

In Consul we have provided all the needed KV pairs for the script to write the ORDS configuration. If we for example want to have the database hostname where an ORDS “app0” container needs to connect to we execute the below curl command to fetch the data:

curl -s | jq '.[].Value' | tr -d '"' | base64 –decode

The reason we use jq in the above example is to help with fetching "Value" from the JSON message we get returned by Consul. If we look at the full JSON message we get returned we see we get the below returned:

    "LockIndex": 0,
    "Key": "ords/app0/params/db.hostname",
    "Flags": 0,
    "Value": "MTkyLjE2OC41Ni4xMDE=",
    "CreateIndex": 8026,
    "ModifyIndex": 8047

In our case we are only interested in "value", by adding jq '.[].Value' to the command we will only get the content of "Value" returned. However, value is between double quotes and is a base64 encoded string. If we want to decode the base64 encoded string we need to feed this into the base64 command which will not work if we still have it wrapped in the double quotes. This is the reason we pipe the result first into the tr command to strip off the double quotes. The result is a clear base64 encoded string which we can decode using the base64 --decode command.

Placing Consul in the center
By placing Consul in the center of your deployment you will add a KV store which can be used in combination with your Docker containers to play a vital role in how containers are started. By ensuring you have a way of controlling how Consul is positioned per environment (think development, test, acceptance & production like environments) you can influence extremely well how containers are behaving in relation to the environment they are running in.

Building the right and useable structure in the Consul KV store is vital for building the level of flexibility you need in a dynamic landscape.

Spending the right amount of time in thinking about the KV structure which can be used in every environment and thinking about how containers will fetch data from a central Consul KV store in your landscape will require some time and effort, however, will provide you with a lot of benefits in the longer run when operating a wider container based footprint.