File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Error with @WebListener Annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Error with @WebListener Annotation" Watch "Error with @WebListener Annotation" New topic
Author

Error with @WebListener Annotation

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9500
    
    2

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?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9500
    
    2

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

Joined: Mar 17, 2012
Posts: 892
    
    9
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

Joined: Sep 26, 2006
Posts: 9500
    
    2

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

Joined: Mar 17, 2012
Posts: 892
    
    9
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error with @WebListener Annotation