NOC/BSM: Sending an e-mail from the client-side fscript

  • 7008211
  • 28-Mar-2011
  • 26-Jun-2012


Novell Operations Center Business Service Manager 4.5
Novell Operations Center Business Service Manager 4.7


Formula Script supports calling functions from various Java Packages. This way it is possible to write a script which sends an e-mail for example when specific alarm occurs, or when any given condition is met or exceeded. E-mail is being sent using Java package mail.jar, and NOC provides fscript sample code how to do it. This sample can be found in /ManagedObjects/database/scripts/mail directory.
The code works nicely from the server-side script, and sends e-mails as requested. However, when someone tries to run the same (or modified) code on the client-side, in the context of Java client VM, he/she receives the following error message:

TypeError: [JavaPackage javax.mail.Session.getInstance] is not a function.

The error happens when trying to get (or to create) mail session object in the scripting code, and it is caused by the fact that Java VM on the client side cannot reach requested mail.jar package.
Please notice, that fscript being run as a server-side script can use mail.jar package, because the package is always copied during the product installation phase into /ManagedObjects/image/lib directory.


This problem can be solved by modifying NOC Java client load process so that it also loads missing mail.jar package into its VM. For achieving this, following steps and modifications are required:

1) find mail.jar package in your /ManagedObjects/image/lib directory
2) copy it to a safe place, and self- sign it, using your valid server certificate, and jarsigner.exe application (it comes with Java JDK).
3) once the mail.jar is signed, copy it to /ManagedObjects/html/client/extensions directory
4) wait for a while for the update process which silently and automatically updates in the background your Java client JNLP file /ManagedObjects/html/client/launch.jnlp.
5) close all running Java apps on your client, and delete your Java cache (for example byt using command "javaws -viewer" on Win32).
6) Re-start your Java client, login, and give your script another try. It should work now, or at least you should no longer get the error message shown above.

Additional Information

The same approach can also be used when a function from another package is being called by customized Formula script on the client side, and the package is by default not available. The required package must be a) signed, and b) copied to /ManagedObjects/html/client/extensions directory, as described above. You should not forget that the memory space for client Java VM is usually limited, and set by default to a maximum of 256MBytes. (This can be changed from Configuration Manager -> Server -> Client Java Runtime Options.)
For more info on how to sign jar file please check NOC Security Management Guide, chapter 5.4.1.