Hi all,
I am experience some problems with UserTransactions. The code below shows how I setup my InitialContext and then use that context to lookup a UserTransaction:
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost");
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
this.initialContext = new InitialContext(properties);
UserTransaction ut = (UserTransaction) PortableRemoteObject.narrow(this.initialContext.lookup("UserTransaction"), UserTransaction.class);
...
ut.begin();
...
ut.commit();
The begin method throws the following exception:
javax.transaction.SystemException: java.lang.RuntimeException: UT factory lookup failed: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.jboss.tm.usertx.client.ClientUserTransaction.begin(ClientUserTransaction.java:107)
at testing.com.bluespace.core.implementation.events.publishers.mailbox.receivemail.ReceiveMailPublisherTest.testPublish(ReceiveMailPublisherTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
...
As my code above clearly shows, I did provide that setting. What is going wrong here?
Rudi.