Monday, 16 April 2018

ReactNative Error Command failed: xcrun instruments -s

For one of my "pet projects" (more on that in a lter post...) I am building a native a pp using ReactNative. After reinstalling MacOS on a brand new (and insanely fast) SSD drive I experienced the following error when starting up a ReactNative app in the simulator using the command react-native run-ios The error appearing was: react-native run-ios Scanning folders for symlinks in /projects/rn/tst1/node_modules (22ms) Found Xcode project tst1.xcodeproj xcrun: error: unable to find utility "instruments", not a developer tool or in PATH Command failed: xcrun instruments -s xcrun: error: unable to find utility "instruments", not a developer tool or in PATH The issue and solution is explained here: https://stackoverflow.com/questions/39778607/error-running-react-native-app-from-terminal-ios In the XCode Preferences you have to set the XCode Command Line Tool version:

Friday, 10 November 2017

Troubleshooting Angular CLI and Windows search indexing

I recently installed Node.js and Angular on my machine for some explorations. During the creation of my first test app using the Angular CLI I came across an annoying issue. I wanted to create a new project using the command
ng new my-demo-app
The following error occured:
30969 verbose unlock done using C:\Users\testuser\AppData\Roaming\npm-cache\_locks\staging-9ee6130cb5906a84.lock for D:\angular\my-demo-app\node_modules\.staging
30970 verbose stack Error: EPERM: operation not permitted, scandir 'd:\angular\my-demo-app\node_modules\fsevents\node_modules\getpass\node_modules'
30971 verbose cwd D:\angular\my-demo-app
30972 verbose Windows_NT 6.1.7601
30973 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--quiet" "install"
30974 verbose node v8.9.1
30975 verbose npm  v5.5.1
30976 error path D:\angular\my-demo-app\node_modules\fsevents\node_modules\getpass\node_modules
30977 error code EPERM
30978 error errno -4048
30979 error syscall scandir
30980 error Error: EPERM: operation not permitted, scandir 'D:\angular\my-demo-app\node_modules\fsevents\node_modules\getpass\node_modules'
30980 error  { Error: EPERM: operation not permitted, scandir 'D:\angular\my-demo-app\node_modules\fsevents\node_modules\getpass\node_modules'
30980 error   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\angular\\my-demo-app\\node_modules\\fsevents\\node_modules\\getpass\\node_modules\'',
30980 error   errno: -4048,
30980 error   code: 'EPERM',
30980 error   syscall: 'scandir',
30980 error   path: 'D:\\angular\\my-demo-app\\node_modules\\fsevents\\node_modules\\getpass\\node_modules' }
30981 error Please try running this command again as root/Administrator.
30982 verbose exit [ -4048, true ] 
Error -4048 seems to occur a lot and most of the time it is a permission issue. I first thought it has to do with some access issue of my user but after lot's of googling and trial and error I found an helpful hint in this forum: https://groups.google.com/forum/#!topic/angular/0iFLX6dEdeA User norricorp gave a hint that this could be related to windows search indexing. During the app-creation files and folders are newly created and then moved to other places. Windows indexing can interrupt this process as it keeps files to be (re-)moved open , so the whole process does not work properly. Once I disabled the windows indexing service the command worked properly :-)

Friday, 17 February 2017

Quick tip: moving an Eclipse project to another folder

I am restructuring some projects on my local machine. Usually I don't want to touch a running project but since I have the opportunity to use an internal Bitbucket server now at my workplace I also want to have all my local project source files on one location.
So this is how I moved the project source files to another location on my local machine:
  1. Open Eclipse and go to the Package Explorer view
  2. Check your project folder locations

    So the project is located in the folder D:\sample\net.mruhnau.sample.hello
  3. Right-click on the projec in the Package Explorer and choose Refactor --> Move...
  4. In the following dialog, choose the new folder location for the project and click OK.
This is it, Eclipse moves the files to the specified location. The advantage is that using this procedure will retain your workingsets as well as project information, history etc. I think this is a very smooth way of reorganizing project files.

Thursday, 16 February 2017

VOP: Mail database is not ready

We have been running an IBM Verse on Premise (VOP) pilot in our company for quite some time now. We started last year with the beta version of IBM Verse and upgraded toi the Gold version a couple of weeks ag. After the upgrade, I had an issue opening my inbox. The following error message occured:


Checking the underlying REST calls brought up this:
The REST call to retrieve the inbox returned an error "Mail database is not ready":
{"error" :
   {
       "failure" : "Database upgrade required",
        "message": "Mail database is not ready"
    }
}

The IBM Verse On-Premises 1.0 Administrator Documentation clarifies the required steps to prepare a mail file for VOP. Besides some new views, VOP also requires that Folder references are enabled for the mail file. A convert -m task rsolved the issue quickly for me.

So the steps to prepare a mail file for VOP are:
  • add additional views
  • enable full text index
  • enable folder references
 Thank you, Christian for your support on resolving the issue :-)

Wednesday, 3 February 2016

IBM Connect 2016 musings from remote

Disclaimer: I do not attend IBM Connect this year. So my conclusions are based on various news channels like Twitter and Blogs.
Nevertheless, I dare to reflect on some of the announcements that made the long way over the atlantic to good old Europe via Internet :-). As I am an application developer my list might be a bit development-centric though. So let's get started:
  • "most of XPages" will be open-sourced: I think this is a great step forward for the community of partnersa dn customers and also for IBM. Above all, this will protect the investment in XPages made by partners and customers. Furthermore this will empower us, the XPages community to understand, fix and extend the XPages runtime. And IBM will also benefit from this step as the community can provide fixes to the XPages runtime. 
  • Domino Designer will filter irrelevant metadata so the use of source control management systems will be improved.
  • Last but not least: we will finally get Java 8. Wooohoooo :-) The fact that the latest Mac client has Java 8 implemented already gave us hope.
  • IBM Verse on premise comes in 2016. This seems to be an ambitious timeline but I am very happy and relieved that verse on premise is finally coming. There are a lot of customers which still cannot or don't want to move Email to the cloud. And we, the internal service providers for collaboration systems struggle every day with new business requirements and shiny new tools from other vendors... The faster we can get our hands on Verse on premise the better for us ;-)
  • Domino and XPages and OpenNTF were part of the Opening General Session with a good story. This is just great!
  • I heard a lot about project Toscana which seems to be a kind of slackish Team collaboration for enterprises. If you don't know Slack already, check it ot...
  • Notes workspace comes to Verse and Connections ;-)

And a few more interesting links to check out:
As this (and the previous post) is based on contributions and information shared by other bloggers and members of the YellowVerse I want to take the chance to say Thank you! for sharing information with us who cannot stay on-site!




Tuesday, 2 February 2016

IBM Connect 2016: some interesting reviews (updated)

I am not attendting IBM Connect formerly known as Lotusphere this year. If you also didn't make it to Orlando this year I recommend these posts:
I may have missed many other interesting reviews, so feel free to post other links as comments :-)

Sunday, 31 January 2016

XPages on IBM Bluemix - working with wrong ID file

This is an easy one, but I still think it is worth mentioning all the different findings about a new technology like IBM Bluemix. During my tests with XPages on IBM Bluemix, I once made a little mistake. I forgot to switch to the IBM Bluemix ID file before I started modifying the design of the Bluemix app.



Obviously this is easily possible within Domino Designer. I was also able to deploy my changes to IBM Bluemix, but the new XPage could not be called due to an access issue we know from our good old domino environment too!


Signing the design element and another deployment to Bluemix solved the issue.
Good old Domino security - makes perfectly sense to me :-) It would be really nice to have an option to sign the design during the deployment process though!
(BTW: this is a rather old post which was still unpublished - but I think the deployment process is still the same)

Thursday, 3 December 2015

Image processing using JaxaXT in a Notes / Domino Agent



Today I stumbled across JavaXT. JavaXT is described as
a collection of Java libraries and utilities that provide a number of functions not available in the standard JDK. It is an extension of the Java core, written to simplify Java development.

I needed a library to resize images - from a good old java agent :-/  So far I used the Java Advanced Imaging API  but I had issues resizing some JPEG images. I was not able to find a correlation what caused the issues: And to be honest, my code was not very clean and neat so this was a good opportunity for improvements anyway. 
Using JavaXT I refactored my whole code to very few lines to do some resizing of images and save them in a NotesDatabase. 

This sample processes all Files in a given folder and resizes them to a fixed width of 200 pixel. 

import java.io.File;
import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      File[] files = new File("D:/tmp/pix/").listFiles();
      for (File file : files) {
        if (!file.isDirectory()) {
          String srcFileName = "D:/tmp/pix/" + file.getName();

          javaxt.io.Image image = new javaxt.io.Image(srcFileName);

          String destFileName = "D:/tmp/pix/resize/" + file.getName();
          image.setWidth(200);
          image.saveAs(destFileName);
          
        }
      }

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}

Job done! In a few lines of code :-)
Besides image processing JavaXT provides a lot more, I can only recommend to check it out. 
If you have suggestions , e. g. for a better approach  I am more than happy about your feedback.

Monday, 20 July 2015

Limitations with multiple instances of XPages applications on IBM Bluemix

I discovered some "limitations" or caveats while I was playing with XPages on IBM Bluemix tonight. I setup two instances of the To Do Boilerplate.

The first thing that annoyed me is that the import of the Bluemix Starter code of the second instance replaced the NSF of my first To Do app. The good news is that Domino Designer asks before the app will be overwritten :-)
If you choose "No", the Starter code won't be imported and you won't loose any data.
One disadvantage for XPages on Bluemix at the moment seems to be that the import always imports into the root folder of your Notes-Data-Directory. This will hopefully be fixed in a future version so that we can import projects into subdirectories. For other Bluemix apps the documentation explains that a developer should create a new subfolder to which he or she can extract the code to. The integration for XPages / Domino is a bit different from that process so this issue seems to be specific for XPages.

Another limitation or issue that came to my attention is that if you setup multiple instances of the same XPages Boilerplate these databases share the same ReplicaID. My two instances both have the ReplicaID 80257E5A:004A751B - and replication of the databases is enabled.


I am wondering if the ReplicaID is bound to the organisation or space or if it is shared across all instances of this Boilerplate. Furthermore I am not sure if this just due to the fact that XPages is still in experimental code. In my opinion this is something IBM should fix for productive use as this can bring lot's of trouble for the developers...(or maybe I am missing something?)

Getting started with XPages on IBM Bluemix - part II

I was able to setup my first XPages Demo Application on IBM Bluemix and prepare everything to start customizing the demo app in Domino Designer. Now I want to get my fingers on the database design

Before you get started with importing the database from Bluemix into Domino Designer, Designer has to be configured to work with Bluemix. In the preferences under "Domino Designer - IBM Bluemix" you can enter the Bluemix Server URL and your username and password (if that option is not available in Domino Designer you first have to install the correct version of the Extension Library).

The URL can be gathered from the "Start Coding" page on your Bluemix dashboard.



Click the "Test Connection" Button and see what happens.
Et Voila, I am connected :-)









Now switch to the IBM Bluemix ID previously downloaded. Otherwise your application will break once you deploy modifications signed with another ID file.

To open the downloaded database from the IBM Bluemix starter code into Domino Designer, click on Tools. There should be a new menue item "Import IBM Bluemix Starter Code".














Select the downloaded Starter code zip file and click next















 After that you have to specify a Bluemix Deployment directory. This will be used for storing the configuration of this app (manifest fle) as well as to store a deployment copy of your database (more on that t later).














Final step is the selection of the organisation and space in Bluemix (in my quick and dirty setup I didn$t setup the organisation properly).














Click Finish and the Bluemix database will be imported into Domino Designer - and can be modified from there.

So what I want to do now is to implement the first customization to my application. Let's create a new XPage and see if that works on the server...








After saving the page I deploy it to Bluemix using the new Bluemix Toolbar Icon











The deployment took a few minutes - as part of the deployment the application will be updated, stopped and started again. So I assume that most of the time is needed for restarting the app (in case of such a small change at least).
















Finally, the deployment was successful.










Now let's see if the new page can be accessed...








Works like a charm :-)

Saturday, 18 July 2015

Getting started with XPages on IBM Bluemix - part I





 Well, finally it is Friday. It's been a busy week with a nice flow of Domino related development work. And tonight I wanted to take the chance to get my fingers on XPages on IBM Bluemix. So this blog post is about the steps it took me to get started...


As I do not want this experimental stuff to interfere with my work related projects I first started to update my private laptop to the latest and greatest releases (Designer 9.0.1 FP4 and XPages Extension Library 901v00_13). After that I spent some time  messing around with my bluemix account and finally creating a new one (it seems my old one has become inactive since I haven't used for too long?). Finally I was able to log in to IBM Bluemix and found the .xsp runtime in the catalog.

Create your Bluemix app
  1. Login to IBM Bluemix at http://www.ibm.com/cloud-computing/bluemix/
  2. Open the Bluemix Catalog
  3. Scroll to the very end of the catalog to the "Bluemix Lab Catalog" (currently XPages on Bluemix are in experimental stage)
  4. I first created the sample todo app from the available boilerplate by selecting the option "XPages Web Starter" in the Boilerplate section. This is the same app as shown at IBM ConnectED 2015 in Orlando.
  5. Specify a name for the app and click create
  6. Wait until the app has been deployed automatically. This will take a couple of minutes (so I guess this is a good time to get a cold beer from the fridge)...
  7. Finally, the app should be up and running:

    And tatataaaa: it can be accessed at http://rum.mybluemix.net/ 

Connect Domino Designer to your IBM Bluemix app
So the next step is to get access to the app from Domino Designer.
  1. In the Dashboard menue click on "Start Coding"
  2. Click on the button "Download Starter Code". This will download a zip file containing the NSF with the application's design as well as an IBM Bluemix manifest file.
     

    BTW: The content of the manifest file can be displayed in Bluemix by clicking on the Environment Variables menue entry.
  3. Additionally you will need to download the ID file to use this NSF and to connect to theBluemix server. The ID File can be accessed from XPages NoSQL Data Service page. To open this page, open the dashboard and click on Services to access the Data Service page.

    and from there click on the "Launch" button on the top right corner.

  4. Download the ID file from the following page - and display the password (f you don't want to guess it... ;-))
Now you are ready for opening the database in Domino Designer - but this will be covered in my next blog post.

Wednesday, 18 March 2015

Your help needed: Jump-start guide to IBM Notes for Outlook users

At my workplace we are about to start with migrating a decent amount of users from Exchange/Outlook to Notes 9. Yes, this still happens and I am quite excited about that ;-)

After a user has been migrated we want to provide access to useful information. What we already have is explaining general things like FAQs about using Mail and Calendar, enable Out of Office, Signature etc...

On top of that, I thought it would be helpful if we provided a jump-start guide explaining a few key differences between Notes and Outlook.  I have to admit that in the 18 years of my Notes & Domino carreer I haven't really touched Outlook - neither at work not for personal reasons... In other words: I have no experience with Outlook and therefore I cannot be very helpful in depicting differencs between both systems.

So I would like to ask you to share your experience in what Outlook users struggle most with when switching over to Notes & Domino.
How do users work with Outlook and what adjustment problems do they have when using Notes?
What is missing in Notes and what can we offer as a substitute (public folders...)?


Looking forward to your feedback :-)

Tuesday, 17 March 2015

Apply Java Permissions to Domino Agents at runtime - again ;-)

This post is supposed to be read by developers only. Admins, please move on ;-)

I have an agent which is used to make SFTP file transfers from Domino to our corporate SAP system. It's an interesting project and I am exploring new stuff on a daily basis :-)

One technical issue I had to solve was this:
The agent opens an SFTP session on a remote host. Unfortunately this is forbidden by Java Policies specified in the java.policy file of the JVM of the Domino server.
The error is
java.lang.SecurityException: not allowed to make a socket connection to MYHOST.MYDOMAIN.COM,-1

So I started to dig into java.policy and java.pol files. And to be honest I was not that much pleased about the whole thing. At first I started to grant ANY permissions in the global section of my policy file:


 grant {   
  ...  
  permission java.security.AllPermission;  
  ...  
 };   

This works but it goes a bit over the top for a productive environment... Therefore I started to tweak the policies to only allow one specific application the network operations required to do the job. Honestly, it's been painful... I think I got it more or less configured properly. But given the fact that we run the application in three different environments (DEV/TEST/PROD) on multiple servers I hardly could imagine a proper rollout scenario. I always thought one of the major strengths of domino and NSF was that usually the design and resides in a single database - and the configuration usually resides in the application, a few system databases (+ notes.ini).

There must be an easier way to grant my code the execution rights it needs.
I finally found a solution to grant my code the needed execution rights at runtime of the agent. There is a whole Java package for handling the permissions - and in my particular case I was looking for SocketPermissions. The code to grant a socket permission is pretty straight forward:

 String hostAndPort = "myhost.mydomain.com:22";   
 SocketPermission p = new SocketPermission(hostAndPort,  
       "accept,connect,resolve");  


This will allow my code to make a network connection to the specified host on the specified port. There might be neater solutions to that problem and not every admin would be happy about that. In my opinion it is not very consistent for what you need to grant permissions in policy files (like network connects) but on the other hand file handling can be allowed on the agent security (Allow restricted operations).


Thursday, 5 June 2014

How to overcome Domino Webservice Timeout issues

Many of you might be aware of the restriction described here. I was not, and it caused me and my colleague quite some time to investigate, and fix this. Additionally, it caused us a lot of pain, because this issue increased the pressure on our project. So this might be relevant to some of you too...

So this is the story: We had a very annoying issue with a Domino WebService Consumer which was running in a timeout (almost all the time). As with many other projects the WebService was running fine in our Development environment. In both, our Integration as well as our Production Environment, the WebService always ran into the following error:

Error while reading data from server, Network operation did not complete 
in a reasonable amount of time; please retry

You have experienced this yourself too, don't you? Obviously, the amount of data in our development system was a lot smaller than in the integration and production environment. This is why the issue did not occur in our DEV system. But why the heck does the WebService stop at all??

After quite some research and opening a PMR we were pointed into te right direction:
The default Web Service Timeout is set to 60 seconds. It is a hard coded limitation, IBM seems not to be willing to fix this. To overcome the issue you have to be smarter than me and set the timeout on each WebService consumer individually at runtime. You can do this by calling the setTimeout() function of the WebService and pass the number of miliseconds.

More details can be  found in APAR LO48272: WEBSERIVCE CONSUMER BREAKS THE CONNECTION AFTER 60 SECONDS

Thursday, 8 May 2014

Extract Top-Level-Domain from a URL using client-side JavaScript


I needed a way to extract the top-level-domain from a url in a client-side javascript. I use the window.location object to achieve this (as I needed it in a CSJS anyway). There might be an easier way to do this, but this is my version of doing this:

 /*  
  * This function returns the TLD part of the url based on window.location => CSJS   
  */  
 function getTLD() {  
      var hostName = window.location.hostname;  
      var hostNameArray = hostName.split(".");  
      var posOfTld = hostNameArray.length - 1;  
      var tld = hostNameArray[posOfTld];  
      return tld;  
 }  

Looking forward to your approacches to to this ;-)

Thursday, 16 January 2014

Some thoughts on Source Control Management for XPages development

In my career as a Domino developer I have been playing with various Source Control Managent solutions already. I used TeamStudio Ciao! for many many years and this tool proved to be a life saver in many occasions already. So I owe some drinks to the guys from TeamStudio... (don't tell them!!)

Since IBM started opening Domino Designer in Release 8.5.3 (was it 8.5.2 ???) towards the "standard" SCM systems (Git, SVN, Mercurial) I have been playing with these options a lot. There was quite some pain involved, I lost source code, my repositories lost the link to the NSF/ODP, etc... No pain, no gain! The good news for me: Today I have a working environment which fits my needs :-)
My first steps were with SVN, but I admit that I was not able to get this setup running properly. Additionally, I was not too happy about the centralized approach. That said I started using Mercurial. Finally I ended up using Git, first the implementation in Domino Designer and nowadays using SourceTree. This setup provides me with such a high flexibility with regards to my work-related projects as well with my pet-projects.

The last missing bit so far was a proper SCM system. I have been looking around for a while and playing with various systems. As I am a corporate developer, using a hosted environment was not an option at all. So I was looking for a solution to run my self-hosted SCM server for my code coming from both, work-related projects as well as pet-projects. Finally, I think my journey has ended successfully (or at least I have reached an intermediate stop). I have played with GitLabHQ for a a while now and it looks very promising to me. I got it up and running relatively painless on a local Ubuntu VM. If you are looking for a self-hosted SCM server, I can highly recommend looking into GitLab (it is very focussed on SCM though).
There is a lot of useful information available in- and outside the XPages community. In the upcoming weeks I will describe my environment and approaches and specifically GitLab a little more in detail and hopefully add some more useful bits. So stay tuned!

Wednesday, 8 January 2014

Today I learned how to override session authentication using a web site rule

Did you know that you can override session based authentication based on URL patterns?‎ Yes? Lucky you, I didn`t. I honestly admit it: I am more a developer than an admin ;-). The feature dates back to R7.0.2 so I must have been missed something at that time...

In one of my projects domino provides a web service which can be consumed by a 3rd-party-system. All sites on that server (R8.5) are configured to use  session-based authentication. Since web services cannot authenticate via basic authentication (at least I did not get it working) I  was looking for a way to work around session based authentication. An additional web site involves a lot of effort and patience in this environment as there are quite a few people involved. 

Finally I got the right hint from the developer who consumes the web service. There is a web site rule for that! And I just did not know about it:-o

The setup is quite straight forward. Open an Internet Site document and click on Web Site - Create Rule and select "Override Session Authentication" as type of rule.
You can specify a URL pattern for which domino overrides session based authentication. On the one hand this provides a lot of flexibility‎. On the other hand, the pattern should be chosen with care. Wildcards (*) can be applied too.

So, this is it, my lesson learned today.

Thursday, 28 November 2013

Domino Web Services SSL Error - Keyring file not found

Today I came across a strange behaviour on our Domino (R9.0.1) server.
We have a database with a web service consumer. This Web Service consumer is used by a schedules background agent. The Web Service makes calls to a third party system using https.
The Domino Web Server is configured using Internet Site documents. All https traffic and calls to the server worked perfectly fine from the evry beginning.
Whenever the web service is called, the following error is thrown on the server console:

Error 4746 Web Service XXXXXXXX method XXXXX error 
Error connecting to 'xxxxx.xxxxx' on Keyring file not found

 So there seems to be something wrong with SSL certificates. After some time of trial and error with some more HTTP server restarts I found two helpful ressources on Google:

IBM Technote LO47722: "SSL ERROR: KEYRING FILE ACCESS ERROR" ON WEBSERVICE CONSUMER US ING INTERNET SITE DOCUMENTS

and a thread in the good, old notes.net IBM DeveloperWorks forum:
HTTPS Web Service - SSL Error: Keyring file not found

Both describe the exactly same scenario as used here. The solution is that in both places, the Internet Site as well as the Server document the specified SSL certificate must match. In general I think this makes perfectly sense. However, as soon as you enable "Load Internet configurations from Server\Internet Sites documents"

in the server document, you cannot specify the SSL certificate in the server doc anymore. What I had to do is temporarily turn this setting off, specify the correct SSL certificate and turn it on again. This is the bit that confused me here. The setting in the server document seems to be used for requests issued by the server itself (i. e. web service consumers).

To make a long story short: 
Make sure you have the same SSL certificates specified both in the server doc and the Internet site document.


Tuesday, 19 November 2013

DOTS: Logging to server console and log.nsf (part2)

In my previous blog post I showed how I implemented console logging in my DOTS projects. As I mentioned already yesterday, I prefer using logMessage respectively logException which are both implemented in the ServerConsole class of DOTS.
Both methods can easily be used directly inside your tasklet. When my first tasklet was growing, I started implmenting my own classes. Thereby I realised that logMessage and logException both are not available outside the tasklet class.

As these methods are implemented inside an own class "ServerConsole" I need an object of this class to use these methods. First I declare an object of type ServerConsole. In my case this object is in my class header and initialized in the class constructor. Thus I can use this object anywhere in my class - and even outside my class as it is declared as a public object.


In my DOTS projects I usually declare one ServerConsole object in one of my classes and use this object anywhere possible.

Beyond this approach I was pointed into two different directions today:

Rene Winkelmeyer mentioned another useful approach in a comment  here. If you want to log outside of the tasklet class you can easily use ServerTaskManager.getInstance().logMessageText("").


So if you only want to log messages, this might be the easiest solution for you. However, if you want to log messages and/or exceptions, the ServerConsole class is your friend...
OR you go down the road that Serdar suggested in his comment here. and use his Logger class.
He created an own TaskletLogger class which extends another Logger class. I haven't tried it out yet, but I am pretty sure it works great :)
Speaking of logger classes, I think I have to mention the XPages OpenLog Logger OpenNTF project by Paul Withers which can be used from OSGi extensions too.

To make a long story short: there are many options available - and while writing this update post I am realizing that this "blogging thing" revealed a lot of good new stuff to explore ;-)

Monday, 18 November 2013

DOTS: Logging to server console and log.nsf

In one of my current development projects I am developing a DOTS server task(let). One thing that I found very annoying is the logging part of DOTS. With logging, I essentially mean - at least in this post - an output to the server console and / or log.nsf. To achieve this, there are basically two different possibilities for logging in your DOTS projects.


Option 1:  System.out.println
As in other Java projects you can use System.out.println("your message") to print out message to the server console.
Running this little tasklet results in the following output on the server's console:

As you can see, the message is printed to the console. What you cannot see from here is that these messages are not save to log.nsf.

Option 2: logMessage
A way better logging is provided by a specific method logMessage("your message") which is part of the class com.ibm.dots.task.ServerConsole.
While your cord  resides inside the tasklet you can easily use this method instantly without any further declarations:
The output looks like that:


Using this method has several benefits:
  • Messages logged using the logMessage method are saved to log.nsf. 
  • You can see the date and time of the message.
  • In addition, the message indicates that it comes from the DOTS Tasklet "Helloworld".
In my opinion this is the clean way to go for logging from a DOTS tasklet to the console respectively log.nsf.

Moreover, the ServerConsole class provides another very useful method "logException" which accepts a throwable Java Exception which then will be printed to the console. In other words: you can use this method in any catch statemen to handle error logging to the server console / log.nsf.