# NPE in ModuleHook#shutdown with custom OPC-UA driver

**URL:** <https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446>\
**Category:** Module Development\
**Created:** [May 14, 2014, 8:14pm UTC](https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446 "2014-05-14T20:14:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [May 14, 2014, 8:14pm UTC](https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446/1 "2014-05-14T20:14:45Z")

</div>

Hey,  
i just refactored my driver for the API change in 7.6.4 and am now (with 7.6.6) getting a NPE during shutdown. Does someone know, what node the device manager tries to unregister here? As far as i can tell, there should be no nodes left at this point, because i remove them during the shutdown of the driver instances.  
I am quite sure this did not happen in 7.6.3 or before and i did not make any changes in this part of the code.

Thanks for your help,  
Carsten

```auto
INFO | jvm 1 | 2014/05/14 21:55:17 | ERROR [ModuleHook] [21:55:16,938]: Error unregistering DriverType.
INFO | jvm 1 | 2014/05/14 21:55:17 | java.lang.NullPointerException
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.server.addressspace.base.StandardNodeManager._removeNode(StandardNodeManager.java:129)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.server.addressspace.base.StandardNodeManager.removeNode(StandardNodeManager.java:125)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.server.addressspace.base.XOPCAddressSpace.updateDeviceFolder(XOPCAddressSpace.java:103)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.server.devices.DeviceManager.unloadDriver(DeviceManager.java:220)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.server.devices.DeviceManager.loadDriver(DeviceManager.java:179)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.server.devices.DeviceManager.unregisterDriverType(DeviceManager.java:155)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.xopc.driver.common.AbstractDriverModuleHook.shutdown(AbstractDriverModuleHook.java:78)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.chitek.ignition.drivers.generictcp.ModuleHook.shutdown(ModuleHook.java:88)
INFO | jvm 1 | 2014/05/14 21:55:17 | at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.shutdown(ModuleManagerImpl.java:2277)
```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 14, 2014, 8:34pm UTC](https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446/2 "2014-05-14T20:34:12Z")

</div>

Hmm, it’s trying to remove the folder for that device from under the Devices folder (the “[your-device-name]” folder) and for some reason it’s not finding it…

Is there a chance your driver is removing that folder as well? I can’t get this error to happen on my side.

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [May 15, 2014, 5:32pm UTC](https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446/3 "2014-05-15T17:32:06Z")

</div>

Thanks for this information. It was a configuration issue on my side, the root cause was a folder node with an empty name that was added to the NodeManager. I assume that this folder replaced the device folder.  
Maybe the API should check this in NodeManager#buildAndAddNode.

But after fixing this, i found another little bug: The Exception is gone, but the device nodes are not removed. Even after the module is uninstalled, the device node is still visible to OPC clients. Also the driver classes are not unloaded. This happens also with the built in drivers (checked with the S7 driver).

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 15, 2014, 5:51pm UTC](https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446/4 "2014-05-15T17:51:59Z")

</div>

Just the [device-name] folder doesn’t get removed from underneath the Devices folder? This only happens with your driver and not the other ones?

I’ll look into the loading/unloading issue.

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [May 15, 2014, 6:06pm UTC](https://forum.inductiveautomation.com/t/npe-in-modulehook-shutdown-with-custom-opc-ua-driver/8446/5 "2014-05-15T18:06:41Z")

</div>

> Just the [device-name] folder doesn't get removed from underneath the Devices folder? This only happens with your driver and not the other ones?

This happens also with the S7 driver. To reproduce, simply uninstall the module while a device is active.
