does nay one have experince with this sort of problem? is it a bad programming construct to create threds in a servlet? if so..where should we be creating our threads? we want this thread to run every 30 seconds and this is a web appliction.
Sometimes there's no cleaner way to do asynchronous processing in a web application environment. Don't let the EJB prohibition on threads deceive you into thinking that servlets are also forbidden to spawn threads. All they're really saying is that if you spawn threads in a web app, the web app should take total responsibility for the entire lifecycle of the threads and not expect the appserver itself to try and pick up after you.
You should be OK as long as you scrupulously follow IBM's recommendations as outlined in that bulletin.
An IDE is no substitute for an Intelligent Developer.
Joined: Jun 04, 2007
hm ok so should i just kind of cheat and not log this error message? OR try to see if DB connection can be taken out and done some place other than the thread? This message is just coming as a warning so i don't know how much impact this is causing to our system. However lot of our stress tests are failing when the 'background' manager is running every 30 secs. dont know if these two things are related..
actually when we make normal connections to the DB from the UI like when user clicks a link we use DSNames like this: java:comp/env/jdbc/pAdmin
However, when the thread created in servlet makes connection to the DB we HAVE to use this DSName: jdbc/pAdmin. If we use the one listed above we get errors. I dont know how related these two things are...but we have the following snippet in our web.xml
[ July 19, 2007: Message edited by: bhaarat sharma ]
i checked and DB connections are being made in run method for BackManager class. Whereelse do you suggest i should be making these connections? when i say they are being made in the run method i mean. the CALL to where the connection is estables is from the run method
Joined: Jun 04, 2007
ok i've implemented a servletcontext listener and took out the Timer created from my servlets init method and placed it in my POJO implmenting servletContextListener. However, still my DSName HAS to be jdbc/pAdmin instead of java:comp/env/jdbc/psrAdmin. DSName starting with java:comp..works everywhere else but just not for the back ground manager. if I use jdbc/pAdmin dsName then i constantly get a warning whenever the background manager tries to make DB connection.
good now i know how to deal with servletcontextlistener but what is the use for it?
even going back to my first post. After even creating threads in plain old java class that implements servletcontextListener i am still getting J2CA0075W: An active transaction should be present
[ July 19, 2007: Message edited by: bhaarat sharma ] [ July 19, 2007: Message edited by: bhaarat sharma ]