Archived

This forum has been archived. Please start a new discussion on GitHub.

Ice Destroy In Java

I hava a c++ code in which i create and destroy the ice communicator. The ice communicator gets destroyed properly.

In Java, the same functionality seems to hang.

Ice Version: 3.2.1

The code snippets are as below:

C++
void TransactionClient::setTransactionProxy() {
try {
iceCommunicator = Ice::initialize();
std::string proxydtls= Conf::getConf().getStrValue("DBENDPOINT");
Ice::ObjectPrx baseProxy = iceCommunicator->stringToProxy(proxydtls);
dbtxn::dbDefPrx dbDefaultProxy = dbtxn::dbDefPrx::checkedCast(baseProxy);
dbTransactionProxy = dbtxn::dbTransactionPrx::checkedCast(dbDefaultProxy, Conf::getConf().getStrValue("DBTRANSACTFACET"));

if(!dbTransactionProxy)
throw OutduException("invalid transaction proxy");
}
catch(Ice::LocalException & ex) {
throw OutduException(ex.what());
}
}

void TransactionClient::releaseTransactionProxy() {
if(iceCommunicator) {
try {
iceCommunicator->destroy();
}
catch(Ice::LocalException & ex) {
throw OutduException(ex.what());
}
}
}

void TransactionClient::beginTransaction() {
setTransactionProxy();

try {
dbTransactionProxy->begin(transactionId);
}
catch(dbtxn::OutduIceDBException & ex) {
releaseTransactionProxy();
throw OutduException(ex.errorCode.c_str(),ex.errorMessage.c_str());
}
catch(Ice::LocalException & ex) {
releaseTransactionProxy();
throw OutduException(ex.what());
}

releaseTransactionProxy();
}

void TransactionClient::rollback() {
setTransactionProxy();

try {
dbTransactionProxy->rollback(transactionId);
}
catch(dbtxn::OutduIceDBException & ex) {
releaseTransactionProxy();
throw OutduException(ex.errorCode.c_str(),ex.errorMessage.c_str());
}
catch(Ice::LocalException & ex) {
releaseTransactionProxy();
throw OutduException(ex.what());
}

releaseTransactionProxy();
}

void TransactionClient::commit() {
setTransactionProxy();

try {
dbTransactionProxy->commit(transactionId);
}
catch(dbtxn::OutduIceDBException & ex) {
releaseTransactionProxy();
throw OutduException(ex.errorCode.c_str(),ex.errorMessage.c_str());
}
catch(Ice::LocalException & ex) {
releaseTransactionProxy();
throw OutduException(ex.what());
}

releaseTransactionProxy();
}

Java
private void setTransactionProxy() throws OutduException {
try {
iceCommunicator = Ice.Util.initialize();
baseProxy = iceCommunicator.stringToProxy(Configuration.dbproxy + ":" + Configuration.dbendpoint);
defaultProxy = dbtxn.dbDefPrxHelper.checkedCast(baseProxy);
transactionProxy = dbtxn.dbTransactionPrxHelper.checkedCast(defaultProxy,Configuration.dbtransactionproxy);

if(transactionProxy == null)
throw new OutduException("invalid transaction proxy");
}
catch(Ice.LocalException ex) {
throw new OutduException(ex.getMessage());
}
catch(Exception ex) {
throw new OutduException(ex.getMessage());
}
}

private void releaseTransactionProxy() throws OutduException {
if(iceCommunicator!=null) {
try {
iceCommunicator.destroy();
}
catch(Ice.LocalException ex) {
throw new OutduException(ex.getMessage());
}
catch(Exception ex) {
throw new OutduException(ex.getMessage());
}
}
}

public void beginTransaction() throws OutduException {
setTransactionProxy();

try {
transactionProxy.begin(transactionId);
}
catch(dbtxn.OutduIceDBException ex) {
releaseTransactionProxy();
throw new OutduException(ex.errorCode,ex.errorMessage);
}
catch(Ice.LocalException ex) {
releaseTransactionProxy();
throw new OutduException(ex.getMessage());
}
catch(Exception ex) {
releaseTransactionProxy();
throw new OutduException(ex.getMessage());
}

releaseTransactionProxy();
}

public void rollback() throws OutduException {
setTransactionProxy();

try {
transactionProxy.rollback(transactionId);
}
catch(dbtxn.OutduIceDBException ex) {
releaseTransactionProxy();
throw new OutduException(ex.errorCode,ex.errorMessage);
}
catch(Ice.LocalException ex) {
releaseTransactionProxy();
throw new OutduException(ex.getMessage());
}
catch(Exception ex) {
releaseTransactionProxy();
throw new OutduException(ex.getMessage());
}

releaseTransactionProxy();
}

public void commit() throws OutduException {
setTransactionProxy();

try {
transactionProxy.commit(transactionId);
}
catch(dbtxn.OutduIceDBException ex) {
releaseTransactionProxy();
throw new OutduException(ex.errorCode,ex.errorMessage);
}
catch(Ice.LocalException ex) {
releaseTransactionProxy();
throw new OutduException(ex.getMessage());
}
catch(Exception ex) {
releaseTransactionProxy();
throw new OutduException(ex.getMessage());
}

releaseTransactionProxy();
}


Can you tell me what the problem is?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Could you upgrade to 3.3.0? We only provide free support on the forums for the latest Ice version. Also, which operating system are you using? In any case, the best way to figure out the cause of a hang is to get a thread dump of the JVM. You can easily do this by sending the process the SIGQUIT signal or by hitting Ctrl-\ in the terminal where the Java process is running.

    Cheers,
    Benoit.