cancel
Showing results for 
Search instead for 
Did you mean: 

Logical locking not working

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Yes I did take a look at the link earlier and still I was getting that error.

thanks

Padmaja

eddy_declercq
Active Contributor
0 Kudos