It's not a secret anymore!
The moose likes Servlets and the fly likes ServletContextListener and Starting a Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContextListener and Starting a Thread" Watch "ServletContextListener and Starting a Thread" New topic

ServletContextListener and Starting a Thread

Brian Hart

Joined: Jun 23, 2002
Posts: 5
I'm looking to 'poll' a database table for new records. I want to have a low priority thread check a database table while the server is running. the run() method of the Runnable would look something like this:

I thought that calling this process from within the contextInitialized(ServletContextEvent event) of a ServletContextListener would be an appropriate place to begin this process. However, on Oracle's OC4J J2EE server, I'm getting the message:
Exception thrown initializing batch completed listener: java.lang.Exception: Not in an application scope - start Orion with the -userThreads switch if using user-created threads
The fact that the server by default discourages user created threads makes me think my approach is a bad one.
Two questions:
1. What is a relatively straightforward approach to implement a simple polling thread on a JSP/Servlet based web application (no EJB, JMS).
2. What are the implications of enabling userThreads on Orion.
Thanks in advance.
I agree. Here's the link:
subject: ServletContextListener and Starting a Thread
It's not a secret anymore!