Calling one EJB from another EJB

Discussion in 'Java' started by Rizwan, May 3, 2005.

  1. Rizwan

    Rizwan Guest

    Hi,

    My environment is Eclipse 3.0 with Lomboz Plugin; JBoss 3.2 Application
    Server; Microsoft SQL Server 2000 Database.

    The web application I am working on is using 2 different datasources
    (odbc-ds.xml and mssql-ds.xml). One is using Sun's ODBC-JDBC Driver while
    the other one is using Microsoft's SQL Server JDBC Driver.

    I have 2 EJBs (Stateless Session Beans): PageEngine and
    ConfigurationManager. "PageEngine" is using Sun's ODBC-JDBC Driver while the
    "ConfigurationManager" is using Microsoft's SQL Server JDBC Driver. The
    "ConfigurationManager" uses Hibernate.

    In one of the methods of "ConfigurationManager", I need to call a method in
    "PageEngine". So I create a new method getPageEngine() in
    "ConfigurationManager" to get the remote interface of "PageEngine".

    private pageEngine getPageEngine() {
    // Remote interface
    pageEngine pe = null;

    try {
    // Home interface
    pageEngineHome peHome = pageEngineUtil.getHome();
    pe = peHome.create();
    } catch (NamingException ne) {
    System.out.println( "ConfigurationManager.java: getPageEngine():
    NamingException= " + ne.getMessage() );
    ne.printStackTrace();
    } catch (RemoteException re) {
    System.out.println( "ConfigurationManager.java: getPageEngine():
    RemoteException= " + re.getMessage() );
    re.printStackTrace();
    } catch (CreateException ce) {
    System.out.println( "ConfigurationManager.java: getPageEngine():
    CreateException= " + ce.getMessage() );
    ce.printStackTrace();
    }
    return pe;
    }

    Now I use it in my code and dispaly the data in a JSP. Everything works fine
    except that in the log file I got a warning twice:


    WARN [TxConnectionManager] Prepare called on a local tx. Use of local
    transactions on a jta transaction with more than one branch may result in
    inconsistent data in some cases of failure.

    Can somebody explain this error and its remedy?

    Thanks

    Rizwan
     
    Rizwan, May 3, 2005
    #1
    1. Advertising

  2. Rizwan wrote:

    ....
    > I have 2 EJBs (Stateless Session Beans): PageEngine and
    > ConfigurationManager. "PageEngine" is using Sun's ODBC-JDBC Driver while the
    > "ConfigurationManager" is using Microsoft's SQL Server JDBC Driver. The
    > "ConfigurationManager" uses Hibernate.
    >
    > In one of the methods of "ConfigurationManager", I need to call a method in
    > "PageEngine". So I create a new method getPageEngine() in
    > "ConfigurationManager" to get the remote interface of "PageEngine".
    >
    > private pageEngine getPageEngine() {
    > // Remote interface
    > pageEngine pe = null;

    ....
    > return pe;
    > }
    >
    >
    > WARN [TxConnectionManager] Prepare called on a local tx. Use of local
    > transactions on a jta transaction with more than one branch may result in
    > inconsistent data in some cases of failure.
    >
    > Can somebody explain this error and its remedy?



    You're using two datasources with two separate transactions with this
    datasources.
    From your code the datasource/transaction used by PageEngine should
    depend on ConfigurationManager, but for Local Transactions this is not
    possible.
    You would have to use XATransactions for both or, if there is no need
    for a common transaction, set transaction attribute to "RequiresNew" for
    PageEngine.
     
    Frank Langelage, May 3, 2005
    #2
    1. Advertising

  3. Rizwan

    Rizwan Guest

    > From your code the datasource/transaction used by PageEngine should
    > depend on ConfigurationManager, but for Local Transactions this is not
    > possible.


    I think its the other way around. PageEngine does not depends on anything.
    It is kind of a service to generate Web Pages. The ConfigurationManager
    depends on PageEngine to accomplish a particular task.
    I dont understand the "Local Transactions" in this context. Can you explain
    it please?

    > You would have to use XATransactions for both or, if there is no need
    > for a common transaction, set transaction attribute to "RequiresNew" for
    > PageEngine.

    Can you explain XATransactions? I am a newbie for this stuff.

    Thanks


    "Frank Langelage" <> wrote in message
    news:...
    > Rizwan wrote:
    >
    > ...
    > > I have 2 EJBs (Stateless Session Beans): PageEngine and
    > > ConfigurationManager. "PageEngine" is using Sun's ODBC-JDBC Driver while

    the
    > > "ConfigurationManager" is using Microsoft's SQL Server JDBC Driver. The
    > > "ConfigurationManager" uses Hibernate.
    > >
    > > In one of the methods of "ConfigurationManager", I need to call a method

    in
    > > "PageEngine". So I create a new method getPageEngine() in
    > > "ConfigurationManager" to get the remote interface of "PageEngine".
    > >
    > > private pageEngine getPageEngine() {
    > > // Remote interface
    > > pageEngine pe = null;

    > ...
    > > return pe;
    > > }
    > >
    > >
    > > WARN [TxConnectionManager] Prepare called on a local tx. Use of local
    > > transactions on a jta transaction with more than one branch may result

    in
    > > inconsistent data in some cases of failure.
    > >
    > > Can somebody explain this error and its remedy?

    >
    >
    > You're using two datasources with two separate transactions with this
    > datasources.
    > From your code the datasource/transaction used by PageEngine should
    > depend on ConfigurationManager, but for Local Transactions this is not
    > possible.
    > You would have to use XATransactions for both or, if there is no need
    > for a common transaction, set transaction attribute to "RequiresNew" for
    > PageEngine.
     
    Rizwan, May 3, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    1
    Views:
    699
    John C. Bollinger
    Jul 15, 2003
  2. loveNUNO
    Replies:
    2
    Views:
    933
    loveNUNO
    Nov 20, 2003
  3. Andre Broers
    Replies:
    6
    Views:
    416
    Andre Broers
    Nov 21, 2007
  4. Raymond Schanks
    Replies:
    0
    Views:
    663
    Raymond Schanks
    Aug 3, 2010
  5. Robert Cohen
    Replies:
    3
    Views:
    283
    Andrew Durstewitz
    Jul 15, 2003
Loading...

Share This Page