Hello there, Thanks for your time,I am not sure about the problem's domain so I am posting it here. I have a servlet which listens at 1234 (Thread) port, but when I start the server it invokes the servlet twice, hence it was binding exception. I solved it by make thread to sleep for a while. But now as I am doing some ORM with hibernate i am submitting a form at a servlet, in order which invokes my action class.. Here below it is...
now as i said it collapses with error
DynamicFenceDataAction.SaveOrUpdate(75) | Transection not Commited, session not closed DynamicFenceDataAction.SaveOrUpdate(75) | Transection not Commited, session not closed DynamicFenceDataAction.SaveOrUpdate(77) | Transection Commited, session not closed DynamicFenceDataAction.SaveOrUpdate(77) | Transection Commited, session not closed org.hibernate.SessionException: Session was already closed
So here also it is invoked twice, and that may be is the reason for no existence of session. Please help, and do tell me if more trace is required.
I would suggest not using a Servlet for listening to the port directly. It is not what Servlets are designed for. since the Server controls the Servlet life cycle and there is no guarantee about when they get created and destroyed, and how many may be created and maintained, they don't do anything more than serving and controlling web content very well.
Instead, try using a a ServletContextListener, which has a servletInitialized method that gets called when the web application is started and would be used to start listening to the port, and a contectDestroyed method called when the application ends, which can be used to close the port. You are guaranteed to have just one instance created, and it will live the length of the application. I much better choice for what you want to do.
Steve [ December 07, 2008: Message edited by: Steve Luke ]
In cases of "servlet invoked twice" I always suspect the deployment descriptor. What is your web.xml entry for this servlet?
Bill It is
I think it is alright, may be URL is of no use.
And steve I had tried with the ServletContextListener also, but if here also I do not make thread sleep for a while it throws error otherwise at least it is not telling me that it had initialized twice (something better). so suggest me your opinion. Thanks again.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com