This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletContextListener and Starting a Thread  RSS feed

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!