# ClientModuleHook not working?

**URL:** <https://forum.inductiveautomation.com/t/clientmodulehook-not-working/3008>\
**Category:** Module Development\
**Created:** [June 13, 2011, 12:02pm UTC](https://forum.inductiveautomation.com/t/clientmodulehook-not-working/3008 "2011-06-13T12:02:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgz](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cgz](https://forum.inductiveautomation.com/u/cgz)\
**Post date:** [June 13, 2011, 12:02pm UTC](https://forum.inductiveautomation.com/t/clientmodulehook-not-working/3008/1 "2011-06-13T12:02:37Z")

</div>

The problem: Why doesn’t my ClientModuleHook get called?

To my knowledge, everything should be set up correctly, but it just doesn’t work.  
On the other hand DesignerHook works as expected. It’s only when I try  
to run the project depending on the module as a client, it won’t mostly work, because everything  
depends on running the hook.

Anyone got a clue? This is pretty much a show-stopper issue by preventing testing  
and even actual use.

The facts: Here’s how I’ve set up things:

```auto
public class ClientHook extends AbstractClientModuleHook
{
    public void startup(ClientContext ctx, LicenseState arg1) throws Exception
    {
        super.startup(ctx, arg1);

        // - grab ClientContext for later use
        // - expose Java/Jython bindings to dependent projects
        ...
    }
  ...
}

<?xml version="1.0" encoding="UTF-8"?>
<modules>
	<module>
		<id>module_id</id>
		<name>@NAME@</name>
		<description>@DESCRIPTION@</description>
		<version>@VERSION@</version>
		<requiredignitionversion>7.2.2</requiredignitionversion>
		<requiredframeworkversion>2</requiredframeworkversion>
		<freemodule>true</freemodule>

		<depends scope="G">xopc</depends>
		<depends scope="D">fpmi</depends>
  
		<jar scope="CD">mymodule.jar.pack.gz</jar>
		<jar scope="G">mymodule.jar</jar>

                <hook scope="C">my.module.class.path.ClientHook</hook>
		<hook scope="G">my.module.class.path.GatewayHook</hook>
		<hook scope="D">my.module.class.path.DesignerHook</hook>
	</module>
</modules>
```

Version information:  
Gateway is run in Developer Mode  
Ignition Version 7.2.5 (b76)  
Java Version Sun Microsystems Inc. 1.6.0\_24

Thanks!

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [June 13, 2011, 5:43pm UTC](https://forum.inductiveautomation.com/t/clientmodulehook-not-working/3008/2 "2011-06-13T17:43:30Z")

</div>

I’m not certain this will be the answer, but I have a couple ideas.

1. You might need to depend on “fpmi” for the C client scope too. “fpmi” is the vision module.

2. If I have a hard time tracing something down, I’ll normally set up java to show the console. Doing this, when the designer starts, I can easily see when my module is loaded, and see any problems it has. Showing the console would likely tell you the same thing when the client was starting up.

---

<div class="post-metadata">

**Author:** ![cgz](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cgz](https://forum.inductiveautomation.com/u/cgz)\
**Post date:** [June 14, 2011, 3:39pm UTC](https://forum.inductiveautomation.com/t/clientmodulehook-not-working/3008/3 "2011-06-14T15:39:07Z")

</div>

Kevin, your 2) helped 🙂

I was relying on a mis-observation that the hook wasn’t being called, but it actually was. By enabling the console I was able to notice the exception my hook was causing.

I was using

`Thread.currentThread().getContextClassLoader().getResourceAsStream()` which couldn’t find the resources embedded in my module. My colleague found out that `ctx.getClass().getResourceAsStream()` worked as expected, even though it’s not entirely obvious why.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 21, 2011, 10:04pm UTC](https://forum.inductiveautomation.com/t/clientmodulehook-not-working/3008/4 "2011-07-21T22:04:45Z")

</div>

The thread’s context classloader is probably the bootstrap loader, whereas your class has been loaded in a separate URLClassloader that you must go through to look for resources packaged in your jar file.
