Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java:comp/UserTransaction

843840Oct 7 2002 — edited Oct 8 2002
I use tomcat 4.1.12 server.
I write simple app, that in servlet creates UserTransaction object with context.lookup(java:comp/UserTransaction),
but it gives error msg like:

Cannot create resource instance at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:157)
at javax.naming.spi.NamingManager.getObjectInstance NamingManager.java:304) etc.

Do I have to configure something in web.xml or server.xml to create this transaction object?
Does anybody know why this code doesn't work?
Here is a sample code:

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Context ctx = null;
UserTransaction ut = null;
try {
ctx = new InitialContext();
ut=(UserTransaction) ctx.lookup("java:comp/UserTransaction");
ut.begin(); //start transaction
//do something
ut.commit();
}catch (NamingException ex) {
ex.printStackTrace();
} catch (Exception se) {
se.printStackTrace();
}
}

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 5 2002
Added on Oct 7 2002
1 comment
230 views