Trials with JPA and XPages


Don’t get me wrong, I love working with Domino and documents and all that ūüėČ , but with XPages I sometimes want to use good old fashioned SQL or even hybrid solutions. I do not want to be bothered with writing sql statements myself in the DAO classes, and I just want to use a prebuilt solution that just works. Enter JPA.

Before I go too much into this, I want to thank the guys on Slack for giving me a hand with the bits and pieces of this. I had a great deal of problems getting this thing going and it is still very far from perfect. I can at least say, however, that it runs.

Quick trial history

I started out with a simple PoC concept of trying to build a type of registry for DVDs I have. (Not creative, just quick and simple). I also decided to do this with eclipselink and built in Eclipse mars. I quickly built a few entity classes and I used the xml orm to map those entities to the database. When this was done, I exported that project to a jar file and then imported that jar into an *.nsf. This first try failed. I am sure I can think of numerous reasons why it did not work. The main issue I had was that the persistence unit I tried to configure could not be found on the runtime. At this point, I copied the eclipselink jars into the nsf directly, and copied the entities into the .nsf.  In other words, the JPA Layer was no longer its own single jar. This allowed me to try to move the configuration files around to other locations. I tried everything I could think of. Fail.

Rethink and Rework

(in other words, ask around…)

Let me just say that if you are not already a member of the XPages Slack community, why aren’t you? JOIN!!!

I went into the random channel, and posted a general question if anyone had success with JPA and XPages. Jesse Gallagher pointed out this post by Toby Samples which uses the hibernate JPA framework. I had seen this presentation before, but I must admit that it lacks the meat and potatoes needed to get it off the ground.  Dont get me wrong, it is a great resource! The other reason why I did not do much with this at first is that it was done in eclipse and not Notes Designer. Most of the stuff that I program for XPages is done directly in Designer and not in eclipse. After talking to the guys on Slack, and seeing that Toby Samples had success with hibernate, I decided to indeed give it a try.

Downloading Hibernate

In the slides (see the above link), Toby describes talks about hibernate tools being downloaded and installed in eclipse. As we all know, Notes is now based off of eclipse, albeit an older version of eclipse…¬† After a lot of searching, I did find an updateSite with the tools and I downloaded a copy of them. I then installed them onto my client as a Widget and also onto the server. This really did nothing worth while.¬† I could not access the tools in designer, nor were they available on the server. I deleted them pretty quickly. Instead, I¬†found this site to download an older version of the ORM. It is necessary to take the 4.3.11 version because Notes/Domino runs on a bitterly out-dated version of java. Once this is downloaded, I imported the required jars into my .nsf. I also put these jars into the <domino>/jvm/lib/etc/ directory as described in the slides. The only issues I had at this point was that designer couldn’t process the source quickly enough to give me the code suggestions and I had the feeling that designer was always a step away from crashing.¬† Indeed it did crash once or twice… (After a system restart it seems to have gotten better)

Configuration and Setup

The first thing that I did was to create the hibernate.cfg.xml file. This is all pretty straight forward.¬† I am also not going to discuss how this file is to be created, but I will show you my copy…

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC 
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

   <session-factory name="hibernateSessionFactory">
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="hibernate.connection.password">****</property>
            <property name="hibernate.connection.url">jdbc:mysql://</property>
            <property name="hibernate.connection.username">DB_Programmatic_User</property>
            <property name="hibernate.show_sql">true</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
            <property name="">false</property>
            <!-- <property name="">create</property>  -->

            <mapping class="de.domain..bluemix.jpa.entities.Actor"></mapping>
            <mapping class="de.domain.bluemix.jpa.entities.DVD"></mapping>
            <mapping class="de.domain.jpa.entities.Genre"></mapping>	

The second thing I did was create an application listener with static information for creating sessions.



import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;


public class PersistenceManager implements Serializable, ApplicationListener2 {

      private static final long serialVersionUID = 1L;

      private static SessionFactory sessionFactory;

      private static boolean init = false;
      public static SessionFactory getSessionFactory() {
            if((sessionFactory == null) || (sessionFactory.isClosed())){
                  throw new IllegalStateException("Session Factory is null or closed!");
            return sessionFactory;
      public static boolean isInit() {
            return init;
      private void init(){
                        System.out.println("Initializing Session Factory");
                        Configuration conf = new Configuration().configure();
                        ServiceRegistry serviceRegistry= new StandardServiceRegistryBuilder().applySettings(conf.getProperties()).build();
                        sessionFactory = conf.buildSessionFactory(serviceRegistry);
                        init = true;
                  } catch(Throwable t){

      public void reInit(){
      private void destroy(){
            System.out.println("Destroying Entity Manager Factory");
            init = false;
            if(sessionFactory != null)	sessionFactory.close();
            sessionFactory = null;

      public void applicationCreated(ApplicationEx arg0) {

      public void applicationDestroyed(ApplicationEx arg0) {

      public void applicationRefreshed(ApplicationEx arg0) {

The point of the application listener is to make sure clean up is done correctly and to make sure that everything is initialized correctly.  It probably is not needed in this way, but I found it at the very least to be a cool idea. This class must also be registered. Here is a screen shot with the location of these files.







Primary Problem

This configuration worked…. almost. I kept getting security exceptions. The runtime was not being granted the permissions it needed to run the code. Only after I added the following lines to the java.policy document was I able to get the code to execute properly.

permission java.lang.RuntimePermission "getClassLoader"; 
permission java.lang.RuntimePermission "setContextClassLoader"; 

permission java.util.PropertyPermission "jboss.i18n.generate-proxies" "write"

This is a situation that I find sucky. It is alright for a test environment, but I would not want to mess with the policy file for an end-customer. My question is, does anyone have a possible solution for this?


It is possible to use JPA and it works well,  but I am not happy about the wide-open security window that was necessary in order to get it to work.

One more time, thank you to those on Slack who gave me a hand…

Toby Samples, David Leedy, Jesse Gallagher, and others who had hints…


Attachments and Java Beans

Up until this point, I must admit that I have been lazy. Even though most of the XPages I have created in the last two years have made extensive use of Java Beans, I have left the attachments to the XspDocument and the typical upload and download controls. I did not want to open that can of worms and just wanted to stick with what I know works. Well, that is dumb. It is fine for one or two minor applications that are never going to be used anyway, but when it comes down to it, I want it to be correct. Today, I started that adventure and, with all new things, a google search was performed for anything that could help me and point me in the correct direction. (Honestly, what did you old folks do without search engines? I’d be lost! Or at the very least spending 10 hours a day at the public library!) What I did not find was a document that contained upload and download information. Since I do not want to loose what I found today, I decided to write a quick post. Thank you to everyone that I am stealing from to write this…. ūüėõ

The first thing that I noticed was that my concept was faulty. At least I think it was. I wanted to have a single file in my Java Bean that I could upload and download at will and access and save in my DAO layer. Of course I could be mistaken, but it does not seem to work that way. Uploading documents and downloading them again needs to be performed in two different actions, and in two different ways, and with different objects. Futhermore, I do not even offer both functions on the same page, though both are possible with the same bean.

First off, my test bean is very simple. If I were to extract an interface (just to get a quick look at what the bean contains, it would hold the following information

public interface IFileTest {

* This function contains the information to save the document. Normally, I do this in a seperate DAO layer Object.
* The example that I used had the majority of the information in one single class.
* I did not experiment as I wanted to keep everything as simple as possible. Such experiments are further on my to-do list.
public abstract void save() throws Exception;

* This function contains the logic to download the attachement. It is performed in a separate XPage containing only this function call.
public abstract void downloadAttachment() throws Exception;

* This function returns a string that points to the xpages with the download attachment function call.
public abstract String getDownloadURL();

* This function will read the parameters from the URL in order to initialize the data for the viewscoped bean.
* Normally with the Beans I create, this function will access the DAO and set the data in an object contained by this Bean.
* This Bean is a controller in the MVC design pattern.
public abstract void init();

* I just find this helpful.
public abstract String getUnid();

* This object is used ONLY in the upload core XPage control.
public abstract UploadedFile getFile();

public abstract void setFile(UploadedFile file);



As i said, this test is done with as simple a construct as possible.

After this was completed, I worked on uploading a document. It seemed the most logical starting point. My primary source for this was a StackOverflow question posted by David Leedy so, note that the following code is primarily coming from Mark Leusink, the accepted answerer of Mr. Leedy’s question. The first part is the most simple. I have a property in my Bean that is of type . I have a corresponding getter/setter pair. I use EL to link the core control for uploading data to the bean. The real magic happens in the save logic.

public void save() throws Exception{
    /* I use the openNTF Domino API (ODA) for nearly all of my
     * applications. If this was not the case, we would have to worry about
     * proper recycling. Keep in mind that this is also just a test. Normally
     * my routines have much cleaner error handling.
     * The following statement uses a utility that I built that helps me get
     * key objects. I am assuming here that you know how to get a handle on the current
     * document. 
    Document doc = ODASessionHelper.getCurrentDatabase().createDocument();
    doc.replaceItemValue(FIELD_FORM, FORM_NAME);
    // file is and instance of UploadedFIle. This is the Property that is bound to the core FileUpload control
    if(file != null){ 
      IUploadedFile fl = file.getUploadedFile();
      //File is the standard variant.
      File file = fl.getServerFile();
      String fileName = fl.getClientFileName();
      // this gave me ONLY the name of the file without any path information.
      System.out.println(String.format("clientFileName: '%s'", fileName)); 
      // on my system, this gave the character ";"
      System.out.println(String.format("seperator is '%s'", File.pathSeparator));
      // This gives you the location of the file that was uploaded by the control on the server.
      File realNameFile = new File(file.getAbsoluteFile() + File.pathSeparator + fileName);
      System.out.println(String.format("realFile name: '%s'", realNameFile.getAbsoluteFile()));
      boolean renamedFile = file.renameTo(realNameFile);
        //typical code to attach a file to a document.
        RichTextItem body = doc.createRichTextItem(FIELD_BODY);
        body.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", realNameFile.getAbsolutePath(), null);
      } else {
        throw new Exception("file could not be renamed");
       * Normally at this stage, I save the UNID so that I get that document again
       * to prevent a bunch of new documents being created.  This is just me being 
       * lazy and wanting to get a test out ASAP.
    } else {
      throw new NullPointerException("file was null");

The only issue that I have with the above code is that the new name of the attachment is a bit messed up. I do not know if it is because the operating system is windows, or if it is because of the domino version, but the attachment name is changed to “_<strangenumbers>tmp;realAttachmentName.txt” . This is because File.pathSeperator is a semicolon. I have a workaround for this in my download function, but a workaround is still only a workaround.

As I previously said, I did not find a post with both upload and download functionality explained. I did find an awesome article on openNTF regarding downloading attachments programmatically. So, here is a quick shout-out to Naveen Maurya who posted the XSnippet. In the example provided, an XPage was built which called a server-side JavaScript function which got a handle on the FacesContext and the server response to download all files in a zip file. I just edited this to be run in my Bean and not in JavaScript.

   * same disclaimer. I wanted to this quickly. Normally my error handling is 
   * significantly better. I just want the theory here.
  public void downloadAttachment() throws Exception{
    Database db = null;
    Document doc = null;
    OutputStream stream = null;
    ZipOutputStream out = null;
    BufferedInputStream in = null;
      if(StringHelper.isNullOrEmpty(getUnid())) throw new IllegalStateException("Unid is null");
      // again, I am using ODA, and this is just a way to get the current database.
      db = ODASessionHelper.getCurrentDatabase();
       * I normally do this in multiple steps.
       * 1. try to get the document with the UNID
       * 2. try to get the document with the noteID
      doc = db.getDocumentByUNID(getUnid());
        throw new IllegalStateException("body not located");
      } else {
        Item item = doc.getFirstItem(FIELD_BODY);
        if(!(item instanceof RichTextItem)){
          // I would assume that I would have to come up with a MIME variant as well.
          throw new IllegalStateException("item is not of type richtext");
        } else {
          // normally I ask if item is instanceof RichTextItem
          RichTextItem body = (RichTextItem)item;
          Vector objs = body.getEmbeddedObjects();
            throw new IllegalStateException("body has no objects to download");
          } else {
            ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
            // javax.servlet.http.HttpServletResponse;
            HttpServletResponse response = (HttpServletResponse)extContext.getResponse();
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", -1);
            response.setContentType("application/zip"); // change this for different types.
            // I gave a static name to my zip file, but the original code was dynamic
            response.setHeader("Content-Disposition", "attachment;");
            stream = response.getOutputStream();
            out = new ZipOutputStream(stream);
            for(EmbeddedObject att : objs){
              in = new BufferedInputStream(att.getInputStream());
              int length = in.available();
              byte[] data = new byte[length];
    , 0, length);
              String nm = att.getName();
               * This is my workaround for the file names. Although they are saved in the document
               * with the incorrect name, I could at least download them again with the proper name.
              ZipEntry entry = new ZipEntry(nm.contains(";") ? StringHelper.rightSubstring(nm, ";") : nm);
          // cleanup should be done properly.  this is a 'do as I say, not as I do' moment.....
    } catch(Exception e){
      // very nasty error handling....
      throw e;

In conclusion, I have a test XPage application with one form, and with two xpages. The one xpage allows saving attachments. It has the File Upload control available by the XPages core and a save button. The second XPage is only used for downloading the attachments. It holds no content, but gets the file to download via the HTTPServletResponse in the beforeRenderResponse XPage action. The UNID of the document is passed with the URL.

Although not implemented in an xpage, I also built the logic to open the URL in a new window using client side javascript:"#{javascript:FileTest.getDownloadURL()}", "_blank");

FileTest in the above example is the name of the bean as configured in the FacesConfig.xml file.

My next steps would be

  • to build a view with which I could display the file names and other typical information available for file downloads
  • export files without being compressed into a zip file
  • it goes without saying that I would have to refine the above functions and build in proper cleanup and error handling

Happy Programming!!

OutOfMemoryError Follow Up

After spending a great deal of time testing, looking… showering…. I finally managed to locate an error that was causing the problem, but this requires knowledge of how the JVM works in order to fully understand.¬† At its core, however, is what I see as a bug in the domino API. (NOT ODA!)

Just to quickly go through the environment: we are dealing with a domino 9.0.1 server, running the ExtLibs, as well as ODA. The application in question is only using the ExtLibs, although ODA is installed onto the server. It is not listed as a project dependency.  ExtLibs is used only to get the current database. A fixpack round about 42-ish is being used, I do not have the number memorized.

To reproduce the problem, I created a database with only two xpages, and only to methods.¬† The first method created 120,000 documents.¬† Each document had only two fields that were manually set: Form and Status.¬† To set the status, I used creatingDocNum % 3 to makes sure that a third of all created documents had the same value. We should have 40,000 documents with the status set to “0” and so on.

The next XPage executed a search over these documents looking for all documents with that form name and the status “0”.¬† As stated, there would have to be 40,000 hits in the database. When performing a, Date, Integer), we are returned a lotus.domino.DocumentCollection.¬† The getCount() returns 500, (I used 500 as the maximum document count). When iterating over the documents, I put the universal id (toUpper()) in a hashmap, as well as counted the iterations. After each loop, I requested how much memory was remaining.¬† Once a certain minimum value was reached, I jumped out of the iteration loop.¬† I printed the hashmap size, the iteration count, and the value returned by the getCount() of the collection object.¬† I was well over the desired 500 document count (anywhere between 1500 and 6000 depending on the memory available) and the getCount() always returned 500.¬† A PMR has been opened for this case.

My work-around is two-pronged.  The first bit is easy.  I simply jump out of the iteration when enough documents have been iterated over. The second bit is that I constantly check how much memory is free.  Once I hit a minimum, I also jump ship. The appropriate message is displayed to the user and he can refine the search, or try again later.

But this is sadly not enough for my ‘want-to-know-everything’ attitude (though in reality I can never know enough), during my testing I found that the available memory always was set back down to 64 MB….

Here is the point where JVM knowledge is paramount. The Runtime always wants to make the smallest memory footprint possible. To that end, when garbage collection is performed, the amount of memory available to the runtime is recalculated.¬† If the available memory is small enough, it will allocate more memory up to the maximum configured value. If there is a bit of free memory, then it will lower the available memory. All well and good…. Normally… What if we have a few users who go in and start a massive search at the same time… because that is what they are there for. Call up their data and have a good day. We could enter a situation where that 64 MB RAM is just not going to cut it. Furthermore, because these massive calls are happening simultaneously, we just entered a situation where the runtime is not going to allocate enough memory fast enough. Even though we set the ini to use a maximum memory of 512MB, we are getting an OutOfMemoryError at only 64MB.

Enter the XPages Gods who have not only mastered development but are more than their hips deep into domino administration…..¬† (in other words google and some awesome blogs…)


Setting HTTPJVMMaxHeapSize=512M is not enough.
Setting JVMMinHeapSize= 128M may be necessary.

I am always very careful before saying that we need to allocate more memory. This is because of how domino works. I go through a checklist to verify the following:

  1. We are not throwing more memory at a memory leak. (are we using recycle() appropriately and correctly?)
  2. How many XPage applications are using on the server (each App runs a new JVM [normally])
  3. The server host can handle it, i.e. enough RAM is physically installed onto the machine.
  4. The problem is not limited to a situation that can be fixed another way that also makes sense.

As a side note, I have found this this error occurs whether or not the openNTF Domino API is used or not. Naturally I have spent more time reproducing the error for IBM with their API than with ODA.

So there we have it. A nice little bug that has been handed over to the guy with a fly-swatter. Happy Programming!


The OutOfMemoryErrors were a result of processing the documents and putting fields of the documents into java objects that were then stored in a List in the view or session scope. The OutOfMemoryError was not a direct result of performing the search, but rather caused by the bug: the search delivers a DocumentCollection object that has more documents than it should and the getCount() method that returns the desired result, not the amount of documents that are actually in the collection.

Memory: A little fucker that dies before its time AKA Crap-Filled bowling balls

As anyone who knows me can tell, I take great pride in every application that I work with.¬† Since spearheading my company’s XPage development starting in 2010(ish), I have developed, analyzed, and fixed numerous apps.¬† They are like little children that send off into the real world.

So when I get reports that one of them is misbehaving, I get real defensive, real fast. It is, unfortunately, my downfall. However, every app that I need to re-evaluate is a learning potential and I do treat it as such.  *Spanks the bad app with a vegance*  (Ok, not really)

Bad jokes and terrible ideas later, I will get into the issue at hand.

Lets call this app ‘Waterfall Workflow’ or WWF. WWF is an application where I can expect a peak of about 800 users concurrently at its absolute extreme maximum. Normal operations should be about half of that number. Users sign in to a main application which holds no more than configuration information and which is responsible for the XPages and coding. Coding is done primarily in Java. All code uses ODA, or as it is officially named, the openNTF Domino API, or just THE API!!! (It all depends on who is speaking ūüėõ ) Hi Paul, David, and Nathan!!! It also makes heavy use of the Extension Libraries, but lets forget that for a moment.

The data is contained on about 4 separate .nsf databases. Each database has a specific function, i.e. Labels and Languages, Primary Data, Global configurations and database instances, etc.¬† Because I do not want to build a database connection for every little piece of the puzzle, I lazily add every piece of configuration heaven into a cache in the application scope.¬† This is done through a series of ‘Controller’ type java classes.¬† No worries, I do not load every possible piece of scrap into its own AS variable.¬† Everything is neatly organized!!!¬† (Your pride is showing….¬† oops *zip*) The primary data is obviously not cached…. why should it be….

So all is fine and dandy until I decide to build an advanced search. Should be easy, right???  Yeah, why not. So lets look at my solution and take a look at some more specifics of WWF.

  1. We are dealing with an application with heavy Author/Reader field usage.¬† (well there goes performance, but there is not too much I can do there…. I think…)
  2. We are dealing with approximately 60,000 documents worth of primary data. (Remember other information is stored in cache as fetched from other nsfs)
  3. Each primary data document may hold a single attachment, and every primary data document may have a separate document (linked via a key) containing up to 10 attachments. This gives us a max total of about 120,000 possible documents where the actual value is likely closer to roughly 80,000.
  4. The search is done in such a way that the query could have 20,000 hits or more. (theoretical)

Productive Server Info

  • 2 XPage applications are run on this server.
  • we are dealing with 64 bit Windows and 64 bit Domino 9.0.1 FP3 and some odd-numbered hot-fix pack
  • October 2015 ExtLibs, and ODA

The implementation of the advanced search is a pretty simple. A user gets the possibility to select values for up to 10 or so fields contained in the primary data document.¬† (There are a total of about 120 odd fields per document) Dependent upon the users’ selection, a DbSearch is performed after building a query string.¬† Although I cannot remember why, I know that a full text index of the database was not built, and one is not desired.¬† The DbSearch is set to return a maximum of 500 documents. Depending on the selection of the user, a further search is performed on an archive which contains old data.

As previously stated, all actions performed using domino data is performed using THE API (ODA). This of course includes the search. Once the search delivers the document collection, an iterator is created over which the documents are read out one by one into java objects which is then stored in a list.¬† These java objects contain roughly 15 string attributes, and we are talking about a maximum of 1000 returned documents. (2 searches, each returning 500 documents)¬† This is nothing ground breaking. This list is stored in a session scoped controller (so that the view can be closed and re-opened without performing a search a second time). We found no issues testing with up to 10 people in the testing environment.¬† We let this functionality go live, and BAM!!!!!!!!¬† OutOfMemoryErrors hit us (ok, hit me) like a ton of crap-filled bowling balls and I still cannot get the stench off of me. Design restore. Wash. Rinse. Rethink…..

Since the design update included numerous little changes, I first had to localize the problem.  JMeter to the rescue in our confined QA environment which (as far as I can tell) is a 1 to 1 mock up of the final server. Same OS, same hardware specs, same (at least where it counts) config.  Same OSGi Plug-ins.

After setting up a test plan where x dummy users login, go to the search page, submit a search request via AJAX, I thought it would be a good idea to set x to 100 users. (All of which are using the same credentials, but by checking the cookies they are all on their own individual sessions) No more than 10 search requests were submitted before BAM!!!!!  Another ton of crap-filled bowling balls.  Server restart, Wash, Rinse, Repeat.

So, where am I going wrong then?

I quickly build another app in the QA system containing one xpage, no configuration cache, and only a DbSearch and a dummy java object being saved in the session scope. So far, only ODA was tested, and the same function construction was emulated. (obviously without the extra final version finesse) Same problem.  Next step, find out which step in the code is causing the error, and by the way, lets cut it to a simple 5 or 10 dummy users.

Before I go further, I want to explain the princess that is the JVM. She has maximum memory (this is how big her brain is), she has an available memory (how much she is willing to give you at the moment, but she’ll give you more if you need it), and a used memory (how much she is actually thinking about your lovely self). Lets expand this into the domino world, and we have two notes.ini variables with which we can play. HTTPJVMMaxHeapSize and its buddy HTTPJVMHeapSizeSet (or whatever). On a 64 bit system, you can play with this a bit. Its default is 256M, referring to a total maximum runtime memory of 256MB, and its buddy, when set to 1 (as far as I know) tells domino not to reset the max heap size.¬† Don’t quote me on that though, it has been a while since reading Paul Wither’s awesome XPage book.

After every critical call, and after every 100th document being iterated over, I printed:

  1. free memory calculated to MB
  2. total available memory calculated to MB
  3. maximum memory

From beginning on, I only had about 35 MB of memory, 64MB available, and a total of 256MB. I played with the setting, going up to 512MB, and then a total of 1024MB. I found a few interesting things:

  1. Viewing the task manager resource/performance panel, the memory usage on the server never exceeded roughly 4 GB of the available 16 GB RAM.
  2. The available memory never exceeded 64MB
  3. the free memory (ok, i obviously was not seeing every milli-second’s value), never went below 5MB.
  4. On the server console, the iteration looping continued although I was also reading the bloody OutOfMemoryError crap-filled bowling ball message.

I am left with an interesting challenge.¬† What is the cause of this stupid bowling-ball shower? The following thoughts are going through my head…

  1. Is a domino configuration setting messing with me, and is that why the available memory is not increasing to match my current needs?
  2. Am I doing something wrong with the loop?
  3. Is it possible that the problem is not with me, but with my tools?
  4. Is it possible that ODA cannot recycle the objects fast enough to handle 10 concurrent requests to perform a function which does a dbsearch over approximately 80,000 documents and returns a maximum of 500?
  5. Is it possible that the OSGi Runtimes are not getting the memory they need to run?  If not, why would that not take the same value as is written in the notes.ini?
  6. What the fuck am I missing?
  7. How do I get the smell of crap-filled bowling ball of me?  Does tomato juice work?

As you can tell, I am still trying to figure this out. I don’t expect you to have learned anything from this, but at least I got my thoughts out.

I am going to try taking yet another shower.



If you are¬†following me on twitter, you will know that I have had my first tastes of the Lotussphere / Connect experience. ¬†It has been quite a day, and I could not be more ecstatic with some of the information I am receiving. The ideas that I am seeing are astounding and the people are wonderful. In all honesty, I am incredibly grateful for the opportunity to come here. I have shaken the hands of people that I have held in incredibly high regard, as well as even had the opportunity to meet someone that I was able to help with my blogs and videos (as bad as they might have been….)¬†I am not certain at the moment how much information I am allowed to just blurt out on this blog, so instead I am going to write a quick evaluation of the session I attended.

The general morning sessions with IBM were very entertaining. ¬†Acting and role playing, promises and announcements… It was a fun and the time went quick. But… ¬†But…. It reminded me of a stay at Disney World. ¬†Lots of fun, lots of pretty facades, but no background. ¬†Of course, how can you go into background information during a sales pitch, and therein lies my problem with those sessions. ¬†It was a sales pitch. ¬†If we needed a sales pitch, we would not be at Connect. ¬†(I think). Dont get me wrong though!!! I loved what they were trying to sell! ¬†IBM Verse with Watson and all of the Cognitive Business ideas are something that I am really going to have to research, and I am definitely interested. But I was really missing was the part where they mention the cons. Hours of pros and no cons leaves me with a twitching eyelid and a stiff neck. It leaves me wondering where the caveats are. So let’s just disregard the obvious sales approach and lets get into the real reason why we all came. ¬†Let’s get into the sessions with the interesting people.

My first ‘real’ session of the day was entitled ‘OpenNTF – From Donation to Contribution’ done by Christian Guedemann. It was a small room, but comfy. (how sad is it that my browser does not recognize comfy as misspelled!) #disturbing!!!! Anyway, The general topic was getting involved. I have been a member of openNTF for quite some time now, and I really want to get involved, but other things seem to always get in the way. Mostly I am just lazy and lack original ideas. ¬†[Did I just really write that?] Well, he went into the main shift in the way openNTF works over the years. How people mostly just threw their old stuff onto the site, trying to save it from simple deletion, and to its new main focus of community involvement and getting to contribute in any small or large way. Yeah, monetary donations¬†are nice, but really getting involved is a much better way to contribute. The best part of this presentation was being shown how the community does not need to just contribute code, but rather can contribute in pure theory.

Let’s take me for example. ¬†The lazy one…. ūüėõ who does not want to come up with a new idea for a project and write a lot of code can instead ‘only’ help contribute in words. ¬†As talked about in a few sessions today, the XPage Knowlege Base is a wiki based online encyclopedia with everything we as a community need to know. ¬†This wiki is going to be a collection of a ton of blogs and resources already completed, as well as people coming up with new stuff that needs to be documented. ¬†You want to know more about ODA (openNTF Domino API)? [I think I coined that phrase and love how I see it everywhere here, though I actually call it O-duh, as in Oh, duh! I knew there was something else we needed] Go to and get the info you needed. ¬†You have a question not answered? Contribute the question!!!!!!! Let the community answer it. OF course questions about a specific problem still remain in StackOverflow, but topics not covered should be mentioned! This truly allows the community to get involved in every small way. ¬†I love it.

As for the presentation itself, I enjoyed it. ¬†The slides were well made, the information was well presented (both verbally and otherwise), and I only wish Mr. G√ľdemann gute Besserung and a good nights rest!

My Second session was with Nathen Freeman covering the topic of Graph databases. There I had another oh-duh moment, though not the good ODA kind, but rather the ‘oh that was embarrassing’ kind. Once You Go Graph… truly was the name of the session, and no, the app did not shorten it for size. **hangs head in humiliation**

Fun aside, using graph concepts for webpage development is nothing overly new, but when presented with it, and knowing we can use the technology with what is already installed on my dev Domino servers….. ¬†Nathen Freeman, you challenged the way I look at developing for domino AND I LOVE IT. All I can say is, the more you know, the more you know you dont know. ¬†(Yes I did post that to twitter) Well presented, explained in an understandable manner, good slides [kudos to your slide assistant], and now the question why no one else including me did not think of it sooner! I cannot really say much more to this session because I have a lot of work to do to fully comprehend this technology. I can only add #ODAForTheWin.

My second last session for the day was Optimus XPages which focused on best practices. This was done by John Jardin. Very nice guy! As I have done XPage dev for a while now and have been hung by the learning curve on more than one occasion, it was great to see how another programmer has learned the software and found his own way. His suggestions for frameworks and just the ideas that he suggested are  something that I am going to be looking at in very great detail in the coming months. Again this was someone who challenged the way I think about how I work and what my projects are like. I may not have agreed 100% on everything (alright, only the single application design was something that I question) , but the information is invaluable.

My last session for the day was GIT ‘er Done presented by Henry Newberry. Judging by the attendee count, this was probably the most undervalued session of the day; which I find really sad. The presentation itself may have been a little sloppy, but the information contained therein was excellent. We talked about how we can use platforms like BitBucket and Git to add team SCM to our domino development processes. This again made me question the procedures that my company has in place. Why do we have to use .ntfs and keep backups somewhere to keep versioning in place, and why cant we simply use a SCM system like the modern git? Of course we can. ¬†And this was probably the most useful bit of information I got today. So all you people who went to see the other big names, I feel good about my decision. ¬†ūüėõ Alright, I wish I could be in multiple places at once too, but I cannot.

I think the main title for my experiences today was, ‘Question why you do what you do’. I do not think I can put a better point to it. I will be thinking long and hard the next few weeks and perhaps longer about my style, my so-called ‘best practices’, as well as my work style. I am grateful to all of the presenters for giving me so much to reflect on. ¬†To those I could not see yet, I am sorry, I will do the best I can! And again, many thanks to my company for sending me here. Looking forward to tomorrow!

XPage Opinions


I had an interesting experience today that I would like to share. I met a group of Notes power users today for a small and informal gathering. The food was good, the alcohol was flowing (so was the soda), and we all started talking.¬† Some of us were developers, some of us were administrators, some of us were in management, all of us use Notes. We got on the topic of IBM stuff and I must say that it was a generally tricky topic.¬† The general topic of Notes was fine, but when it came to XPages…. Lets just say it was a rough time. As it turns out, there are people that love to hate on XPages.¬† I must say, I used to be one, but I converted…

There are a few arguments that I want to touch upon.¬† The first one is that it is impossible to take on projects done by others.¬† This is a very good point even if I am not in complete agreement.¬† Unfortunately, we were not agreed as to the cause of this trouble. One person said that the trouble is based solely on the different ways to “hide” the code. Yes, I will say that this is an issue, but I am also not sure we were talking about the same stuff.¬† General style when building XPage applications is problem, but it is not more or less problematic than in classic notes development.¬† The question of whether to use a script library or put the calculations directly into the Form design element itself is the same argument that I have with using JavaScript libraries and putting it into the controls themselves.¬† The correct answer is also clear, use the damned library… That is what it is there for. For me, this is also not a reason that taking over someone’s project should be difficult. Refractoring is needed, but if the project was done correctly, then chances are the original programmer is still working on it. Another possibility was the location of Java code.¬† There are a few places where you can place such code.¬† The Java Design element is usable (from what I have read), and some of us prefer to use the good old Web Content/WEB-INF/src folder located in the java perspective. THIS IS A STRENGTH IN XPAGES, SO STOP HATING ON THE FRAMEWORK!!!!!

Another reason I heard today to hate XPages was that the applications are slow or are unstable.¬† This excuse makes me angry… very angry. The applications are as stable and as fast as the programmer allowed it to be.¬† And for this point, I am going to point and laugh at every single corporate manager who says that it is cheaper and easier to outsource your development to overseas countries where you only have to pay a hundred dollars a day for programming services instead of using your next door neighbor who gets a thousand.¬† You will get what you pay for! Of course, we cannot all know from birth how XPage applications should be run, and it takes a while to learn the proper methods of using error handling (shout out to the dreaded NotesException), and learning how to properly recycle objects in order to prevent killing other functions, and building a proper cache and balancing CPU vs Memory…. These things are not easy.¬† Not every one can do this.¬† THIS IS NOT XPAGE’S FAULT, SO STOP HATING ON THE FRAMEWORK!!!!!

Another problem is our idea of what XPage development is.¬† XPages is a way to program modern web based applications which may or may not use a domino data source and which run on a domino server.¬† IT IS NOT RAD (rapid application development).¬† At the very least, it is not the RAD that many remember in classic notes.¬† Much more planing needs to go into XPage development.¬† A lot more skill is needed.¬† I wider range of skills is needed.¬† JavaScript, Java, DOJO, JQuery, GUI/XML, architectural skills…. not every Joe who knows Excel and spreadsheets can do this! It is still more rapid than building a JSF/JSP application from scratch, but a totally different ball park.¬† THIS IS MODERN APPLICATION DEVELOPMENT AND NOT XPAGE’S FAULT, SO STOP HATING ON THE FRAMEWORK!!!!!

Instead, let me tell you the awesomeness that is this framework.¬† This framework offers modern web based applications.¬† It offers a way to combine the tested and true Domino nature with the scalibility and efficiency of SQL.¬† It offers easy binding of third party software into your applications. A separation of data and GUI allows for a much more robust and rich application that does not create a dependency on certain servers or data sources but rather abstraction which allows almost anything. The deletion of a certain server does not require any complex desktop processes to make sure that the tile on the client is switched to the proper database instance.¬† More control is granted to the application design due to easy access to modern JavaScript libraries. Sharing of code between application instances with the use of self-built OSGi libraries running on the server enable build once – copy never functionality not seen before in notes applications…¬† The reasons and advantages of using XPages in your environment are manifold.¬† Don’t get frustrated at the first glance or first failure and say that the whole thing is shit.¬† Open your mind to what is now possible, change your perspective to see that this is not classic Notes, and learn the correct ways to use this framework.

</bitching></rant> …. doing is up to you…

Java Beans and funny stuff

I have such a backlog of posts that I have written and have neglected to post, it is not even funny.  I have a few videos that still need to be edited or redone and it is nuts. So first off, I am sorry for the long breaks in posts, but life tends to get in the way.

Today I was working with an apprentice and getting him involved with XPages.  He seems to enjoy it so far, and it is a help for me because I give some of the more mundane things to him.  He has zero Notes/Domino experience and has focused primarily on .NET development.  If you go to, you can see a bit of his handy work.  Of course he worked with another apprentice of ours to build that site, and I must say together they built one awesome application.  But I digress.  Of course I think our apprentices are amazing, but we want to quickly discuss our adventures of the day with Beans and XPages.

As readers may or may not be aware, I have spent a great deal of time developing a standard java library that I use in all of my XPage applications for use both internally and for customers.  It includes custom controls, standard beans, and now a configuration.  But a simple configuration was not good enough for me.  Let me quickly get into my use case.

Up until now, I have been using a file saved under the Resources/Files tab of the project. ¬†I wanted to get around needing profiles which can be a cached pain in the rear, I originally did not want to have a view to look up a specific document, and I did not want to touch the xsp.config xml file. Of course there are some wonderful snippets available from Paul Withers in case you would prefer that approach. ¬†I wanted to save values that differ from database instance to database instance, as well as from dev version to QA version to productive version. ¬†As far as I am aware, performing a design refresh also rewrites the config.xml file. ¬†Really the best way to get the functionality I wanted was a good old fashioned NotesDocument, a good old fashioned view, and the wonderful ODA view method “getFirstDocumentByKey()”. #ODAOnceMoreForTheWin .

This brought on interesting points that I could discuss with the apprentice: abstract classes, Beans, and expression language.   I wanted to build the following structure:

-contains the view alias for lookups which will be used for all XPage configurations
-abstract init() method
-abstract getLookupKey() method
-a few other methods that are sensible for our use case but may not be needed for all.

AbstractDashboardConfiguration => AbstractConfig (just an example)
-implements init() to fetch the needed data
-protected final Strings for each field in the NotesDocument
-private members for each field value and the appropriate getter/setters

DashboardConfigurationDocument => AbstractDashboardConfiguration (just an example)
-save() implementation
-specific XPage rendering helper functions
-is set up as a viewScope variable

DashboardConfiguration => AbstractDashboardConfiguration (just an example)
-Specific methods to use a re-init interface that I built so that all of my applicationScoped beans can be reinitialized with a click of a button by an admin
-obviously applicationScoped

As you can see, the build up is pretty complex, and this is the easiest of examples. ¬†There are probably a few “WTF?” questions that I should touch upon, so let me get to them first.

First off, I am sure the reason for an AbstractConfig class is clear.  When all configuration documents are already being saved in the same view, then why not.  Certain fields need to be set in order to guarantee that they are displayed in the correct view. Also, why should the name of the view be set in each configuration class?  It just makes sense to have a single abstractconfig java class.  But, the question that probably comes to mind is, why is there a need for another abstract class before the real implementation?

The answer is pretty simple: I hate StackOverflowExceptions. ¬†I started to create two classes to handle configuration information. ¬†One bean would be responsible for saving and editing the information (DashboardConfigurationDocument), and the other would be responsible for caching the information in the applicationScope (DashboardConfiguration). ¬†Without the abstract class I am left with the following¬†conundrum…..

It is clear that DashboardConfigurationDocument should get it’s information from the document… I mean…. ¬†it is sort of implied in the name. ¬†It should also save itself. It then needs to inform the applicationScoped DashboardConfiguration bean that it should refresh its data. This data¬†could be read from DashboardConfigurationDocument to get around needing to write the int() function twice. ¬†Right there we have a problem because¬†we have two classes that call each other. ¬†It just makes the most sense that both of these classes have the same key functions and members in the abstract version, and the rest of the key implementation in the concrete classes. ¬†It makes for a much cleaner implementation at the cost of hereditary chaos. ¬†ūüôā ¬† Truth be told I find it awesome.

The second major question that I should directly address is, why do I just not save the DashBoardConfigurationDocument bean in the application scope? Basically I am a control freak wanting to do crazy things. ¬†No…. ¬†I assure you that I have a reason. ¬†Let’s look at lazy admin A and multi-tasker admin B. ¬†Admin A makes a single change, directly in the appScoped bean before going for coffee, and admin B gets a phone call after doing the same. ¬†Neither are finished with their changes, neither of them had to save the changes explicitly, yet both of the have a change that is already potentially putting the application in an unstable state. ¬†Baaaaaaaddddd ¬†vooodooo…. ¬†baaaaaaaadddddd. ¬†For this reason, I also like to separate my editing logic from my global configuration logic. Additionally, I can have XPage UI specific logic in the viewScoped class without feeling guilty about caching stupid spam members in the appScope bean.

I can use this pattern as often as I want, and I can be sure that I do not forget anything.  All of my field names are saved as final strings and I can use them in other sub-classes if I need to.  I can even decide later that I want to override my save function in another bean to get SQL support or whatever. It is just clean, and I like clean.

After taking some time to explain a lot of this to the apprentice, we dove into Expression Language and getting some good old binding done. ¬†It worked like a charm…. almost.

This goes into another crazy use case.  I only wanted one configuration XPage.  I have an enum where I have specific configuration keys saved.  These values are then presented to the user in a combobox where a specific configuration key can be selected, and the document is opened, and the information is displayed.  We did this with Expression Language.  The ComboBox held string values representing each of the values in the enum, and the bean had the necessary getter and setter to take the string and set the enum value for that document.  This setter also triggered a process whereby the configuration was fetched and the values were refreshed.  It was a thing of beauty until we realized that the values were not being refreshed on the XPage although the values in the bean were being refreshed with the contents of the NotesDocument.  It took us two hours to figure this issue out.  The correct getters/setters were being called, the init() function was being called, the correct document was being retrieved, and the values were correct in the bean.  Why were they not refreshed on the XPage?

First off, I thought it was a simple refresh problem.  The errorMessages control displayed no errors, and I thought that it was just a simple case of needing to either perform a full refresh, a refresh directly on the component, or some other crazy thing.  We messed around without any success.  In the end, this was one instance where a simple EL expression just was not enough.  We saw that the EL expression was calling the correct methods;  the onChange partial refresh on the page was working correctly.  My suspicion is that the partial refresh was being performed faster than the methods called by the EL expression.  We took out the EL data binding and instead implemented a SSJS function calling the setter method for the configuration key.  When we did this, everything worked as planned.  We also now have one page that can be used for multiple similar configuration documents that can easily be extended without changes in the design.

Lesson learned:  Java is awesome, EL is cool, but ssjs still has to be used for certain things.

XPage dev Why Java

I recently received a comment that I would like to address:

Hey Greg. I watched the tutorial and followed it quite easily. My biggest block to Java is why should I use it? I am having difficulty understanding what the great benefits are, other than getting skilled in a new field.
I also am perplexed as to why, for example, would I need a session helper when I have session info with my standard XPage. Another thing, having an object of a Domino document and using the object to read and write fields back to my source data seems rather tedious seeing that I can read and write straight to my source data?!?
I’m missing something for sure because everyone seems to be wanting to go the Java route.
If I had 1000 users open an XPage application and view a document then why create 1000 objects, one for each document and session helpers. Does that not take needless memory?

But I am looking forward to the next tutorial!!

There are a few questions in here that I find good to ask and that can cause some debate in the professional world.  I will start off my answering my part to the question why.

Why use Java instead of JavaScript?

Some people will say, “Use Java! ¬†Why? ¬†Because ..¬†white noise………”

I am sure that all of you have heard the “Because it is faster”. ¬†Faster for whom? ¬†The computer? ¬†The difference is negligible. ¬†In a test done by a colleague, iterating over a view with 75,000 documents, touching every one completed only about two seconds faster when done in Java as opposed to JavaScript (14 seconds rather than 16 seconds). ¬†I say, if you are doing something in the real world that needs to touch that many documents and the user is waiting on you, then you are doing something wrong! ¬†I do not care if that is done in JavaScript or Java. ¬†Now, keep in mind that he was doing this for a test and to see if there was a measurable difference. ¬†There was. ¬† We thank him for doing his tests and for sharing the results with us! But to that end, lets make our first point:

Use the correct tool for the correct job!

First off let me say that I find this debate stupid.  It reminds me of the debates that I had to listen my friends engage in regarding their preferences to C# vs Java and Windows vs Linux or Mac.  Every task has its goals, and every goal has its best practice and optimized structure and technology.  If you are working on a project that will be small, used by few, and only requires a few pieces of JavaScript code, than maybe it is best to use pure JavaScript in your implementation.  Likewise, if you are going to be building an application that has code that focuses on customizing the controls, then that too might be best to be done in a pure JavaScript environment.  JavaScript simply is the tool for those jobs.  If you are going to be working on code that needs to be well documented, used by others, maintained by others, or shared between applications or one day may be shared by applications, then Java is the way to go, no doubt about it.  It just is the tool for that job!  Likewise, if you have to build code that handles jobs and working with many documents, then the code does not belong in either of them, but rather run in [scheduled] Agents.*

I know that the separation of Business Logic and UI Logic is another big push the separation of JavaScript and Java.  To that I say bullocks.  Because of the JSF infrastructure and the ability to change existing HTML generation code into actual controls, Java might indeed be the best place to store your code rather than using JavaScript to generate the code for <ComputedField>s set to HTML.  Granted customizing those controls must still be done using JavaScript, but depending on the use case, you might even have some of that logic kept in a Java Object.

Yeah, but, Why Java

Maintainability, Readability, Usability.  There is no better way to put it.

Think back to another Blog Series I did when I discussed the issues I had with debugging JavaScript.  I mentioned that the stupid error

if(apples = oranges) doSomething();

as opposed to:

if(apples == oranges) doSomething();

and that this was an error that should be caught, but never is.  This is my number one reason for pushing for java.  The stupid errors that can cost a great deal of debugging time are caught by the compiler and are easy to fix.  Another case, you have a larger function.  You are dealing with many different kinds of objects, and you accidentally try to set a document object to a documentcollection object.  In JavaScript, you will not discover this error until you run the program and you get an error that states that the desired function is not available, or you end up debugging because it manifested itself in some other way.  In java, a variable declared as a document can only be used for a document.  The error will never happen.  My first reason for pushing for Java in XPages is Usability.  You are not going to have as much code that contain errors and his hidden or uncaught by a compiler.

Another reason why I say usability is improved with java is the tooltips/inteli-sense or whatever else you want to call this feature.  If the javadoc for the API you are using is connected in the build path, you are able to look at detailed information provided by the developers, assuming that they maintained their javadoc well.  This also goes for the javacode that you write.  Of course you have the ability to write and look up comments in SSJS, but they do not show up like they do in Java.  If I am wrong about that please tell me, but I do not believe I am.  In Java, you have the ability to simply use shortcuts to import packages and classes using the inteli-sense, keyboard shortcuts, and see what members and functions are available in those classes whether they are known to designer or not.**  You write a class, that class is known by the inteli-sense. It is that simple.  It may not seem like a lot, but when you can quickly see what code does what, import, and comment all in one place, then why would you not want to?

Readability is also highly improved.  Lets say you have your classes all defined and you are using them.  In JavaScript, you do not have the ability to click on the method being called and have that method opened up in designer, at least not when those functions are defined in two different files.  With Java, this is not an issue at all.  Click on the call, file opens right to the spot in question, time is saved, finish.  The reader is just put into a position where it is efficient to go through your code and figure out what to do.  Another thing: in that same series I linked before, I mentioned that embedded JavaScript function calls are not listed in the outline view.  In Java, this is not the case.  All members, functions and embedded classes and their members are listed in the outline view thus adding to the readability of your code.

Because you are writing your code in a place that makes it readable and because it is in a very usable format that will not require a lot of learning about your code (ie reading your script files to learn how to use it and instead getting the comments via the javadoc and inteli-sense), you are saving time of future programmers who are using your code.  You are also saving yourself time when you need to change something 16 months later and do not remember what you did any longer.  You are also creating something that can be added to later!  Let me explain this.  By saying that, I am not referring to adding some code at some point down the line.  If you want to do that, than JavaScript is completely reasonable.  I am talking about finding out that there are these few classes that you use over and over and over again.  You have to port them into every database you own.  By having these classes in java already, you are in a position where it is not that expensive to port them over into OSGi Libraries that can be put on the server as globally available beans.  If you have them in JavaScript, you also need to translate them.  Furthermore, if you have an HTML generation function that you use for a computed field that displays html code, then it is not so far off to take that code one day and make a real JSF control out of it.  Likewise if you decide to make that code into a control, you can share that control via an OSGi extension.  Overkill?  Nope.  You are simply writing your application in a way that allows for future sustainability.

Why Java?  Not for the negligible speed increase, but for Maintainability, Readability, Usability.

Why a SessionHelper object?

This question refers to a video that I posted as a part of my Java XPage tutorial. ¬†I created a Java object in order to access the session. ¬†First off, I just would like to mention that this is primarily a class to assist other Java classes and not JavaScript. ¬†I most likely would not put this into the faces-config file and register it as a bean, although I have done so in the past. ¬†As the object stands right now, it is merely a list for static methods. ¬†This is a poor candidate for a bean as an instance of the class is not necessary to use its functionality. ¬†Get it when you need it, otherwise leave it. ¬†The only functionality in this particular SessionHelper class that might¬†be helpful down the line in JavaScript is the getODASession(). ¬†Otherwise, if I remember correctly, ODA creates a bean called “openSession” that allows you to access the ODA session object simply in JavaScript without any sort of self made utility¬†class. ¬†Even then, you could always access the ODA Factory utility.

There will be some who will say that my approach to getting a session in an external class is a bad idea.  I can only say to that that I have not had any issues getting the session or the database from other helper objects and methods.  An absolute no-go would be getting the objects under the database object.  Your cleanup would either be messy, or give you NotesExceptions depending on how you went about it.

 Java and Object Retention

Beans and the scoped maps are there for a reason. ¬†Lets assume we have an external database that holds language information: labels, keyword lists and so on. ¬†A typical approach from a few applications that I have taken over require that each form retrieve its own values using @DbLookup to fetch them from the source DB. ¬†In XPages, this is dumb. ¬†Likewise, this would be an asinine thing to do for a computed field or hiddenText field, it would be a horrible idea to put it into the viewScope, a dumb thing for sessionScope, and perfect for an applicationScope Bean which maintains a ¬†HashMap of document labels and keywords based on some key and correctly retrieved by reading out the sessionScope bean that contains the preferred language information for the current user as read from his user document. ¬†By putting it into the applicationScope in a bean you are creating a way to cache your expensive values and provide a way to reset those values at will. ¬†Of course you can do similar things with JavaScript, but you cannot put a JavaScript “object” or function into the scoped maps. ¬†We will be getting into such patterns later on in the tutorial.


As Scotty said in Star Trek V, “How many times do I have to tell you, the right tool for the right job!” ¬†There are times when Java is the right tool, there are times when JavaScript is the right tool. ¬†Do not let yourself be put into the position of thinking that only one option is correct, but keep an¬†open mind and remember that future sustainability is¬†directly influenced on your programming technique and tool decision. ¬†Don’t get caught up in the stupid debate of which is better. ¬†Do not listen to the “java is faster” crap. ¬†The real reasons go much deeper than any of that, and if you are having performance problems, then there are much more likely causes than the language choice.

Java is also the only place where you can define classes for beans to be used with scoped maps.  Otherwise, you are just saving raw variables into your map and cluttering it up.  Use Java to correctly store and access your information so that it can be readily accessed and executed.  I am a strong supporter of Java use in XPage applications.  I hope that this article has helped explain why.


* This is really a case by case decision and must be decided upon specifically when designing the application.
** By “known to designer”, I am referring to basically hard coding the inteli-sense. ¬†I actually do not know how this works and am merely guessing. ¬†Does not matter though.

OSGi development issues


This is a post written out of frustration and the hope to get some assistance figuring out what I’m screwing up. ¬†I did not proof-read it (will soon though), and I am certain there is some detail that is missing. ¬†This is more of an article for me to remember what I’ve learned so far. ¬†If you’re interested, go for it!


A few weeks ago, I started setting up a development environment with eclipse where I could mainly view the extension library code and perhaps edit and add to it.  This eventually was extended in the hopes of creating my own OSGi Plug-ins.  Let me quickly describe the deployment strategies that I have seen and partially used myself.

1. Central template

The first deployment strategy is going to be the clearest for Notes Developers, I believe.  In fact, it is very common that there is a central application that serves as the main design template and that all other corporate applications use that database.  Most of the time, this primary template contains very little more than images, css files, and maybe a few administrative views which assist with conflicts.  Often the next level of templates will increase the functionality to include libraries and so on.  Of course, this can be done with XPage elements and with Java classes and so on.

This is the method that I started off with, and still use in a few cases, but I found a few issues, or at least I had a few issues.  More than likely, I just found a few cool new ways of messing up and did not realize how.  My main issue was when I distributed Java source code in this manner, I ended up with a great deal of SecurityExceptions and the occasional Serializable- or ClassCastException.  The program would run for a while without any issues whatsoever, and then suddenly I would be getting these stupid errors and they would not go away.  I could only solve it by going into designer, refractoring to change the name of the offending class, and then change the name back again.  I had tried to clean the project, rebuild the project, and there were even a few times I deleted the entire class and recopied the text.  (That last one also worked)  This was annoying.  To fix this issue, the cleanest option I found was to package the source code in a jar (easy to do in eclipse) and then distribute the jar.  This can also be completed with the same sort of template distribution, but the source code is not present, or taken off the build path.  I have had problems just removing the source or old jars from the build path though.  It seems there is a cache that is present that gets in the way, so it is best just to delete it.

2. I vaguely remember some other strategy that I am not going to touch upon….

3. OSGi Development

This is the way I want to go.  The main push to develop my utility files in this fashion is my desire to publish them on openNTF.  Of course this is not any sort of requirement that I have read about, I just find it cleaner, more professional, and easier to maintain and update, not just for me, but also for the customer.  Basically, my components and java files will work in a way similarly exactly like the Extension Library content.  I can have them installed on designer and on the server and just go to town.  At least that is the theory.  There are a few obsticals that I want to touch upon here because I am still not able to do this the way I should and I am pretty stuck.  I do not know if my environment is set up incorrectly, if I am just being stupid, or what the heck is going on.  I am to the point where I do not even know what to ask anymore to try to figure out the issue.  Instead, I am just going to write about my experiance here as best I can in the hopes that someone can help me figure this out.

Eclipse Setup

Setting up eclipse in order to get this to work was my first chore and did not go well. ¬†Again, my goal at this point was to set up eclipse in such a way that I could play with the code for the Extension Libraries. ¬†I starting¬†using this video¬†to set up my environment. ¬†I did have a few issues with this. ¬†The main issue was that the Development package described in the video is not available. ¬†I tried for hours to somehow find it, but it was simply sent to nothingness. ¬†Wonderful. ¬†Using¬†this StackOverflow question,¬†some help from Paul Withers, and a great deal of playing with build paths and workspace settings, I eventually got the code loaded with only a few errors. ¬†The errors that I had were mostly in test packages from the ExtLibs. ¬†I closed those packages and hid my head in the sand refusing to see any of the numerous warnings that I also have, and still have. ¬†The one that bothers me the most is the “Access Restriction” warning saying that a particular class or whatever is not accessible. ¬†I somehow managed to get them to go away (mostly) but I do not remember what I did. If I do, I will post it here.

After a few weeks of a break, I picked it back up again because I wanted to develop my own stuff.  I want to rely on the openNTF Domino API as well as the Extension Library.  Because of this, it makes the most sense to work in that same workspace and just add my projects to it.

 Noob Problems

I will confess right here and now that I am not well versed on OSGi, Plug-in development, or JSF.  I learn by doing, and if I can find a book on the subject, I will buy that mother and soak it up from cover to cover and complete every single understanding exercise it contains, or make up my own in case the author opted out of such a cool idea.  **Hint Hint to all of you authors out there that this person might buy your book if you can come up with something that deals with Domino OSGi dev**  

First off, it is not enough to just copy your source code from designer to eclipse and call it a day.  There are a few different types of projects that you have to create.

1. Project file

In my case, this Project was named de.holistic.utils.  It is the heart and soul of what I am trying to do.  It contains all of the code from designer and is what I want to publish.  I made this a plug-in project, and I am not entirely certain this was correct, but that is the current stand.

2. XSP Plug-in

This is a plug-in that I was not aware was mandatory. ¬†In all honesty in only makes sense though. ¬†This plug-in will point to the “” extension point. ¬†This should act as a flag (as far as i can tell) that tells designer (and I bet Domino) that it is an addition to the Xpage runtime. ¬†I am not really doing anything here other than setting up the XSPLibrary and Activator classes. ¬†Additionally, I have a domino-faces-config.xml file which I have found out can store bean information like the faces config file in the .nsf’s. ¬†My current stand is that I just copied the file directly from the development database and I have not cleaned it up. ¬†The only thing I did was to make sure that the class names¬†are all correct.

3. Feature project

The feature project seems to be fairly simple.  As far as I can tell, it is just a glorified library of plug-ins that are going to be installed into the runtime later.  I do not think there is any real magic happening, it is just an xml file with a pretty front end.

4. Update Site Project

The update site is also just a glorified XML file that points to one or more features.  This produces what we can later zip up and send to customers to install exactly like the ExtLibs.  Again, no magic.

Just getting this far seemed to be a bit of a hassle. ¬†I had no idea that so much was involved in getting one jar file out onto the server. ¬†It does make sense, but I was not expecting it. ¬†Your welcome for the heads up. ¬†ūüėČ

 Current Stand and Issues (my Noob-i-ness is painful Рespecially to me)

Here is the point where I say that I do not know where I am going wrong. ¬†I have posted a few more questions¬†onto StackOverflow¬†mostly because of the symptoms I am seeing, and not really understanding what my issue is to begin with. ¬†The problem that I am having is that I cannot access my classes in a project. ¬†There is no further problem that that. ¬†The rest is all guesswork as to what it can be caused by. Using this article and the answer to my question from SO, I discovered I needed to create an xsp plug-in and correctly set the extension point. ¬†I have since done this. ¬†That tutorial is mainly component based, and while I am sure this is going to come in handy in the future as some of my utilities are components currently used as custom controls. ¬†I have not really had much luck figuring out what to do with java libraries and adding that to the developer’s toolbox. ¬†The issue that the library cannot be chosen in the is still a concern, although i have set the XSPLibrary to global, so that should not be too much of an issue right now. ¬†It is mostly something that I need to clean up in the future. ¬†**I THINK**

When I run an Xpage right now, the beans that I defined in the configuration cannot be created. ¬†It cannot find the class. ¬†I have checked the spelling (but since I am in a really bad mood right now — yes bloody shirt type bad mood for those who read my last latest blog series) I am not so certain that I did not mess that up. ¬†I have made the utility plug in project required for the Xsp project and I added it to the build path. ¬†I have tried many different settings and many different combinations. ¬†I would not be so surprised if I have shot myself in the foot by now and changed stuff that is the cause for my own issues.

The code has been published at GitHub under:
I am pretty new to GitHub, so you will not see too much from me there.  I also like to keep my code local and am not sure how often I will publicly commit code, but in this case, it is the best option.

As soon as I figure out what I am screwing up, I will be sure to post about it.

Thanks for the support!

A few Years of XPage Developement – Part 6


My XPage journey being laid out before you, I now come to a point where I want to say what we need in order to be more productive in XPage development.

  1. We need a centralized help application.  Forums and demos are good, but they are not good for everything.  We need a central place to get information on every JavaScript, java, and control function.  We need a listing of all methods opened by each control, and should not have to search long, for example, to figure out how to get the NoteID of a selected document in a view control.
  2. The IDE must be optimized.  This must be done in a few ways.
    1. JavaScript errors must be found at design time.  This is pointing to my if-statement error again.
    2. Nested functions must also be listed in the left side panel of the SSJS editor.
    3. All functions must be listed alphabetically in the left side panel of the SSJS editor
    4. Better and complete java-doc documentation of all JavaScript and java functions which can be seen in the IDE, including better parameter variable names when selecting function.  (control+space).  arg0, arg1, arg2 is just awful.
    5. While binding fields to a control, the field names must be sorted alphabetically and not randomly.  It would be helpful if this alphabetizing was done ignoring caps.
    6. It would be helpful if field names while binding data were also available when using a separate database as a source.
    7. Adding to point f, it would be nice if fields from a selected list of subforms could also be added to the binding options, and that it would work more like type-ahead.
    8. It should be possible to completely ignore the drag and drop and often buggy nature of the Design panel.  I would request that the source editor be optimized for direct xml input.  See visual studio to see what I am talking about.
  3. For those projects where the customer does not want to install the openNTF Domino API, programmers must fall back on the IBM Domino API.  For this, a must have would be a detailed documentation on the use of the API, when to recycle, when not to recycle, and the design patterns that they see as correct and incorrect.  Most designers are left completely in the dark and set up to fail when it comes to recycling and memory management.
  4. Setting properties for multiple controls in background documents was very easy.  Highlight a few controls, add some code, make a few clicks and done.  The designer/programmer never had to search through the property window long before finding what was needed.  The following are things to consider:
    1. Too many clicks are needed to configure controls on the XPage.  There must be a way to optimize this.
    2. Support for changing the values of multiple values at the same time.
  5. Themes.  You can create your own theme in theory, but a lot of stuff is based on dojo and, most of the time, to get what you want you need to get into the innards of Dojo theming.  In the case of OneUI, you have to first understand how it all works.  There should be better theme development support in designer.  This should include altering the Dojo level themes as well as stuff on OneUI.  Optimize this, and you will increase designer productivity by a lot and make point 4b a lot simpler.
  6. With the openNTF Domino API, this point is moot, but get rid of the NotesException.¬† Completely. It. Must. Go.¬† I need to handle a SecurityException (User does not have sufficient ACL access) differently than a NullDocumentException (document with given key not found in view) and that differently from IllegalStateException (document was removed or recycled). By having one exception for everything and just changing the ‚ÄúText‚ÄĚ variable (an already bad design), the developer cannot really alter the exception handling without parsing the Text first.
  7. Some issues, whether bugs or not, need to be addressed.  They may not be seen as bugs to the creators, but to the end user who only sees something different than what he sees in the client, it is wrong.
    1. Dynamic categorization in views must also be indented.  Building a view navigator is all well and good, but it is not what he sees in the client, and for many customers that is unsatisfactory.  This is true with the dynamicViewPanel, and the ViewPanel controls, and possibly others that I have not tried.
    2. The Calendar control is a nightmare.  It is complex to set up, buggy in IE, and questionable in other browsers.  It needs a major overhaul and fast.
    3.  I am sure I could think of plenty more if I gave myself the time.


XPages are a good idea in theory.  At its core, it offers a relatively easy way to get a Notes Database open to the web quickly while, under many conditions, not sacrificing usability.  It offers solutions to the current Big Data problem where a single Database cannot contain the data it needs to by offering a behind the scenes and invisible way to access numerous databases simultaneously, whether they are Domino, SQL, or a mixture.  The development of applications is a headache at best, and a catastrophe at worst.  XPages show great potential, but lack what I believe to be real support and backing from IBM.  Instead the XPage development community is left to fend for itself.  If we want XPages to succeed in the current market, than it must be able to compete alongside Microsoft Sharepoint, JSF/JSP applications, and other high end platforms.  This includes programmer efficiency, usability, extensibility, lack-of-buggy-ness, and support.  Call me a masochist, but I want XPages to succeed.