• Post Reply Bookmark Topic Watch Topic
  • New Topic

Binding and attr listener - app won't start  RSS feed

 
Daniel Stankiewicz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the difference between HttpSessionBindingListener and HttpSessionAttributeListener. But I tried to implement them both in an attribute class, added listener to DD and.... application didn't start at all! I know that it was wrong, but could you tell me why exactly app didn't start?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but could you tell me why exactly app didn't start?

Please post your container's log.
 
Daniel Stankiewicz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christophe Verre:

Please post your container's log.


Here you are:

2007-10-04 09:16:11 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.example.web.Dog
java.lang.InstantiationException: com.example.web.Dog
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3713)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2007-10-04 09:16:11 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

what's in the constructor of com.example.web.Dog?

Herman
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.InstantiationException: com.example.web.Dog


Can you post the code to your com.example.web.Dog class?
Be sure to use UBB Code tags when you do.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also make sure there's a public default constructor. But as others said, please post your Dog class as well.
 
Akshay Kiran
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What could also be wrong is
Dog is a HttpSessionBindingListener and BindingListeners need not be registered in the web.xml.
The container will automatically figure out that it has to send BindingEvents to objects of this class when they are bound or unbound to the session object.
but this should not necessarily cause an instantiation exception.
so you probably don;t have a no argument public ctor.
regards,
Akshay
[ October 06, 2007: Message edited by: Akshay Kiran ]
 
Daniel Stankiewicz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was that Dog class didn't have a default public constructor, but just a parametrized constructor. So the container couldn't instantiate this class as a HttpSessionAttributeListener. Thank you all for helping
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!