• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Call Transactional Remote Session Bean From Spring

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have deployed one transactional remote session bean at server B, which should be executed in caller's transaction context. I am calling this remote session bean from my spring bean, where JTA transaction is already started(TransactionManager is injected from JBossAS). I am doing some database operation in my spring class first and then calling remote session bean with transaction active.

I am getting EjbTransactionRequiredException when method with MANDATORY transaction attribute is called in remote session bean. I doubt that whether transaction context from Spring can be propagated to remote session bean? If this is possible, then what might be going wrong in my case.

I can post code snippets or configuration if required.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the entire exception stacktrace and the relevant code where the injection happens and which starts the transaction? Which version of JBoss AS is this?
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jaikiran,

I am using JBoss 5.0.1 GA release. When I am calling remote session bean residing in the same server instance, it works perfectly fine but not getting following stack trace when remote session bean is deployed in separate server instance.

Stacktrace :


Configurations for TransactionManager & Datasource


UserServiceImpl class :


 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When I am calling remote session bean residing in the same server instance, it works perfectly fine but getting following stack trace when remote session bean is deployed in separate server instance.



See this https://coderanch.com/t/513513/JBoss/JBOSS-Distributed-Transactions
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that link Jaikiran. As far as what I understand from that link is, that example looks up for UserTransaction instance from target ejb server & then controls life cycle of that transaction. I have not tried it that way.

What I exactly intent to achieve is I want to seamlessly have distributed transaction achieved i.e. container should be managing distributed transaction. As shown in the example in previous post, when save() method shown in the snippet is called, spring looks up java:/TransactionManager from local Jboss server(site 1) & transaction is started, it then delegates call to userDao.save() method in remote session bean at Jboss server(site2). I want that in this call, active transaction should be propagated to site 2. Is it possible to achieve?
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Have you tried using some other Datasource provider(The one configured using the Driver provided by Database you are using). As you are using a Commons DBCP pool, AFAIK it is the basic implementation of connection pool and datasource. May be you can check with the documentation of DBCP whether this connection can take part in distributed transacation.

Regards,
Amit
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit,

I have also tried it by injecting MySQL's XA datasource as well as local datasource configured in jboss but got the same result.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vish
I had a similar issue when communicating across Websphere Servers of different versions.
To get it working I had to turn off Transaction Authorization Coordination. Though this sounds like some thing wrong that is what is recommened by IBM.
So you might have something like this to be configured in Jboss.
See if this helps
http://community.jboss.org/message/106266
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lingan,

I think that discussion refers to quite older jboss version. I guess JBoss 5.0 supports 2+ jvms & includes arjuna products.

Just want to add one more isolation if someone can give inputs from that. I tried to call that same remote ejb(site 2) from other EJB located at site 1. But getting the same exception. So spring & its injections are not in the picture now. Just I want to have transaction propagation between two remotely located ejbs. I think it is quite common scenario in ejb environment. Eagerly looking for some help.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the wiki, I pointed to earlier, already has these details http://community.jboss.org/wiki/TransactionPropagationwithJBoss
 
Vish Shukla
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jaikiran,

sorry but I am getting totally confused.

Here are the queries and observations I have:

  • http://community.jboss.org/wiki/TransactionPropagationwithJBoss says :

    JBoss supports the first 2 cases via "ClientUserTransactionService" which is described in the AS user guide (see http://docs.jboss.org/jbossas/jboss4guide/r5/html/ch4.chapt.html):

    The ClientUserTransactionService MBean publishes a UserTransaction implementation under the JNDI name UserTransaction.


    so it means I need to use BMT to achieve this right?? what if I am using CMT, just like what is shown in the example in the discussion, using java:TransactionManager


  • The Default Transaction Manager :

    While it does support propagating transaction contexts with remote calls, it does not support propagating transaction contexts to other virtual machines, so all transactional work must be done in the same virtual machine as the JBoss server.



    I am not able to get what this quote says.


  • Transaction Propagation :

    If transaction contexts are to be propagated with RMI/JRMP calls, the transaction manager must also implement two simple interfaces for the import and export of transaction propagation contexts (TPCs). The interfaces are TransactionPropagationContextImporter, and TransactionPropagationContextFactory, both in the org.jboss.tm package.

    These interfaces and their JNDI locations are:

    The javax.transaction.TransactionManager interface is used by the application server to manage transactions on behalf of the transactional objects that use container managed transactions. It must be bound under the JNDI name java:/TransactionManager.

    The TransactionPropagationContextFactory interface is called by JBoss whenever a transaction propagation context is needed for transporting a transaction with a remote method call. It must be bound under the JNDI name java:/TransactionPropagationContextImporter.

    The TransactionPropagationContextImporter interface is called by JBoss whenever a transaction propagation context from an incoming remote method invocation has to be converted to a transaction that can be used within the receiving JBoss server VM.


    so that JBoss' implementation of TransactionManager got by java:/TransactionManager doesn't implement TransactionPropagationContextImporter & TransactionPropagationContextFactory interfaces?? what things should I do to have CMT, transaction propagation across remote calls & 2 phase commit?


  • When studying EJB specs, I thought distributed transaction propagation across remote calls should be seamlessly achieved, without putting much efforts in system level details.
    reply
      Bookmark Topic Watch Topic
    • New Topic