Skip to main content

Problem using OTS and JTS within the same application

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

  • Product Name: Borland Application Server
  • Product Version: 6.6
  • Product Component: OTS/JTS/Transaction
  • Platform: All

Scope of the Document:

This document highlights and addresses the erroneous behavior detected in applications containing multiple partitions where some partitions are using OTS engine (VisiTransact Service) while others are using JTS. It is seen that sometimes a partition supposed to use OTS may erroneously cache the reference of JTS belonging to another partition. And if the partition containing this particular JTS is stopped, the partition caching JTS reference would start giving errors.

Problem Description:

- An application contains multiple partitions say 1 to n. EJBs deployed in one of the partition, say i, is supposed to use JTS Transaction Manager. OTS is started as an external service available for EJBs in all the partitions and JTS is deactivated in all the partitions except partition i.

- When the partitions are started in order, during startup and after that there is no problem and everything works fine.

- But once the partition i (using JTS) is stopped, few partitions say j, k start getting following exception stating that it can not locate the transaction service (though the OTS is still running fine):

2007-04-25 14:21:48,140 DEBUG - *sc* received request: CORBA::Object.purchase 2007-04-25 14:21:48,140 DEBUG - *st* prepare context READY --[method:purchase]--> READY 2007-04-25 14:21:48,140 DEBUG - *tx* Dispatcher.invoke: returning 2PC TM 2007-04-25 14:21:48,140 DEBUG - *tx* Dispatcher.invoke: returning 2PC TM 2007-04-25 14:21:48,140 DEBUG - *tx* Dispatcher.invoke: tx.begin(serverTransaction) 2007-04-25 14:21:49,109 ERROR - Fatal Error: Transaction service could not be located org.omg.CORBA.OBJECT_NOT_EXIST: java.net.ConnectException: Connection refused: connect vmcid: 0x56420000 minor code: 1 completed: No at com.inprise.vbroker.ProtocolEngine.PortfolioImpl.getConnector(Unknown Source) at com.inprise.vbroker.ProtocolEngine.ManagerImpl.getConnector(Unknown Source) at com.inprise.vbroker.orb.DelegateImpl._bind(Unknown Source) at com.inprise.vbroker.orb.DelegateImpl.verifyConnection(Unknown Source) at com.inprise.vbroker.orb.DelegateImpl.is_local(Unknown Source) at org.omg.CORBA.portable.ObjectImpl._is_local(ObjectImpl.java:354) at org.omg.CosTransactions._TransactionFactoryStub.create(_TransactionFactoryStub.java:29) at com.visigenic.services.CosTransactions.CurrentImpl.begin_with_name(CurrentImpl.java:183) at com.visigenic.services.CosTransactions.CurrentImpl.begin(CurrentImpl.java:109) at com.visigenic.services.CosTransactions.TSCurrentManager.begin(TSCurrentManager.java:77) at com.inprise.visitransact.jta.TransactionManagerImpl.begin(TransactionManagerImpl.java:161) at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1369) at com.inprise.ejb.Dispatcher.invokeJACCSecurityCheck(Dispatcher.java:1137) at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dispatcher.java:1147) at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:892) at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:664) at com.inprise.ejb.EJBHome.dispatcherInvokeBeanMethod(EJBHome.java:85) at com.inprise.ejb.EJBHome$ComponentInterfaceMethodCache.invokeDispatcherMethod(EJBHome.java:1563) at com.inprise.ejb.EJBHome.invokeDispatcherMethod(EJBHome.java:63) at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:468) at com.borland.examples.ejb.shoppingcart.CartPOAInvokeHandler.purchase(CartPOAInvokeHandler.java:101) at com.borland.examples.ejb.shoppingcart.CartPOAInvokeHandler.purchase(CartPOAInvokeHandler.java:184) at com.borland.examples.ejb.shoppingcart.CartPOA._invoke(CartPOA.java:90) at com.borland.examples.ejb.shoppingcart.CartPOA._invoke(CartPOA.java:60) at com.inprise.vbroker.poa.POAImpl.invoke(Unknown Source)

- Now if we restart partition j and k, error disappears and all partitions work fine again.

Steps to replicate the issue:

Create four similar partitions and then deploy the <install dir>\\examples\\ejb\\basic\\cart example on each of them. On the 4th partition use JTS Transaction Manager whereas deactivate the JTS on other three partitions so they use OTS VisiTransact Service. On running the client, the 4 partitions work in round-robin order to serve the client request, so everything runs fine. But the following exception shows up in Partition log on stopping the partition running the JTS Transaction Manager.

1. Create 4 similar partitions as actively Managed objects in an configuration. 2. Deploy <install dir>\\examples\\ejb\\basic\\cart example on each of them. 3. Start the OTS engine. 4. On the 4th partition enable JTS Transaction Manager. 5. While on other three disable the JTS Transaction Manager so they use OTS VisiTransact Service. 6. Now, run the client as follows:

>appclient cart_beans_client.jar

7. The 4 partitions work in round-robin order to serve the client request and gives following output, so everything runs fine till here.

======= Cart Summary ======== Price: $39.99 Book title: J2EE Blueprints Price: $11.97 CompactDisc title: Kind of Blue Total: $51.96 ============================= ======= Cart Summary ======== Price: $11.97 CompactDisc title: Kind of Blue Price: $49.99 Book title: Programming with VisiBroker Total: $61.96 ============================= Could not purchase the items: com.borland.examples.ejb.shoppingcart.CreditCardExpiredException: Expiration date: Tue Dec 31 00:00:00 SGT 2002

8. Now stop the partition running JTS.

9. Run the client as follows for at least three consequent times (as it will be served in round-robin order by the remaining three partitions)

>appclient cart_beans_client.jar

10. The following exception appears in one or more of the Partition's log:

2007-04-25 14:54:42,562 DEBUG - *tx* Dispatcher.invoke: tx.begin(serverTransaction) 2007-04-25 14:54:43,656 ERROR - Fatal Error: Transaction service could not be located org.omg.CORBA.OBJECT_NOT_EXIST: java.net.ConnectException: Connection refused: connect vmcid: 0x56420000 minor code: 1 completed: No at com.inprise.vbroker.ProtocolEngine.PortfolioImpl.getConnector(Unknown Source) at com.inprise.vbroker.ProtocolEngine.ManagerImpl.getConnector(Unknown Source) at com.inprise.vbroker.orb.DelegateImpl._bind(Unknown Source)

11. Also, following exception is seen at client side:

======= Cart Summary ======== Price: $39.99 Book title: J2EE Blueprints Price: $11.97 CompactDisc title: Kind of Blue Total: $51.96 ============================= ======= Cart Summary ======== Price: $11.97 CompactDisc title: Kind of Blue Price: $49.99 Book title: Programming with VisiBroker Total: $61.96 ============================= Client Container Error: Caught unhandled exception from client application java.rmi.NoSuchObjectException: CORBA OBJECT_NOT_EXIST 1447165953[]; nested exception is: org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: 0x56420000 minor code: 1 completed: No at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at com.inprise.vbroker.rmi.CORBA.UtilImpl.newInstance(Unknown Source) at com.inprise.vbroker.rmi.CORBA.UtilImpl._mapSystemException(Unknown Source) at com.inprise.vbroker.rmi.CORBA.UtilImpl.mapSystemException(Unknown Source) at javax.rmi.CORBA.Util.mapSystemException(Util.java:67) at com.borland.examples.ejb.shoppingcart._Cart_Stub.purchase(_Cart_Stub.java:426) at com.borland.examples.ejb.client.CartClient.main(CartClient.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.borland.appclient.Container.invokeAppClientMain(Container.java:273) at com.borland.appclient.Container.main(Container.java:220)

Resolution:

Workaround:

In order to prevent Partitions using OTS to cache another partition's JTS reference, a bean-level property, "ejb.transactionManagerInstanceName" may be used to specify the name of OTS at EJB level for each EJB that require 2PC transaction completion. Both the Transaction Manager (JTS) and the VisiTransact service (i.e. OTS engine) may be available for all EJBs but only those that do not have this property specified will discover the Transaction Manager.

This property can be commonly used for session or message-driven beans since transactions are usually demarcated in a session bean facade or the onMessage method of a message-driven bean.

Here are steps to set the property:
1. To set the "ejb.transactionManagerInstanceName" property use the Management Console.
Navigate to your deployed EJB module, right mouse click on it and select "Editor Deployment descriptor" popup menu.

2. In the DDEditor select the required bean from the Navigation Pane. Select the "Properties"
tab and add the "ejb.transactionManagerInstanceName" property. Define the property as a
String and specify a unique name value such as "2PhaseEngine".
Note the value MUST exceed more 15 characters.

3. Next, you must modify the VisiTransact service (i.e OTS) factory name with the
"ejb.transactionManagerInstanceName" value (i.e factory name to be "2PhaseEngine").
In the Management Console, select the VisiTransac service (i.e. OTS) then right mouse click on it and select "Properties..." popup menu.

4. In the "Transaction Service Properties" dialog, click on "Edit..." button, this will launch "Arguments:" dialog.

5. In the "Arguments:" dialog, edit "-Dvbroker.ots.name=OTS" to "-Dvbroker.ots.name=2PhaseEngine", then click "OK" button of "Arguments:" dialog, follow by "OK" of "Transaction Service Properties" dialog


Ideally, this property is only needed in cases where in the same partition some EJBs are to use JTS while others shall use OTS. So, the problem discussed by this document is recognized as a bug that EJBs from one partition happen to cache JTS Transition Service from another Partition.

CR 9123 has been filed to address this issue in future releases, meanwhile workaround explained above provides the perfect solution.

 

Other Useful Readings:

Chapter on "Transaction management" in Borland AppServer 6.6 Developer’s Guide.

 


#JTS
#transaction
#OTS
#Security
#AppServer
#VisiBroker