Version 2

    Symptom

     

    Standalone client. You want to lookup a UserTransaction from JNDI according to the AS guide . You do it by specifying the properties for the InitialContext programmatically, like so:

     

             UserTransaction tx = null;
             Properties props = new Properties();
             props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                   "org.jnp.interfaces.NamingContextFactory");
             props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
             props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
             InitialContext ctx = new InitialContext(props);
             tx = (UserTransaction) ctx.lookup("UserTransaction");
             tx.begin();
    

     

    But the lookup does not work, instead you get a java.lang.RuntimeException: UT factory lookup failed

     

    Explanation

     

    The properties are not forwarded to the lookup within UserTransactionSessionFactory. For details, see http://jira.jboss.com/jira/browse/JBAS-1270

     

    Solution

     

    For JBoss < 4.0.2, use a jndi.properties file instead of programmatic setup of the jndi properties. For JBoss >= 4.0.2, use the org.jboss.naming.NamingContextFactory instead of org.jnp.interfaces.NamingContextFactory. This factory provides the necessary functionality for the bugfix (remembering the last Properties passed to InitialContext()), see http://wiki.jboss.org/wiki/Wiki.jsp?page=NamingContextFactory.

     

    Links

     

     

    Referenced by: