When deploying a custom CacheListener (such as a ServerDestroyListener) to a GemFire cluster using "gfsh deploy", the listener may fail to trigger, and the server logs may not show any activity from the listener. This often occurs when the listener class is missing from the deployed JAR file, even if the build appears successful.
The issue is typically caused by a Maven project structure that does not follow the standard "src/main/java" layout. If the listener source code resides in a sub-folder (e.g. server-listener/src/main/java), the default Maven compiler plugin will not include the classes in the final JAR unless the sourceDirectory is explicitly defined in the pom.xml file.
Follow these steps to ensure the listener class is correctly bundled and deployed.
Run the following command to check if the listener class exists in the JAR:
jar -tf your-listener-file.jar | grep ListenerNameIf no output returns, the class was not bundled.
If using a non-standard directory structure, add the "sourceDirectory" and "resources" tags to the <build> section of the pom.xml:
<build>
<sourceDirectory>server-listener/src/main/java</sourceDirectory>
<resources>
<resource>
<directory>server-listener/src/main/resources</directory>
</resource>
</resources>
</build>Ensure the JAR is compiled with a Java version supported by the GemFire server (see Java Support doc for your Gemfire version).
gfsh undeploy --jar=your-listener-file.jargfsh deploy --jar=target/your-listener-file.jargfsh alter region --name=/your_region --cache-listener=com.package.ListenerClass