File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Help!!! I can't get BMT working with Orion and MS SQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Help!!! I can Watch "Help!!! I can New topic
Author

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

Jag Bains
Greenhorn

Joined: Sep 08, 2005
Posts: 3
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.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Have you created a Tx Data Source?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
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.


I think, therefore I exist -- Rene Descartes
Jag Bains
Ranch Hand

Joined: Nov 19, 2002
Posts: 39
How do I create a TX data source?
Jag Bains
Ranch Hand

Joined: Nov 19, 2002
Posts: 39
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

Joined: Sep 29, 2002
Posts: 1683
Check your EJB server vendor's documentation, there will be typically a GUI or script for configuration.
Jag Bains
Ranch Hand

Joined: Nov 19, 2002
Posts: 39
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

Joined: Nov 19, 2002
Posts: 39
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

Joined: Feb 17, 2005
Posts: 704
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

Joined: Sep 29, 2002
Posts: 1683
Perhaps the moderator can move this to the Orion forum. (I can't help you, I'm a WebLogic Server man ...)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help!!! I can't get BMT working with Orion and MS SQL Server