Discussions

EJB programming & troubleshooting: Is XA necessary in this situation?

  1. Is XA necessary in this situation? (7 messages)

    I have an EJB (BMP entity bean, technically) in WebSphere 6, which accesses another EJB remotely in another application (that is to say, it accesses the second EJB through a remote interface, rather than a local interface). I am using container managed transactions, and in fact, I have so far allowed the default transactional settings to remain. Both EJBs use the same defined JNDI DataSource to retrieve connections, which they then perform a series of statements on.

    When the first bean executes, it forms a connection and executes a few statements against the database. It then delegates to the second EJB to retrieve some other information. When the second bean attempts to connect to the database (actually while creating the PreparedStatement), it fails with the following message on the console:

    WTRN0062E: An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction.
    (I can post the stack trace if it's needed)

    The message is fairly self-explanatory, but still, I'm confused. I'm not using multiple databases or even DataSources, here, so why does it want to put this in the context of an XA transaction? Is XA required here, or do I have something configured incorrectly?

    Any help would be greatly appreciated.

    Thanks!

    Threaded Messages (7)

  2. Two different applications[ Go to top ]

    Everything seem resonable. You have two differents application. So probably two different classloaders. You are using remote interface. So it's equivalent as having two different processes or two different computers. Why are you surprise it expect an XA transaction?

    What's is more surprising is that you are in the same computer and created two different applications that are closely related and used remote interface. Why not having everything in the same EAR?

    Having everything in the same EAR will probably activate a WebLogic optimization about your use of remote interfaces.
  3. Two different applications[ Go to top ]

    Why not having everything in the same EAR?

    In this case, the application being used is the interface to our security system (we are using WebSphere security with LDAP, but sometimes we need to know information not about the logged-in user, but rather a user whose data the logged-in user wishes to work with). This is a common thread througout all of our applications (or will be), so the security application is meant to stand alone and be used by other applications.

    I really don't want to bother with XA, but it would appear I am going to have little choice in the matter. Frustratingly enough, I really don't care if the transactions with the security application happen within a transaction at all (read-only), but that is specific to my application, so I can't change how the security application is set up. grrr...
    Why are you surprise it expect an XA transaction?
    Because I am new to a lot of this and still learning my way around :-)

    Thanks for the reply Sebastien. I'm going to try to find some work-arounds (application design-wise) before I try to set up an XA datasource and switch to it, but I'll probably have to deal with it.
  4. Local interface?[ Go to top ]

    If I were to place my application on the same server as the second application and use a Local interface to it, would this remove the requirement to use an XA transaction?

    This is a bad solution for us, but at least it would be a solution. I am having trouble getting an XA datasource to work (keeps hanging with no errors).
  5. Local interface?[ Go to top ]

    If I were to place my application on the same server as the second application and use a Local interface to it, would this remove the requirement to use an XA transaction?This is a bad solution for us, but at least it would be a solution. I am having trouble getting an XA datasource to work (keeps hanging with no errors).

    If you keep one EAR then it won't need XA transaction. But then as you have pointed out that you have kept the security domain in a different web application, which indeed makes sense. I am not sure but your organisation has kept the security as a different application because all the other applications of the organisation can use the same security app.

    I believe XA is a better approach and you may want to post the errors(by checking the server logs) you are getting while implementing two phase commit and put some debug statements to see where it hangs.

    Hope it helps.
  6. Local interface?[ Go to top ]

    I believe XA is a better approach and you may want to post the errors(by checking the server logs) you are getting while implementing two phase commit and put some debug statements to see where it hangs.

    That's the problem: I get no errors, statements, etc at all. I traced the problem, and it seems to happen upon the executeQuery() of the second (called) application. So my application executes some database query (or queries), then calls the second (security) application. The second application successfully makes a connection, creates a PreparedStatement, and sets the values on that statement, and when it calls executeQuery(), everything simply stops as though it's waiting on the database. I looked at the DB monitor, and for each statement executed, I have a database thread that is on the "CLOSE step." Everything seems to stop in this state and do absolutely nothing until I use the OS to end the java.exe process of the webserver. Then (obviously), the server stops, and the database threads are released and dissapear.

    It very well may be a database config issue, too. I just don't know.

    Anyhow, it was decided that we would (at least for this project) directly connect to the backend (database tables) of the security application within my application. While we don't get to use the business logic built into the security application (not to mention, I'm tightly coupled to the database structure of the security application), at least it works and lets us move on.

    Further projects will have to solve this problem. Hopefully we'll be able to come up with something a little more useful later :-).

    Thanks for all the help!
  7. Local interface?[ Go to top ]

    That is strange. How you are getting the connections. Using the datasource right? Also please check that in the config file two phase commit is set to true {EnableTwoPhaseCommit="true"}.

    If you have access to weblogic console then you can check that if any thread has been stuck.

    Thanks.
  8. Local interface?[ Go to top ]

    Using the datasource right? Also please check that in the config file two phase commit is set to true {EnableTwoPhaseCommit="true"}.If you have access to weblogic console then you can check that if any thread has been stuck.Thanks.

    Sure (this is WebSphere 6, btw). It's just an standard XA Datasource using a type 2 JDBC driver. It's an old driver/client version, so it could be a problem with the driver as well. But right now my project is in a time-crunch, so I don't have much time to play with things. The work-around seems to be a "good-enough" solution for this application.

    Thanks again for all of your help!