Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have below mentioned method for implementing UserTransaction in JNDI



private UserTransaction getUserTransactionFromJNDI() {
InitialContext context;
Object result;
try {
context = new InitialContext();
result = context.lookup("java:comp/UserTransaction"); // lookup in
// JBossAS
} catch (NamingException ex) {
throw new RuntimeException("UserTransaction could not be found in JNDI", ex);
}
return (UserTransaction) result;
}


And created context.xml and web.xml with following code
context.xml
<Resource
name="UserTransaction"
auth="Container"
type="javax.transaction.UserTransaction"
factory="org.jnp.interfaces.NamingContextFactory"/>

web.xml
<resource-ref>
<description>for implementing Transaction
<res-ref-name>UserTransaction
<res-type>javax.transaction.UserTransaction
<res-auth>Container


But i can get error javax.naming.NamingException: Cannot create resource instance
What i can do?

What I have tried:

Already tried solution shown in above
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900