Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error with @WebListener Annotation

 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the Servlet 3.1 specification, a class that is annotated with @WebListener must implement one of the Servlet interfaces:

http://docs.oracle.com/javaee/6/api/javax/servlet/annotation/WebListener.html

I have a Webapp that is built using the Play Framework. I want to now run this Webapp in a Servlet container. For this reason, I'm using the Play2-war-plugin.

https://github.com/dlecan/play2-war-plugin

When I tried to deploymy war file to Glassfish, I faced s strange error as mentioned below:



I later looked into the source code for the play2-war-plugin and the Play2Servlet has the @WebListener annotation and extends a GenericServlet abstract class and this abstract class implements the interfaces. My question now is since Play2Servlet extends the GenericServlet, Play2Servlet also implements the interfaces. So why do I get this error?

Is it that the actual class that has the @WebListener annotation should actually implement one of the interfaces from the Servlet api irrespective of class hierarchies?
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering why this post was moved out from the Servlets forum. The issue that I face is the error that I get when running a Servlet and I wanted to know if the WebListener annotation can be applied on a subclass while the superclass implements one of the servlet interfaces.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue is likely related to how the Play framework works and that plugin rather than servlets.
The plugin only mentions support for servlet 2.5 and servlet 3.0. It even uses a servlet named play.core.server.servlet30.Play2Servlet
Have you verified that the plugin works on servlet 3.1 at all?
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:The issue is likely related to how the Play framework works and that plugin rather than servlets.
The plugin only mentions support for servlet 2.5 and servlet 3.0. It even uses a servlet named play.core.server.servlet30.Play2Servlet
Have you verified that the plugin works on servlet 3.1 at all?


I've had a look into the Play2Servlet, but that is not my problem. I@m also aware that the plugin does not yet support Servlet 3.1. My question was with respect to the Servlet specification and the way the @WebListener annotation works. Is it ok to have the @WebListener annotation on a subclass wherein the superclass implements one of the servlet interfaces?
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Harry wrote: My question was with respect to the Servlet specification and the way the @WebListener annotation works. Is it ok to have the @WebListener annotation on a subclass wherein the superclass implements one of the servlet interfaces?

If this was the question then you shouldn't have clouded it with play plugins information. As for the answer, why not test it with a simple web application that has nothing to do with play and play plugins?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic