on 01-25-2006 3:19 PM
Our system consists of ABAP and java stack. There are two server processes running on the system. We have a web application that is deployed. We want to lock an object in the init method of the servlet. We are using logicallocking to do that.
We want it so that when the application is deploying and running the init method on one server it obtains the lock. The other server process should wait till it obtains the lock.
This is the code I have
try {
lockOmscb();
_omscb.start();
} catch (LockException e1) {
_logger.logInfoExt("Omscb instance already running, cannot access lock on object.");
// TODO Auto-generated catch block
e1.printStackTrace();
}
private void lockOmscb() throws NamingException, LockException, TechnicalLockException, IllegalArgumentException {
Context initialContext = new InitialContext();
LogicalLockingFactory factory = (LogicalLockingFactory) initialContext.lookup(LogicalLockingFactory.JNDI_NAME);
_logger.logInfoExt("Got intial context lookup");
_lock = factory.createLogicalLocking("NWCPM", "NWCPM workspace" );
_logger.logInfoExt("created logical locking");
lock.lock(LogicalLocking.LIFETIMEUSERSESSION, "NWCPM/OMSCB", cfg.toString(), LogicalLocking. MODEEXCLUSIVE_NONCUMULATIVE);
_logger.logInfoExt("Got lock");
}
.
In the locking adapter I can see two locks being obtained at the same time. They are not getting it one after the other.
If I try to obtain the lock twice in the same method then it is throwing the lockException.
But this is not happening when the web application is being initialized in the two server processes.
Logicallocking is supposed to be access the lock between applications.
Is there a way I can acheive this ? If so how?
Can you please let me know.
thanks
Padmaja
Hi Padmaja,
the argument you are trying to lock is _cfg. As you do not deliver the code that defines this I cannot say what it contains, but it is easily predictable that this value is different in two different servers.
Make it a hard coded string with a value like "Humble" and then you are sure all instances will try to save exactly same value, which will make it work as expected.
Regards,
Benny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes I did take a look at the link earlier and still I was getting that error.
thanks
Padmaja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Did you check this
http://help.sap.com/saphelp_nw04/helpdata/en/a3/df5b1ee1bed348b198719e50af835d/frameset.htm
Eddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.