Lucee as a war (on jetty)

So, this is probably more of a question about how servlet containers work/are configured. As noted in a previous post, I’m trying to get Lucee working on Jetty. When I drop the war into the webapps directory, the app works fine in the /lucee-5.x/ context. However, I don’t know how to configure Jetty to look at another directory as the web root.

And, it’s possible I’m not understanding how I should be configuring the server. It could be I should be loading the war in the root context, but if so, I’m not sure how to configure the container to find my document root. I’d like to be able configure that without editing the war file (changing the WEB-INF/web.xml).

I see that Lucee Express is setup with a jar not a war - is that the tact I should take?

Any guidance here?

When you deploy a war file, the war file should contain the entire application. War files are just zip files, so you could certainly just add your cfml source code and repackage the war file and then deploy.

If you just use the lucee.jar file then you will need to modify the web.xml so the server knows to map .cfm to the CFMLServlet, here is an example: ubuntu-nginx-lucee/web.xml at master · foundeo/ubuntu-nginx-lucee · GitHub

1 Like

Ok, I think I’ve figured out how to configure it most of the way. Here are my notes:

Setup

After unzipping the download, create a link to it

mklink /j jetty jetty-distribution-9.4.14.v20181114

Next, create both the base and start directory; without the start.d, all configs will got to a start.ini

mkdir jetty\lucee-base\start.d
cd jetty\lucee-base

You can list available modules java -jar ../start.jar --list-modules (more information at
https://www.eclipse.org/jetty/documentation/current/startup-modules.html)

These are the modules we’ll be using

java -jar ../start.jar --add-to-start=deploy,jsp,ext,http,https,logging-logback

Theoretically, there is some dependencies added, but I’m not sure which.

Under the lucee-base/lib/ext directory, add the lucee.jar

Configuration

Each web app context can be bound to a separate virtual host. To do so, create an xml file with at least the following:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/</Set>
    <Set name="resourceBase">
        <SystemProperty name="jetty.base" default="." />/webapps/target-directory
    </Set>
    <Set name="extractWAR">true</Set>
    <Set name="copyWebDir">false</Set>
    <Set name="virtualHosts">
        <Array type="String">
            <Item>host-name</Item>
        </Array>
    </Set>
</Configure>

The target-directory will become the webroot. Create WEB-INF directory under it and place the web.xml with the lucee servlet config. The server context will write the necessary files upon restart.

You should now be able to access http://host-name:8080/ for your cfm files, and http://host-name:8080/lucee/admin/web.cfm for the instance’s cf settings.