Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

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, 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.

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 ;-)

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.



Saturday, 16 November 2013

iNotes calendar control - a good example to get started

In my previous blog post about the iNotes calendar control, I talked about some issues I was having with the iNotes calendar control which is part of the XPages Extension library. Yes, there are some issues, but to mke a long story short: the control is a great resource. If you want to learn more about this control, I can highly recommend to have look at the latest release of the TeamRoom Template which is deployed to your Lotus IBM Notes client.

If you want to learn more about the iNotes calendar control, check out the calendarView custom control.

BTW: On this control, I experience the same issue with the events as described here.

There is also a TeamRoom project available on OpenNTF (older version). And a demo video by Ed Brill demoing the TeamRoom template. The OpenNTF project description says:

This new TeamRoom OpenNTF 8.5.2 template has been built as a showcase application for the XPages Extension Library.  Approximately 80 different XPages Extension Library controls have been used in the construction of the TeamRoom OpenNTF 8.5.2 template, therefore making it a great learning resource on how to leverage the XPages Extension Library!

In my opinion this hits the nail on the head. This is excatly the reason why everyone learning developing XPages applications (beyond the entry level) should have a look at this template. Additionally this version of the TeamRoom template provides a much better Web UI. So your users might benefit from this template too :-)

Friday, 15 November 2013

XPages iNotes Calendar control - Events oddities

While working in one of our projects with the iNotes calendar control I experienced some oddities with the Events of this control. What I wanted to achieve is that some magic happens when clicking somewhere inside the control - e. g. opening the entry on which the user clicks... Should be pretty straightforward, I was thinking. Stupid me! As usual the devil's in the details.

I started by selecting the control and opening the events view and entered a simle JavaScript in the "onNewEntry" event. The script is supposed to show a message box after  clicking in an empty time slot.
 
In my case the result is that the event just doesn't get fired at all. I tested with FireFox, Google Chrome and even Internet Explorer. After some more testing and playing with the control I noticed an odd behaviour of Domino Designer:
As you can see on the Screenshot above, both events "onNewEntry" and "onOpenEntry" are marked blue which indicates, that there is some code in the event to be executed.  When I opened the "All Properties" view of the control to check the scripts there, I noticed that both events were empty, no script, nada, nil... Switching back to the events view, the scripts were there.





So that got me thinking. Once I entered the same code in an event from the "All Properties" view, the code is executed.

As far as I understand, the "Events" view is kind of buggy for at least this control. Besides the issue described above, I noticed that from the "Events" view I can enter CSJS as well as SSJS and Simple Actions. From the "All Properties" view, only CSJS can be used - and as far as I can see only CSJS is supported. Side note: I am using Domino Designer and Domino Server R 9.0.

 Lesson learned (again): All Properties is where you should do your work!The good news: as soon as you know how to work with this control, it works great :-)