ClientModuleHook not working?

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:

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!

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.

Kevin, your 2) helped :slight_smile:

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.

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.