This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Listener started twice  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a ServletContextListener yesterday to initialize a connection to a business object and make it available to the servlets. The listener is successfully started, however, the contextInitialized method is called twice (and the business object is then created twice). I'm running on TomCat 5.5. My web.xml is at the bottom of this post. Additionally, Eclipse is showing an error on the web.xml -


The error goes away if I take out the listener sections.

Any help on this would be appreciated.

Thanks,

Jeff
[B][/B]
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

the error you got is because of the order of the web.xml sections, the error message specifies the order in which the parser is expecting the sections.

You are writing the <listener> tags after the <resource-ref> tags while it sould be between <filter-mapping> and <servlet> tags.
 
Jeff Schanhals
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the information on the order of the sections. That corrected the error.

However, I am still getting the listener initialized twice. The listeners code is as follows:

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!