Trouble with Module

I’m trying to upgrade a module from 7.6.4 to run on the 7.8 framework using Maven. I’m brand new to module development so I’m probably missing something basic. This is the error I get when I try to load the module:

INFO | jvm 1 | 2016/02/23 08:23:55 | ERROR [ModuleManager ] [08:23:55,305]: Error loading hook classes for module "com.completear.zprint". INFO | jvm 1 | 2016/02/23 08:23:55 | com.inductiveautomation.ignition.common.modules.ModuleLoadException: Unable to load hook class "com.completear.zprint.gateway.GatewayHook" for module "com.completear.zprint". INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.loadHook(ModuleManagerImpl.java:2233) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.load(ModuleManagerImpl.java:2019) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.startupModule(ModuleManagerImpl.java:1492) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$4.call(ModuleManagerImpl.java:982) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.executeModuleOperation(ModuleManagerImpl.java:1124) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.installModuleInternal(ModuleManagerImpl.java:962) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.access$1500(ModuleManagerImpl.java:124) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$InstallCommand.execute(ModuleManagerImpl.java:1889) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$Receiver.receiveCall(ModuleManagerImpl.java:1826) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.redundancy.QueueableMessageReceiver.receiveCall(QueueableMessageReceiver.java:45) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl.dispatchMessage(RedundancyManagerImpl.java:738) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl$ExecuteTask.run(RedundancyManagerImpl.java:759) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:537) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.util.concurrent.FutureTask.run(FutureTask.java:266) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.lang.Thread.run(Thread.java:745) INFO | jvm 1 | 2016/02/23 08:23:55 | Caused by: java.lang.ClassNotFoundException: com.completear.zprint.gateway.GatewayHook INFO | jvm 1 | 2016/02/23 08:23:55 | at java.net.URLClassLoader.findClass(URLClassLoader.java:381) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.lang.ClassLoader.loadClass(ClassLoader.java:424) INFO | jvm 1 | 2016/02/23 08:23:55 | at java.lang.ClassLoader.loadClass(ClassLoader.java:357) INFO | jvm 1 | 2016/02/23 08:23:55 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.loadHook(ModuleManagerImpl.java:2211) INFO | jvm 1 | 2016/02/23 08:23:55 | ... 19 more

I have looked in the module.xml file and it does seem to have all the required .jars listed. Any help is appreciated, thanks.

I think we’d need to see your build project’s pom.xml to help you figure out what’s going on. With the new maven plugin, a separate module.xml is no longer used; everything is configured in the plugin configuration section of the build pom.

Oops, I meant the compiled .modl file.

Here’s the pom file from the root directory:

[code]<?xml version="1.0" encoding="UTF-8"?>

4.0.0

<groupId>com.completear.zprint</groupId>
<artifactId>LabelPrinter</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
	<module>Designer</module>
	<module>Client</module>
	<module>Common</module>
	<module>Gateway</module>
	<module>Build</module>
</modules>

<pluginRepositories>
    <pluginRepository>
        <id>releases</id>
        <url>http://nexus.inductiveautomation.com:8081/nexus/content/repositories/inductiveautomation-releases</url>
    </pluginRepository>
</pluginRepositories>

<repositories>
    <repository>
        <id>releases</id>
        <url>http://nexus.inductiveautomation.com:8081/nexus/content/repositories/inductiveautomation-releases</url>
    </repository>

    <repository>
        <id>snapshots</id>
        <url>http://nexus.inductiveautomation.com:8081/nexus/content/repositories/inductiveautomation-snapshots</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>

    <repository>
        <id>thirdparty</id>
        <url>http://nexus.inductiveautomation.com:8081/nexus/content/repositories/inductiveautomation-thirdparty
        </url>
    </repository>
</repositories>
[/code]

Need the pom file from Build

Here it is:

[code]<?xml version="1.0" encoding="UTF-8"?>

4.0.0

com.completear.zprint
LabelPrinter
1.0.0

Build

    <build>
    <plugins>
        <plugin>
            <groupId>com.inductiveautomation.ignitionsdk</groupId>
            <artifactId>ignition-maven-plugin</artifactId>
            <version>1.0.8</version>

            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>modl</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <projectScopes>
                    <projectScope>
                        <name>Designer</name>
                        <scope>D</scope>
                    </projectScope>
					<projectScope>
                        <!-- common resources should be shared among all scopes -->
                        <name>Common</name>
                        <scope>GCD</scope>
                    </projectScope>
					<projectScope>
						<name>Gateway</name>
						<scope>G</scope>
					</projectScope>
                    <projectScope>
                        <name>Client</name>
                        <scope>CD</scope>
                    </projectScope>
                </projectScopes>

                <moduleId>com.completear.zprint</moduleId>
                <moduleName>Print</moduleName>
                <moduleDescription>A module for printing.</moduleDescription>
                <moduleVersion>${project.version}</moduleVersion>
                <requiredIgnitionVersion>7.8.0</requiredIgnitionVersion>
                <requiredFrameworkVersion>7</requiredFrameworkVersion>
                <!--<licenseFile>license.html</licenseFile>-->
                <!--<documentationFile>doc/index.html</documentationFile>-->
				
				<hooks>
					<hook>
						<scope>C</scope>
						<hookClass>com.completear.zprint.client.ClientHook</hookClass>
					</hook>
                    <hook>
                        <scope>D</scope>
                        <hookClass>com.completear.zprint.designer.DesignerHook</hookClass>
                    </hook>
                    <hook>
                        <scope>G</scope>
                        <hookClass>com.completear.zprint.gateway.GatewayHook</hookClass>
                    </hook>
                </hooks>
            </configuration>
        </plugin>
    </plugins>
    
</build>
[/code]

This looks correct at first glance. Can you attach your modl file so we can see what’s in it?

Another thing that might be a problem is that you’re using a release version instead of a SNAPSHOT version in your poms - with Maven there is only ONE release version, so while you’re developing you should be using a version like 1.0.0-SNAPSHOT, otherwise you’re going to keep assembling the modl file using whatever you installed/deployed the first time you ran it because it was a release version.

Here’s the module file after changing to the version to snapshot.

Your jar files don’t seem to have any code in them.

Are you sure they’re getting built correctly? Do you have your source code under a src/main/java folder?

The directory structure looks like: src/com/completear/zprint/(common or gateway or desginer, etc). Then there’s a .java file in each folder.

This is in Eclipse.

The best thing to do would be to use Maven’s standard source directory: src/main/java (see maven.apache.org/guides/introdu … ayout.html)

If you can’t do this, you can reconfigure Maven to look at an alternate source location. maven.apache.org/pom.html#Build_Element

Almost there I think. I got the module to compile and not fault out when it’s installed. The problem it has now is that when I try to call the custom function from common it throws this error:

[code]Java Traceback:

at org.python.core.Py.JavaError(Py.java:495)

at org.python.core.Py.JavaError(Py.java:488)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)

at org.python.core.PyObject.__call__(PyObject.java:404)

at org.python.core.PyObject.__call__(PyObject.java:408)

at org.python.pycode._pyx3.f$0(<buffer>:2)

at org.python.pycode._pyx3.call_function(<buffer>)

at org.python.core.PyTableCode.call(PyTableCode.java:165)

at org.python.core.PyCode.call(PyCode.java:18)

at org.python.core.Py.runCode(Py.java:1275)

at org.python.core.Py.exec(Py.java:1319)

at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)

at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)

at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)

at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:417)

at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:405)

at javax.swing.SwingWorker$1.call(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at javax.swing.SwingWorker.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NoClassDefFoundError: qz/PrintServiceMatcher

at com.completear.zprint.common.ZPrint.print(ZPrint.java:20)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)

... 20 more

Caused by: java.lang.ClassNotFoundException: qz.PrintServiceMatcher

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 26 more

Traceback (most recent call last):
File “”, line 2, in
at com.completear.zprint.common.ZPrint.print(ZPrint.java:20)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: qz/PrintServiceMatcher
[/code]

Here is the pom file for common:

[code]<?xml version="1.0" encoding="UTF-8"?>

4.0.0

<parent>
    <artifactId>LabelPrinter</artifactId>
    <groupId>com.completear.zprint</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>Common</artifactId>
<dependencies>
  <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
    <scope>compile</scope>
  </dependency>
  <dependency>
  	<groupId>com.qz-print</groupId>
  	<artifactId>qz-print</artifactId>
  	<version>1.0</version>
  </dependency>
</dependencies>

<build>

    <plugins>
        <!-- ask maven to compile this module against java 8 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

[/code]

I’ve tried specifying different scopes (runtime and compile) for qz-print but it hasn’t made a difference. Any ideas?

If you open the module and jar(s) with a zip manager does it look like the qz-print classes are getting included?

They appear to be. There’s a qz-print-1.0.jar and qz-print-1.0.jar.pack.gz in the .modl file. If I go into the .jar file there’s a qz folder with a number of class files inside (including PrintServiceMatcher.class).

The module.xml file has the .jar in the gateway scope and the .jar.pack.gz in the client and designer scope. I’m trying to test from the Script Console.