# Springboot Inside of Ignition Gateway Module

**URL:** <https://forum.inductiveautomation.com/t/springboot-inside-of-ignition-gateway-module/85709>\
**Category:** Module Development\
**Created:** [February 14, 2024, 6:53pm UTC](https://forum.inductiveautomation.com/t/springboot-inside-of-ignition-gateway-module/85709 "2024-02-14T18:53:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Gendron](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@Nick\_Gendron](https://forum.inductiveautomation.com/u/Nick_Gendron)\
**Post date:** [February 14, 2024, 6:53pm UTC](https://forum.inductiveautomation.com/t/springboot-inside-of-ignition-gateway-module/85709/1 "2024-02-14T18:53:49Z")

</div>

I'd like to integrate Spring into my current Ignition gateway module to provide a management API for our application and to make the core functionality a bit more portable for different use cases. Is this something that is possible with the architecture of Ignition or has anyone done something similar? After digging through the docs and forums I have not found anything related to this so any help is appreciated.

---

<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:** [February 14, 2024, 6:58pm UTC](https://forum.inductiveautomation.com/t/springboot-inside-of-ignition-gateway-module/85709/2 "2024-02-14T18:58:05Z")

</div>

It may be possible if you expected zero integration with Ignition and its own embedded web server instance, and your module just tried to boot up its own embedded Springboot/Tomcat setup, running a 2nd HTTP server in parallel... but yuck.

And that's assuming there's no ClassLoader issues or anything like that.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 14, 2024, 7:21pm UTC](https://forum.inductiveautomation.com/t/springboot-inside-of-ignition-gateway-module/85709/3 "2024-02-14T19:21:25Z")

</div>

I'm not familiar with Spring, but a module can mount its own servlets into Ignition's URL namespace.

Use [yourModuleContext.getWebResourceManager()](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.30/com/inductiveautomation/ignition/gateway/model/GatewayContext.html#getWebResourceManager()), then [.addServlet(...)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.30/com/inductiveautomation/ignition/gateway/web/WebResourceManager.html#addServlet(java.lang.String,java.lang.Class))

---

<div class="post-metadata">

**Author:** ![cody.tamaki](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@cody.tamaki](https://forum.inductiveautomation.com/u/cody.tamaki)\
**Post date:** [February 16, 2024, 4:06pm UTC](https://forum.inductiveautomation.com/t/springboot-inside-of-ignition-gateway-module/85709/4 "2024-02-16T16:06:16Z")

</div>

I've done this actually, and it wasn't easy to figure out, but only takes a little bit of code.

There are some weird class loader issues that I had to work around with the following:

```auto

    @Synchronized
    private void initializeSpringContext() {
        // force spring to use the current classes classLoader to load spring dependencies
        var threadClassLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

        springContext = new AnnotationConfigApplicationContext(SpringContextConfig.class);
        this.beanFactory = springContext.getAutowireCapableBeanFactory();

        Thread.currentThread().setContextClassLoader(threadClassLoader); // reset the class loader to prevent any unintended side effects
    }

```

I didn't do any xml/file based configuration and instead opted to do a configuration class. I did manage to get JPA, JTA, DI and web services working. Going forward, Java changing the servlet namespace under (javax is now jakarta) has basically broken the APIs I was using to integrate spring boot webservices with Ignition.
