Since CLM now ships the WebSphere Application Server Liberty Profile as default, you might want to be able to publish XML and other data similar to the easy way that was available in Tomcat, by just using the application server that is available. This avoids having to set up an additional Web or application server.
Problem
Sometimes it is necessary to provide access to some files using the HTTP/HTTPS protocol.
This is interesting for the Process Enactment Workshop, or if you want to publish your own XML data to be used with HTTP Filtered Value Sets, host custom Doors Next Extensions, or if you want to publish Build results.
It is convenient if there is already an application server available to host these files there and make them accessible, instead of having to set up a web server. This especially holds if it is necessary to provide the data using HTTPS, and not HTTP, because browsers these days reject to process content that is mixed from HTTP and HTTPS sources. The latter is important for Doors Next Generation extensions. Not having to set up a new server also avoids having to create a trusted certificate for it. It reduces the additional failure point, backup and maintenance and provides URI stability as well, since you don’t want to change the URI for the CLM applications hosted anyway.
Tomcat
With Tomcat, it was relatively easy to do that, by just adding a folder under \tomcat\webapps and placing your files there. Assuming the folder name is myfiles, Tomcat then provides the files with the public URI root https://serverpath:port/myfiles/fileName.
Another way was to simply drop the file into the tomcat/webapps/ROOT/ or a sub folder, which has the same effect.
Is there a similar way to achieve this with the WAS Liberty Profile shipped with CLM?
Example Scenario
Lets assume, like in the scenario explained in Publish and Host XML Data Using Tomcat – The Easy Way, we want to publish a file makers.xml to be accessible with a context root PEWEnactmentData on the server with the public URI root https://clm.example.com:9443/.
The expected outcome is to be able to access the XML file content using the URL https://clm.example.com:9443/PEWEnactmentData/makers.xml.
Solutions
There are two relative simple solutions for WAS Liberty. The solutions below are based on information from Lars, one of our WebSphere experts and the IBM WebSphere Application Server Liberty Profile Guide for Developers.
For WAS Liberty Profile, all solutions require to deploy an application. There are several ways to create and deploy an application in WAS Liberty Profile.
- Deploy an application in some folder and declare the context root and location of the application in the server.xml or specific location XML file
- Deploy an application in the dropins folder; for this to work, it is necessary to make sure the application server has the dropins monitoring enabled for this to work
Deploying an application in this context means
- Create a folder with some contend in a location (or copy the folder into the location)
- Deploy a compressed folder with some content
Please note: Any changes to any of the server configuration XML files are automatically picked up be WAS Liberty Profile. There is no need to reboot the server for the steps below to work.
1. Deploying an Application – Standard
The trick in this solution, is to pretend to deploy an uncompressed Web Application such as a WAR file. It is obviously possible to create a real WAR file or the structure that is contained in it, but that is not really necessary. See the last section here if you are interested in deploying the application as compressed WAR file.
1.1 Deploying the Application
The only thing necessary to trick the WAS Liberty Profile into making the data available with a correct context root is to create a folder with the context root as name and an extension .war, and to make the application location known in an XML file.
In the default setup of WAS Liberty Profile with CLM, after the first launch, all installed CLM applications end up in the folder <Install Folder>\server\liberty\servers\clm\apps. The screen shot below shows this structure.
The applications are deployed as compressed WAR file and have been extracted to a folder with the name of the application. As an example the CCM application (RTC) came shipped as ccm.war.zip and was extracted to a folder ccm.war. The context root of the CCM application is ccm, which is basically the name without the extension war. The same pattern holds for all the other applications.
It is possible to create a folder to host the files to be published. The folder should be named <context root>.war to result in an application with the desired context root.
Files within this folder will be available with their file name.
A file in that folder with the name <filename> will be accessible as <public URI root>/<context root>/<filename>.
If the files are within sub folders, the folder path within the root folder and the file name compose the file name part of the URL. For example, the root folder has a sub folder names myfiles and a file test.xml in it, the file is accessible as <public URI root>/<context root>/myfiles/test.xml.
In our example with the given public URI root being https://clm.example.com:9443/, the folder name <context root> being PEWEnactmentData and <filename> being makers.xml the URL would be https://clm.example.com:9443/PEWEnactmentData/makers.xml.
1.1 Declaring the Application Location
The WAS Liberty Profile needs to know which application has to be published and where to find its resources. WAS Liberty Profile defines an XML element to declare which application is located where. The element is <appliction…./>. It supports various attributes and can come in many different forms. The most important attributes are
- id: Must be unique and is used internally by the serve
- location: The path to the application resource
- context-root: The context root of the application
- name: The name of the application
- type: Specifies the type of application (war or ear)
The location and ID is required and either the name equal to the context root, or the context-root can be provided. The type can be omitted. I did not provide the ID and it worked for me, but since the server requires it, it should be provided. Use the same value as the name or context root for the ID.
It is necessary to add the application declaration to the server configuration for example by adding it to the server.xml file. In a CLM deployment a file appliction.xml is included in the server.xml, declaring all the applications and it makes sense to use that file instead.
Save the xml files after any change to activate the new setting. The server will pick up the change.
2. Deploying an Application – dropins
The WAS Liberty Profile has the capability to monitor a special dropins folder on a regular basis. If new content is detected, it is automatically made available by the server. The automatic monitoring needs to be enabled for this to work. A standard CLM deployment disables the monitoring to reduce server load.
2.1 Deploying the Application – dropins
In a default CLM install the dropins folder is located here:
<Install Folder>\server\liberty\servers\clm\dropins
Create a folder named <context root>.war in the dropins folder and add the files to publish. After detecting the addition, the files will be accessible like explained in 1.1.
The folder <Install Folder>\server\liberty\servers\clm\dropins should now look like below.
2.1 Enable Automatic Monitoring for Dropins
The automatic monitoring of the dropins folder is disabled for a standard CLM setup with WAS Liberty Profile. This saves processor cycles and I/O for the server operation. It has to be enabled once in the server.xml file for this solution to work. Find the XML element <applictionMonitor> and change the attribute dropinsEnabled from “false” to “true” and save the file. The image below shows the changed configuration file.
The attribute pollingRate determines how often the server checks the location for changes. Adjust the value to your needs.
Save the server.xml file after any change to activate the new setting. The server will pick up the change.
The XML file content should now be accessible.
Example 1 – Standard
In the example we want to publish a document with the URI https://clm.example.com:9443/<context root>/makers.xml, where <context root>=PEWEnactmentData. The public URI root is already given by the server set up.
1.1 Create the “Application”
As first step create the application. Create a new folder named PEWEnactmentData.war in the folder <Install Folder>\server\liberty\servers\clm\apps. The folder could be created anywhere, but it makes sense to put it where the other applications are. If it is necessary to use a different folder, for example to allow other users to modify the content, place the folder in a different location and note the path. The path to the location will become important in the next step.
Put the files to be published underneath this folder. In the given example, put the file makers.xml into the folder.
The folder structure should look like the image below:
1.2 Publish the “Application”
The WAS Liberty Profile needs to know which application has to be published and where to find its resources. WAS Liberty Profile defines an XML element to declare which application is located where. The element is <appliction…./>. It supports various attributes and can come in many different forms. The most important attributes are
- id: Must be unique and is used internally by the serve
- location: The path to the application resource
- context-root: The context root of the application
- name: The name of the application
- type: Specifies the type of application (war or ear)
The location and ID is required and either the name equal to the context root, or the context-root can be provided. The type can be omitted. I did not provide the ID and it worked for me, but since the server requires it, it should be provided. Use the same value as the name or context root for the ID.
The element can be put into several places. In a CLM installation, by default, the applications are declared in the file
<Install Folder>\server\liberty\servers\clm\conf\application.xml
The file is included in the file <Install Folder>\server\liberty\servers\clm\server.xml. It would be possible to place the application declaration in the file server.xml, but it seems to make more sense to put it into the file application.xml instead.
Add lines
<!– My Application –>
<application id=”PEWEnactmentData” name=”PEWEnactmentData” location=”${server.config.dir}/apps/PEWEnactmentData.war”/>
to the file application.xml and save the file.
The file should look like below:
In this case the location is relative to the server configuration folder which n our case is <Install Folder>\server\liberty\servers\clm\. The location could really be anywhere. If it is necessary to include a folder that, as an example, can be accessed by regular users, you could change the location to somewhere with less read and modification restrictions.
After the save of the application.xml, the published XML file should be accessible using the URL https://clm.example.com:9443/PEWEnactmentData/makers.xml.
The image below shows the browser access.
2. Deploying an Application – dropins
In the example we want to publish a document with the URI https://clm.example.com:9443/<context root>/makers.xml, where <context root>=PEWEnactmentData. The public URI root is already given by the server set up.
2.1 Create the “Application”
As first step create the application. Create a new folder named PEWEnactmentData.war in the folder <Install Folder>\server\liberty\servers\clm\dropins.
Put the files to be published underneath this folder. In the given example, put the file makers.xml into the folder.
The folder structure should look like the image below.
Assuming the automatic application monitoring is enabled, the file should be accessible after the next polling cycle, (at least after waiting the full pollingRate). If automatic application monitoring is not enabled, enable it as described in 2.2 and save the configuration file.
The XML file content should now be accessible using the URL https://clm.example.com:9443/PEWEnactmentData/makers.xml.
Deploying Compressed Folder Structures
It is also possible to publish real WAR, EAR similar to the way described above. For example create a WAR file as described in Publish XML Data Using Tomcat – Hotfix for The Process Enactment Workshop and attached to that post. Deploy the compressed WAR file, for example PEWEnactmentData.war in the dropins folder or declare it as an application and put it onto another location like explained below. This automatically deploys the application and makes the contained files accessible.
Just zipping the folder structure we created above into a zip file, name it PEWEnactmentData.war and trying to deploy does not seem to be working however. The WAR file needs to provide required supporting structures in this case.
Related Posts
The RM Extensions Hosting Guide for CLM 6.0.1 and later versions explain the dropins example as well.
Summary
This post shows how easy it is to publish supporting files on the WAS Liberty Profile. This is important if you want to host custom Doors Next Extensions, or if you want to publish your own XML data to be used with HTTP Filtered Value Sets, for the Process Enactment Workshop and it can possibly also used with Build result publishing. In the latter case, you would likely publish a root folder that contains all the build results.
As always I hope this post has some value to users out there, or is at least interesting to read.
Hello Ralph,
interesting arcticle. Thank you.
My Suggestion for such a Scenario within a licensed CLM world, is always use a front end IHS (IBM HTTP Server) with the IHS plugin for WAS to access the profile and handle this inside IHS. With this you have all the possibilities of an Apache webserver including folder security, etc..
The benefit is to hide the application server behind the webserver, make relocations easy and also the load for this special content is not done in the application Server.
regards
Guido
Thanks Guido. In general I would agree, especially if you need special user tp be able to modify and publish content. In this context it is more important to be able to provide something quick and not an an enterprise level, however.
If I decide to use dropins folder, then how can I specify context-root? inside xml file inside dropis or inside the ear file?
Also, is there anyway of defining external XML file to source from server.xml? I tried with (inside server.xml) -> but i doesn’t work:
-Processing included configuration resource: ……apps.xml
I FFDC1015I: An FFDC Incident has been created: “java.lang.NullPointerException com.ibm.ws.config.internal.WSConfigActivator 181” at ffdc_16.06.24_15.16.29.0.log
In the dropins example, as shown, the name of the war file determines the context root. The name of the XML is identical to the name of the XML file.
I don’t understand the rest of the question, obviously you can only publish the files you have and they have to be in the published folders.
Thank you. But still, is there any other way of defining the context root, as my ear files have version numbers in the filename.
Second question was more about configuring server.xml so it loads the rest of the configuration from other xml files. Similar to httpd.conf or nginx.conf where I have store application configuration, vhosts etc in a separate independent files, and just reference to those files from the server.xml file
I am not aware of any way to modify the context root in the dropins folder. I assume you can do that with some property in the EAR if you have a real EAR, but I am not sure and this is basically out of my scope.
An addition as far as I am concerned the scope in the post is to be able to load the XML file and use it in an RTC HTTP Filtered Value Set or be able to publish open social gadgets. The HTTP filtered value provider reads the XML specified and there is no redirect. The other automation have their own structure and expect exactly that structure.
Pingback: IMPORTANT LINKS FOR RTC – datamatoInfoCenter