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.
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.
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 “com.ibm.xsp.Library” 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 xsp.properties 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: https://github.com/GregReeder/de.holistic.utils
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!