Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Error while running HttpSessionAttributeListener

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a listener class like this,

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

class SessionAttributeListener implements HttpSessionAttributeListener
{
public void attributeAdded(HttpSessionBindingEvent ev)
{
System.out.println("Inside Addition "+ev.getName()+"|"+ev.getValue());
}

public void attributeReplaced(HttpSessionBindingEvent ev)
{
System.out.println("Inside Replace "+ev.getName()+"|"+ev.getValue());
}

public void attributeRemoved(HttpSessionBindingEvent ev)
{
System.out.println("Inside Removed "+ev.getName()+"|"+ev.getValue());
}
}

when i start the server i'm getting the error
SEVERE: Error listenerStart
and
my web.xml entry goes something like this
<listener-class>SessionAttributeListener </listener-class>

what is the cause of this error.

please clarify me


with regards
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll get that error in Tomcat. Make your class public.

default accessibility will not work.

good luck
 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kurian ,
But will that work in other servers.why is that these classes(including servlet) have to public.Is this specified in sun specifications.


thanks,
Senthil.S.S
 
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Senthil Kumar SS:

my web.xml entry goes something like this
<listener-class>SessionAttributeListener </listener-class>

what is the cause of this error.

please clarify me


with regards






Your <listener-class> should enclosed in <listener>

<listener>

<listener-class>exact path here</listener-class>

</listener>
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is this specified in sun specifications.


SRV.10.3.1 Provision of Listener Classes
The Developer of theWeb application provides listener classes implementing one or more of the listener classes in the javax.servlet API. Each listener class must have a public constructor taking no arguments. The listener classes are packaged into the WAR, either under the WEB-INF/classes archive entry, or inside a JAR in the WEBINF/lib directory.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic