Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Calling one EJB from another EJB

Reply
Thread Tools

Calling one EJB from another EJB

 
 
Rizwan
Guest
Posts: n/a
 
      05-03-2005
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


 
Reply With Quote
 
 
 
 
Frank Langelage
Guest
Posts: n/a
 
      05-03-2005
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.
 
Reply With Quote
 
 
 
 
Rizwan
Guest
Posts: n/a
 
      05-03-2005
> 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to generate "ejb-jar.xml" from EJB class (source)? "ejb-jar.xml" appserver independent? Raymond Schanks Java 0 08-03-2010 08:21 AM
How to call an ejb from an ejb from another applicartion server Andre Broers Java 6 11-21-2007 09:17 AM
EJB on Weblogic7 : accessing Ejb thru *Local interface* fails due to JNDI lookup Mumbai Joe Java 0 07-29-2003 04:16 PM
Dynamically Access & Call An EJB From Another EJB? Steve Java 1 07-15-2003 06:47 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments