Java and XPages

I am following the guide in the Designer Wiki for adding custom java to XPages. Basically, swap to Java perspective, add to Webcontent/WEB_INF.

One serious problem. Once you have loaded the page, the java remains cached in memory for ever. You can delete the JAR and the xpage will continue to run the now non-existant code. If you update the JAR the old code will continue to run.

I have tried using Clean, Rebuild etc. But apart from restarting the server, there is no way to update the code.

Obviously restarting the server after every edit makes this pretty much useless.

I need to use Java as the code is too complicated to consider using Javascript, and the XPage javascript editor is really not much more than Notepad.

Has anyone found a way to make the server refresh the XPage java?

Cheers

Simon

Subject: Where is you jar file?

There is a class loader associated with each NSF. It is used to load the XPages and the .class/.jar located within the NSF. This class loader is discarded each time there is a change in the NSF. It works very well with class files.But I suspect that the JVM might be aching the jar files somewhere, we have to investigate.

Subject: Where is the JAR

Hi, thanks for the replies.

Following instructions from the Designer Wiki, I did the following:

  1. Open NSF in designer

  2. Swap to Java perspective

  3. Open the folder WebContent\WEB_INF

  4. Create a folder called lib

  5. Import the JAR into the lib directory

I can reproduce the problem with nothing more than a HelloWorld() style function with no external libraries etc.

It is permanently cached.

The functionality I want cannot be tested within another IDE, so this is a problem for me.

S

Subject: restart http

It works the same as any running Java process, once the jar is loaded, it stays there until the process terminates. However, instead of bouncing the whole server, you can just restart the http process. That’s a lot faster and less intrusive.In general, when developing jar files, it’s best to do that on it’s own, and unit test it through your IDE. When it passes that, then try to integrate it to your XPage. That minimizes the number of iteration you need to perfect it in your full environment.