I am generating wsdl using java2wsd
. My class is
public class REWS {...}
.
I just added implements HttpSessionListener
like so:
public class REWS implements HttpSessionListener {...}
and I started getting the NoClassDefFoundError
error for HttpSessionListener
.
I can build the REWS class, but once I want to generate stub with java2wsdl
I get NoClassDefFoundError
.
How to I tell java2wsdl
to take HttpSessionListener
from /Tomcat/lib/servlet-api.jar
? How do I include servlet-api.jar
?
That is a bad design, indeed.
First, let's recall what interfaces are for. Interfaces establish a strong design contract in your class, stronger than declaring the inherited methods "the plain old way". WSDL defines interfaces too, even if java2wsdl
works on classes.
You use interfaces because they are parameters of framework methods, allowing you to provide them your own implementation of a contract. With WSDL, it's slightly different. The WSDL is the contract and is self-powered. You don't need anything more in a WSDL except the XSD schemas that are explicitly imported.
So: why does one implement HttpSessionListener
? As stated by documentation, a properly registered session listener is activated by the framework when session changes. Is this part of the design contract of your publicly-accessible web service? Absolutely not!!
By implementing, you are implicitly exporting to the public two methods that are for internal use, so you are trying (but won't ever succeed) to declare two additional methods to your public service that handle session changes. That's not only wrong, but impossible because HttpSessionEvent
is simply not exportable to XSD!
Don't implement this interface on your WS class. Use your custom implementation as a class member and let it interact with your WS class according to what your web service does. I'm not an expert in Tomcat but web services don't use session and cookies, so I doubt you'll ever deal with the session in a web service.