Hi there, I am having a java agent trying to call a method within a jar file I have placed under the lib/ext folder in the Lotus Notes client v6.5 java installation directory. My method starts up a Java Thread to run something … unfortunately it never starts the thread like it’s supposed to do. I take a look in the Java console and the following is the output:“Error cleaning up agent threads”
What is that supposed to mean? Does Notes not support Java threads - that’s strange. I couldn’t find any IBM specific Thread classes I could use under the Notes.jar What can I do ?
Please post some code samples otherwise we cannot see what you are tyrying to do. Also point out any place you get to in the code etc so we have some idea of where and how your problem is occurring.
If you’re writing a multi-threaded program, you’ll want to have a look at the NotesThread class in the Designer. The available options are given along with some examples (threading can be a little different in Notes/Domino). If you’re writing a program that uses third-party stuff in which a thread is spawned, you’ll need to try to find a way to terminate the thread(s) through the third-party’s API. And, as Shane suggested, posting the relevant code might be useful.dgg
It doesn’t sound like this is your issue, but… just in case. You will get the same message if you have more than one class that extends AgentBase. I have not seen this stop execution but it will give the message when the primary agent completes and on occaison will pick up on the loose thread at the next execution of the agent. So, primary agent extends AgentBase and any other classes that are called upon must not.
There are some things you may or may not be aware of using Java in Domino / Lotus.
1 - The Java APi is just a thin shell of java that executes the native C / C++ based Lotus API. It is quite possible to kill off a java thread but still have the underlaying C code not be destroyed at the same time. DO NOT … let me repeat that … DO NOT trust Lotus Java / Lotus Java API to do recycling or termination or clean up of any kind at all … Ever!!! It will bite you. Explictly run a recylce / gc at all times. Also explicitly call the destructor for all code explictly. You will often find it is not called automatically in Lotus. THe fact that the Java thread terminates leaving behind the C code in memory creates massive memory holes. I watched some R4 and R5 java api code flatten a massive AS400 and those things are meant to be bomb proof.
2 - Agent Base / Session Classes - Those are or should be considered static, signle instance type classes. Instantiate them that way and have all your code hang off one single instance of them. In Lotus script it doesn’t matter how many times you instatiate a new session , it is always pointing at the one session instance in the back ground. The Java api theoretically only ever points to one instance of the Agent Base / Session thread but to be honest … I wouldn’t trust it to do it manually … do it yourself explicitly.
3 - You may be able to look at coding this using Lotus Script to call your Ajax jar via LS2Java. It is simple to implement and may solve you some hassles if the LS can kick off your code. However be aware, anything to do with formula evaluations, LS evaluations and LS2Java (evaluate type thing for Java) most probably has memory hole potential. IBM gurus themselves say it is probably flakey if you use it too heavily. They suspect memory holes in eval type statements nad potentially in LS2J.
I’ve tried writing a couple of multi-threaded agents in the past without a lot of success. What no documentation, including Lotus’ will tell you is that once your main agent thread is done executing, it kills any threads that agent may have spawned.
Also, that mesage is typical for an agent that completes abnormally and still has a resource open. Are you calling the recycle method on your Domino objects prior to the agent shutting down? If not, it can cause threads to not stop properly, eventually eating your memory and causing the server to require rebooting. In fact, the fact that you are getting that message leads me to believe you may want to do that soon anyway, or face a crashed server. It’s happened to me more times than I care to think about.
Overall, at least in 6.5 and below, Java seems to cause some serious problems that still need to be dealt with, so I always recommend coding in LotusScript unless you need a Java specific capability.
Hi again, Interesting. In my case coding all that in LotusScript was very timeconsuming and since Java has the whole Axis framework that can create objects from a WSDL file and all we saw it as a time saving factor and went on using the java part. We are doing web services from java- LS calls some service methods within the jar files.
As for calling a recycle method… not that I am aware of, of course unless it is something happening behind the scenes.
Basically my jar file has some method that just spawns a thread and that’s it. I am trying to make a Java Agent that calls this method. From within my Java development IDE (Eclipse) - it’s working flawlessly, but when I use the Lotus Notes Java Agent from within NotesMain - that’s when the thread is never started.
Besides our web services must be able to run over SSL, now I don’t know if that is possible from Notes client 6.5 (?) using Lotus Script
What version of Eclipse are you running? the 3.x series, particularly 3.1 and later, require a 1.4 jdk, while the server, including Domino agents, run in a 1.3 environment. Check the version of Axis you are running, it may require 1.4 features which wouldn’t function in an agent.
Based on my experiences with Domino and Java, I would recommend installing the WebSphere plugin and deploying the agent as a servlet instead, and letting the servlet retrieve your data. If you’re limited to an agent because of form submission restrictions, I’d use the agent to call a servlet, let the servlet do the heavy lifting, and use the servlet’s returned data. It will take longer to do that way, but I think you’ll find it more robust in the long run.
I am running Eclipse 3.1.1 but I don’t see the a problem since I am compiling my code using the Lotus Notes JVM (I just changed the default JRE to the one under Notes). So whenever I am testing out java code I will know it will run from my jar file when I put it in lib/ext since I am using the same environment to test the code (eclipse points to this jre). As for running an agent as a servlet, I am not not too sure whether this will solve problems. However I have not tried that yet.
I see issues here. Eclipse cannot run the code exactly like an agent, it’s not being governed by the Domino container the way an agent is. For whatever reason, agents do not handle multithreading the way a regular JVM does.
If you want to see a really simple example of how Notes agents handle multithreading, create an agent that has a new class that implements Runnable which does nothing but wait 10 seconds then print a message. Have your agent spawn a new thread with an instance of your runnable class and start it, and let the agent complete after that. Odds are good you won’t see the message at all.
Also, I suggest you try inserting this code in the Eclipse environment as the first line in the main class: