• 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Help!!! I can't get BMT working with Orion and MS SQL Server

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a servlet that posts a message to a stateless session bean, which inturn updates DB. The problem is that it always commits after each insert regardless to whether I have done a UserTransaction.Rollback or commit.

The Session bean is:



The UserTransaction and Context are create (call getIC() and getUT()) on calling the ejbCreate and ejbActivate methods.



the data-source.xml contains :


My ejb-jar.xml contains the following:



Can some please show me the errors of my ways.

Thanks.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you created a Tx Data Source?
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jag,

Your code and your settings look almost fine to me. I would also expect it to work. One might even suspect that the auto-commit feature is turned on, but that�s not the default with jta. There is however one more thing that looks wrong to me: the fact that your SLSB maintain the reference to the user transaction (ut) as an instance variable. Please notice that stateless means that the session bean does not maintain any state information for a specific client. However, stateless session beans can have non-client specific state like a database connection. Making your transaction object �sharable� I�m not pretty convinced is a good idea and you�d probably like changing the getUT method as follows (not to say that the synchronized keyword here is meaningless):

Besides I guess you declared ut as static and this makes no sense with ejbs (unless they are final). For the same reason I would advice you to rewrite the getIC() method and make ic non-static as well.
Regards.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I create a TX data source?
 
Jag Bains
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Valentin,

Understand what you are saying and will change.

However, I not 100% sure this will make any difference. Its almost as if I am missing something obvious when setting up the datasource or connection or UserTransaction.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your EJB server vendor's documentation, there will be typically a GUI or script for configuration.
 
Jag Bains
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roger,

My vender is Orion. Looking at the documentation, it states I should be setting up the datasource as:

3.5 Configuring a vendor XA DataSource for EJB or CMT usage

In order to use a vendor implementation of a XA DataSource for EJB or CMT usage, the DataSource has to be wrapped by the OrionCMTDataSource class in order for Orion to add support for distributed transactions and pooling as necessary.

This setup requires two DataSource configuration entries; one defining the vendor XA DataSource and another defining the wrapping Orion DataSource (OrionCMTDataSource) for EJB or CMT usage.

Below is an example of such a setup using Inet Opta 2000 XDataSource for MS SQL Server 7.0:

<data-sources> <!-- vendor XA DataSource -->
<data-source
name="vendorXA"
location="jdbc/vendorXACoreDS"
class="com.inet.tds.XDataSource"
username="sa" password="" host="localhost" > <property name="databaseName" value="sample"/> </data-source>
<!-- Orion CMT DataSource --> <data-source name="default" location="jdbc/defaultCoreDS" class="com.evermind.sql.OrionCMTDataSource" xa-source-location="jdbc/vendorXACoreDS" schema="database-schemas/ms-sql.xml" /> </data-sources>


Listing 5: A sample XA Datasource for EJB or CMT usage DataSource entry.

The first DataSource configuration entry listed above creates a Inet Opta2000 DataSource and binds it to the JNDI location " jdbc/vendorXACoredDS". The name of the database to use is stated in a parameter name-value pair as this parameter is not part of the normal parameters defined for data-source.xml entries, but the vendor's implementation needs this value.

The second DataSource configuration entry listed above creates a OrionCMTDataSource on top of the first DataSource and binds it to the JNDI location " jdbc/defaultCoreDS". As this DataSource needs to be used on top of a existing XA DataSource, the JNDI location value of the xa-source-location attribute is given a value of " jdbc/vendorXACoredDS", which will point it to the first DataSource (see above).

The second DataSource configuration entry listed above would become the default DataSource for all applications deployed after this DataSource descriptor has been deployed as its the first DataSource listed to use the OrionCMTDataSource.

 
Jag Bains
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i find the correct class to use for the XA data source?
I'm using MS sql server 2000.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jag,

I believe you�re right and I�m convinced the changes I recommended will not solve your problem. I remember somebody else on this forum having a similar problem and s/he solved it by setting the DataSource. He was using weblogic though and he needed to enable the TX-DataSource in order to honor the global transactions. Unfortunately I don�t know much about the Orion server and I cannot help you there. Check the documentation though.
Regards.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps the moderator can move this to the Orion forum. (I can't help you, I'm a WebLogic Server man ...)
 
Whatever you say buddy! And I believe this tiny ad too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic