0
votes

I want to listen to contextInitialized() and contextDestroyed() events. I created jetty.xml file where I want to specify the class that will be responsible for listening. The error message I get: Unknown tag: listener.

The content of the file:

<Configure class="org.eclipse.jetty.server.Server">
  <listener>
    <listener-class>test.Application</listener-class>
  </listener>
</Configure>
1

1 Answers

0
votes

<Configuration> is for configuring a specific object in Jetty.

That syntax has a DTD that explains what you are allowed to use as far as what XML elements.

<listener> is not available in that DTD.

That's the reason for the error Unknown tag: listener

Now, lets dig a bit deeper...

Why do you want a Listener that listens for contextInitialized() and contextDestroyed()?

I assume you want a javax.servlet.ServletContextInitializer based on those method names.

That's only available in a specific webapp, not for all webapps.

The most common way to configure that is in the webapp's own WEB-INF/web.xml

That's where your <listener> block needs to be.