users@jersey.java.net

[Jersey] ApplicationEventListener's in Jersey

From: Nikita Sheremet <Nikita.Sheremet_at_noveogroup.com>
Date: Mon, 9 Sep 2013 18:14:12 +0700

Hello I am trying to write ApplicationEventListener for jersey application. But it does not work. I see in log file that class implements ApplicationEventListener actual loaded, but code inside it does not run. (I added System.out.prinln() to onEvent method and nothing writes to the log)

I use glassfish 3.1.2.2 with jersey implementation is 1.11. Is the problem that ApplicationEventListener is Jersey 2.2 feature? Is it possible to use ApplicationEventListener in glassfish 3.1.2.2 and how?

Also could you provide an explanation with maven dependencies with Jersey? If I use only:
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
I could not package my application with maven, because there is no ApplicationEventListener interface in it. I can add
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.2</version>
        </dependency>
After that I can compile my application but it does not work.

I will be much obliged to you if you provide one simple completed example with ApplicationEventListener, maven dependencies and container (glassfish 3.1.2.2, not simple jdk with main function), that can be compiled and deployed.


Regards,
Nikita Sheremet