I have written a small example in EJB3.0. This has got a simple session bean and an entity. Iam calling entitymanager.persist() in session bean business method to persist the data into database. But due to some problem, it got a runtime exception and displayed full stacktrace of that exception. I have try catch block in session bean business method and i have not given ex.printStackTrace() in catch, but still it is printing the full stacktrace. I think, it is being thrown by the toplink essentials. Do i need to configure anything in persistence.xml file? Is there anyway to not to print full stack trace whenever there is any exception. Rather i just need the short description of the error which i can get using ex.toString().
You are probably using a CMT session bean with a container-managed entity manager, so the exception would be happening at commit time, which is when the method has already completed. This would be why your catch block could not catch it. Try doing an em.flush() call from inside the session bean catch block. This will force your entity manager to write everything out immediately and give you a chance to catch the exception, if that is what you want to do.
I am not sure that I understand why you wouldn't want the full stack trace to be printed for a development-time error, but anyway...
There is no standard persistence.xml option in JPA, but there is an option in TopLink Essentials to control the stack trace being printed out. This is likely happening at the container level, though, so you would probably need to configure the logging in OC4J, which just uses java.util.logging by default, so you could customize it with handlers, etc, if you wanted to.