# Setting 'lucee-server-directory' init param not working in embedded Tomcat

**URL:** <https://dev.lucee.org/t/setting-lucee-server-directory-init-param-not-working-in-embedded-tomcat/7807>\
**Category:** support\
**Created:** [January 11, 2021, 7:23am UTC](https://dev.lucee.org/t/setting-lucee-server-directory-init-param-not-working-in-embedded-tomcat/7807 "2021-01-11T07:23:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![valley](https://dev.lucee.org/user_avatar/dev.lucee.org/valley/32/639_2.png) [@valley](https://dev.lucee.org/u/valley)\
**Post date:** [January 11, 2021, 7:23am UTC](https://dev.lucee.org/t/setting-lucee-server-directory-init-param-not-working-in-embedded-tomcat/7807/1 "2021-01-11T07:23:47Z")

</div>

Hi all,

I’m been playing around with running Lucee within embedded Tomcat with the intention to make a standalone and portable application, but I’m unable to get the lucee-server to point to the right directory.

Here’s a snippet of my Tomcat initialisation…

```auto
final String serverRootPath = new File(configProperties.getPropertyValue(Arguments.SERVER_ROOT_PATH)).getAbsolutePath();
ctx.getServletContext().getServletRegistrations().get(cfmlServletName).setInitParameter("lucee-web-directory", serverRootPath + "/WEB-INF");
ctx.getServletContext().getServletRegistrations().get(cfmlServletName).setInitParameter("lucee-server-directory", serverRootPath + "/lucee-server");

```

With the above, a ‘lucee-server’ directory is created so there’s clearly something in the CFML engine doing its thing, but then it doesn’t actually appear to use the directory for anything, and remains empty once started up.

Weirdly, redirecting the ‘lucee-web-directory’ works just fine and results in my WEB-INF folder appearing there.

I was able to locate the lucee-server directory by checking the pageContext, and it appears to be running from my Gradle caching directory, which makes sense as I have the Lucee jar as a dependency in my build.gradle, retrieved from maven central.  
`C:\Users\mahdo\.gradle\caches\modules-2\files-2.1\org.lucee\lucee\lucee-server\context`

To code is available here if you need more context.  
[https://github.com/valley-fordham/lucee-server/blob/master/src/main/java/com/glenfordham/webserver/TomcatServer.java](https://github.com/valley-fordham/lucee-server/blob/master/src/main/java/com/glenfordham/webserver/TomcatServer.java)

Everything otherwise works correctly!

edit: I also tried this…  
`System.setProperty("lucee.server.dir", serverRootPath + "/lucee-server");`  
…which had the exact same result as the above. ‘lucee-server’ folder was created but wasn’t used.

Anyone have any idea how I can get it redirecting correctly? I went back to a Lucee version from several years ago and the same thing happened, so I wonder if embedded Tomcat isn’t completely supported, or if I’m just doing something dumb.

_Don’t forget to tell us about your stack!_

**OS** : Windows 10 64bit  
**Java Version** : Java 14.01  
**Tomcat Version** : 9.0.41  
**Lucee Version** : 5.3.7.47

Thanks all.  
Glen

---

<div class="post-metadata">

**Author:** ![valley](https://dev.lucee.org/user_avatar/dev.lucee.org/valley/32/639_2.png) [@valley](https://dev.lucee.org/u/valley)\
**Post date:** [January 22, 2021, 9:43am UTC](https://dev.lucee.org/t/setting-lucee-server-directory-init-param-not-working-in-embedded-tomcat/7807/2 "2021-01-22T09:43:27Z")

</div>

For posterity, I did manage to solve this!

It turned out a call to Log4j2 (before I even initialised embedded Tomcat) was invoking ScriptEngineManager, which in turn (using reflection) would initialise all script engines on the classpath (I think!). Lucee happens to be one, so the lucee-server would be unpacked before my Tomcat setInitParameter(“lucee-server-directory”) could be used.

Weirdly, this also creates an unusuable Lucee web-context, presumably for the script engine.

If anyone else uses Log4j2, Tomcat and Lucee, feel free to chime in so I can pick your brain 🙂

Cheers!
