Gary, thanks for your help on this. In the end I had to use the version of ActiveMQInitialContextFactory.java as attached by Edan idzerda at 2010-03-18 11:05 PM. I had a search through the ActiveMQ issue tracker and couldn't find if Edan's suggested code was ever added to core - do you know if it was? It would be very useful if it was for cases like the one I have outlined below where the setting up of the jndi environment is abstracted up out of the code. (i.e. in websphere you cannot define the 'xa=true' property anywhere - hence Edan's 'XAConnection' jndi name is invaluable!
For anybody else trying to get a connection to ActiveMQ within a WebSphere7.0.0-managed XA transaction and getting an error of "An illegal attempt to commit a one phase capable resource with existing two phase capable resources has occured" in the WebSphere SystemOut.log. This error was thrown when a Message Driven Bean was fired from a WebSphere default jms queue and it tried to write a message to an ActiveMQ queue all within an XA transaction. There was an Oracle db write in the same transaction also. Here are the steps to get around it:
1) Use the attached file kindly attached by Edan at 2010-03-18 11:05 PM to compile activemq-5.4.0.
2) In WebSphere Admin Console, create a new JMS provider:
i) Resources > JMS > JMS providers > New
ii) Use the following:
Name: use a name like 'ActiveMQ 5.4.0'
Classpath: add the paths to the following jar files (each path needs to be on a new line in the text box) activemq-all-5.4.0.jar, commons-logging-1.1.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar
External Initial Context Factory: org.apache.activemq.jndi.ActiveMQWASInitialContextFactory
External Provider URL: tcp://localhost:61616
3) In WebSphere Admin Console, create a new ConnectionFactory
i) Resources > JMS > Connection factories > New
ii) Use the following:
Name: use a name like 'ActiveMQ 5.4.0 Connection Factory'
JNDI name: jmsfactory/activemq540connfactory (this will be the name that any WebSphere-run apps will lookup using jndi)
External JNDI name: XAConnectionFactory (this is the new name added by Edan's code in step 1 above - basically, when you're code running in WebSphere calls 'jmsfactory/activemq540connfactory', WebSphere does a call to activemq using this jndi name, i.e. XAConnectionFactory )