[nbj2ee] Re: Error when adding context listener to web.xml

  • From: Glenn Holmer < >
  • To: < >
  • Subject: [nbj2ee] Re: Error when adding context listener to web.xml
  • Date: Mon, 27 Feb 2012 15:49:47 -0600
  • Organization: Weyco Group, Inc.

On Mon, 2012-02-27 at 17:56 +0000, Slobdell wrote:
> Hi, I'm a little lost here any help would be appreciated I can't find
> anything specific to my problem on the internet.  I'm using Netbeans
> 7.1 and Glass Fish Server 3+.
> 
> I have added a context listener to my webapp, and when I deploy I get
> an error after adding it to my web.xml file.  This is for class
> obviously so I'm new to Servlet contexts and descriptor files and all
> that.  
> 
> I think it has something to do with my context root from my Netbeans
> error message but I'm no expert. Any help would be greatly appreciated
> I've spent so many hours looking for a solution.
> 
> This is my listener, haven't changed it:

As for the errors, you put them there yourself (by leaving NetBeans'
default method handler code in there). In other words, your code is
behaving as expected. For production, you'd put something in the
contextInitialized() and contextDestroyed() methods that actually does
something (write to a log file, configure log4j in the first place,
whatever).

But you don't need the stuff in web.xml if you're using Java EE 6. Try
this annotation:

@WebListener
public class MyContextListener implements ServletContextListener {

Then you don't have to use the <listener> in web.xml at all.

-- 
____________________________________________________________
Glenn Holmer                          

Software Engineer                        phone: 414-908-1809
Weyco Group, Inc.                          fax: 414-908-1601



[nbj2ee] Error when adding context listener to web.xml

Slobdell 02/27/2012

[nbj2ee] Re: Error when adding context listener to web.xml

Glenn Holmer 02/27/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close