• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

Creating and using Orbs to connect to Domino Database

I've written a JSR-168 java portlet that takes input from a form in a JSP page and connects to a Domino Database and then performs a Full Text index search. I'm using org.omg.corba for my connections and most of the time they work fine.

However, I am getting this error message in my SystemErr.log file on my Portal Server:

NotesException: Could not open Notes session: org.omg.CORBA.COMM_FAILURE: java.io.IOException: Connection closed: Host: <serverName.mywebsite.co.uk> Port: 63148  vmcid: 0x0  minor code: 1 completed: Maybe

I've read that COMM_FAILURE relates to a network issue in that the connection could not be established, the code below is used to create the orb, and then the session.

I found this code from the IBM site: http://www.ibm.com/developerworks/lotus/library/ls-Java_access_2/ and adapted it for my use.

Is there something in my code that may cause the session to drop randomly, or connection to the server to not be allowed for any reason?

Any help or suggestions are much appreciated!
Thanks, Nathan
import lotus.domino.*;
 
public abstract class Conn {
	
	static Session s = null;
	static org.omg.CORBA.ORB orb = null;
	static int count = 0;
	static Object sem = new Object();
	
	public static Session getCon(String host, String user, String pass) throws NotesException
	{
		try
		{
			synchronized(sem)
			{
				if((orb == null) || ((count++ % 10) == 0))
				{
					orb = NotesFactory.createORB();
				}
			}
			s = NotesFactory.createSession(host, orb, user, pass);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}		
		return s;
	}
}

Open in new window

0
ducey2001
Asked:
ducey2001
  • 10
  • 8
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
Maybe a silly question. is DIIOP started on the server?
0
 
ducey2001Author Commented:
Not a silly question :) Yes it is started - we have a clustered environment
0
 
Sjef BosmanGroupware ConsultantCommented:
Anything in the log-databases on the Domino server? Let's assume your prodding has been noticed...

Do you have some simple test program? A kind of Hello World application that connects to the Domino server, gets some info and disconnects?

> ... may cause the session to drop randomly ...
Did you ever get a connection with your application? The sentence seems to suggest that you do, from time to time. Otherwise, what do you get when you try to connect using telnet?

    telnet iii.ppp.aaa.ddd 63148
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ducey2001Author Commented:
This is from the Domino Server Logs:
DIIOP Server: ip.a.d.d connected
DIIOP Server: ip.a.d.d connected
These are the only entries related to DIIOP and there were no errors in the logs for both servers.

I've got a portlet that takes a search string from a user and then queries a Notes db using the getCon() method stated above. The connection works as expected, and the results are returned. So the connection in nearly all searches is working fine. It is just random when it fails, so hopefully with entries from the Domino server log I can see if anything sinister is happening in the background!

One thing I did notice with the getCon method, was that if I put a System.out.println() under the line:
s = NotesFactory.createSession(....
that depending on the number of previous time getCon() is called, that the sysout is printed out. So for example, the first time the getCon() is called, the system out is printed out once. Then if I perform another search, the sysout is printed out twice, and this goes on.

I do get a connection using my Java application, and when using telnet I can fine connect every time.

I've attached the two files I use for connecting and querying a domino database for you to have a look at if thats ok please?
Conn.zip
0
 
Sjef BosmanGroupware ConsultantCommented:
How many connections do you need? And is there really a need to use the orb parameter?

I noticed that there is a session.recycle() in the code, which is good. Where is orb recycled?

"Garbage collection has no effect on Domino Objects unless you first explicitly recycle them.

In a remote (IIOP) environment, recycle releases resources on the server. Although a client-side cache exists, the Java object can no longer communicate with its remote counterpart.
In a remote (IIOP) environment, recycle can be called from any thread on any object."

See the Help database on recycle()
0
 
ducey2001Author Commented:
Thanks for taking a look into this, it's much appreciated.
We have a popular website and so connection pooling has proven to be a big performance boost. We originally went with code that created a new DIIOP call each time, but now since using connection pooling, our servers are running a lot better and not failing now.

I'm not sure where's best to recycle the orb, as we've got a max of 10 connections in an orb, but we can't determine when those connections will be finished with, so can't call orb.recycle(). I'll have another look through my code and see where it could go, but it's the session that I'd need to recycle more than the orb, as the orb can be reused when another session is needed. Is my thinking correct?! :)

Thanks again
0
 
Sjef BosmanGroupware ConsultantCommented:
I assume, but I'm not a real Java guru, that the orb is static over all Conn objects? Doesn't that create a new orb every 10 new connections while overwriting the old one? That would mean to me that, when you had 1000 connections, you have 1 "live" orb and 99 zombies that never will be recycled.

Why all the orbs? Isn't one enough? Can't you create a global MyORB object that allows you to manage orbs? And takes care of regular orbituaries? ;-)
0
 
ducey2001Author Commented:
Ok, I see what you mean, and yes I think that is what happening in my code, so the Orb is being overwritten on the 11th connection and so all previous sessions will be lost because the object reference has been overwritten.

Is there a limit to the number of connections held in an orb? I've not seen any limits on the documentation I've read on the internet and java.sub.com site.

I'm not 100% sure how you mean to create a global MyOrb object, and then use it to manage the orbs? Or would I create a private org.omg.CORBA.ORB myOrb = NotesFactory.createOrb(); in my Conn class?
Nice idea of the orbituaries :)
0
 
Sjef BosmanGroupware ConsultantCommented:
http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/understanding/orb_using.html

# com.ibm.CORBA.MaxOpenConnections: (range: 0 through 2147483647) (default: 240)

Determines the maximum number of in-use connections that are to be kept in the connection cache table at any one time.

Maybe there's something similar in org.omg.CORBA.ORB ?

Are connections properly reused in the orb??
0
 
ducey2001Author Commented:
I've updated my Conn.java file to the file below. This way, the same orb is used, and the sessions are recycled within the orb.
Conn.txt
0
 
ducey2001Author Commented:
From the code I've written, yes they are properly reused, and recycled after they have been finished with. I'll test my new Conn.java class and see what performance is like.
0
 
Sjef BosmanGroupware ConsultantCommented:
Fingers crossed...
0
 
ducey2001Author Commented:
From doing my testing, it seems to be working ok, with no errors in the logs. The Conn.java class is shown below, I've made the orb static, and am using the same one now for all connections. Do you know if this is this good practice, or the best way to use an orb object?


import lotus.domino.*;
 
 
public abstract class Conn
{
	
	static Session s = null;
	static org.omg.CORBA.ORB orb = NotesFactory.createORB();
	
	public static Session getCon(String host, String user, String pass) throws NotesException
	{
		try
		{
			s = NotesFactory.createSession(host, orb, user, pass);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}		
		return s;
	}
}

Open in new window

0
 
Sjef BosmanGroupware ConsultantCommented:
Apparently, it is good practice ;-) But test thoroughly anyway.

If it's at all possible, add a destructor to your class to do a recycle() in order to release the orb and the back-end memory in Domino.
0
 
ducey2001Author Commented:
Thanks sjef, I'll add the recycle information.
Thanks very much for your help, it's much appreciated :)
0
 
ducey2001Author Commented:
Thanks for your help, much appreciated and were patient with me as I rambled on about my code! :)
0
 
ducey2001Author Commented:
Out of interest, is it possible to determine when a user navigates away from a portlet on a website? For example, a user goes to my portlet, performs a search, views the results, then visits another page on our website. Is there a way to determine they've now left the portlet and I can then recycle the orb? Because if I add the orb.recycle() after they've done a search, that orb could be being used by other users at the same time, meaning their connection would now be null.
0
 
Sjef BosmanGroupware ConsultantCommented:
Not a good idea: I often have multiple pages on the same website open (e.g. EE). The orb should probably only be recycle()d when the portlet is terminating. You know how to find the proof of the pudding?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 10
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now