We are testing switching our current lucee infrast...
# docker-commandbox
s
We are testing switching our current lucee infrastructure from IIS/tomcat to commandbox/undertow, and loving it so far. However, we have hit a bump. We use html as cfml on some files, and as yet cant find a way to do this with undertow. With IIS we are adding servlet mappings within our web.xml files. We have tried adding them in .Commandbox/server/[instance-id]/[lucee-version]/WEB-INF/web.xml, similar to how we have them currently in IIS, but these do not work:
Copy code
<servlet-mapping>
    <servlet-name>CFMLServlet</servlet-name>
    <url-pattern>*.cfc</url-pattern>
    <url-pattern>*.cfm</url-pattern>
    <url-pattern>*.cfml</url-pattern>
    <url-pattern>*.html</url-pattern>
    <url-pattern>/index.cfc/*</url-pattern>
    <url-pattern>/index.cfm/*</url-pattern>
    <url-pattern>/index.cfml/*</url-pattern>
    <url-pattern>/index.html/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>RESTServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
  <!-- default file to execute if directory is called with no file name, e.g. <http://mysite.com/> !-->
  <welcome-file-list>
    <welcome-file>index.cfm</welcome-file>
    <welcome-file>index.lucee</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
Is this possible with undertow? Thanks.
r
s
Great, thanks Rodney, I’ll read up and try now.
I’m still unable to get the override working correctly. Here’s what I’ve attempted so far: I’ve added the override configuration to `/home/cbuser/.CommandBox/web-override.xml`:
Copy code
<web-app>
    <servlet-mapping>
    <servlet-name>CFMLServlet</servlet-name>
    <url-pattern>*.cfc</url-pattern>
    <url-pattern>*.cfm</url-pattern>
    <url-pattern>*.cfml</url-pattern>
    <url-pattern>*.html</url-pattern>
    <url-pattern>/index.cfc/*</url-pattern>
    <url-pattern>/index.cfm/*</url-pattern>
    <url-pattern>/index.cfml/*</url-pattern>
  </servlet-mapping>
</web-app>
I’ve added the file path to `server.json`:
Copy code
{
  "JVM": {
    "heapSize": "4G"
  },
  "app": {
    "webXMLOverride": "/home/cbuser/.CommandBox/web-override.xml",
    "webXMLOverrideForce": "true"
  },
  "openBrowser": "false",
  "profile": "development",
  "web": {
    "blockCFAdmin": "false",
    "host": "0.0.0.0"
  }
}
Note: I first tried without the
"webXMLOverrideForce":"true"
, then I added it after the first attempt in case there were any old residual configurations. These are my observations: • A test file,
cbox.html,
returns a
powered by commandbox 404 page
• Renaming that test file to
cbox.cfm
works • Browsing to a .cfm url file that doesn’t exist
cbow2.cfm
returns ‘`file not found`’ (I guess this is the undertow response) • using
server status --JSON
I can see the web override settings Any suggestions would be appreciated.
r
What version of CommandBox are you using?
s
it’s
v6.0.0+00787
r
Hmm, should work then. There was a bug with xml overrides pre 6.0.
Do you get any additional information running
server start --debug
?
s
this is the result of
server start --debug
, the Configuring Servlet section is showing pasing of the `web-override.xml`:
Copy code
Trying to start server...
> server start name='site1' openBrowser=false debug=true --!saveSettings
 √ | Starting Server
   |------------------------------
   | Site name - site1
   | Webroot - /home/cbuser/cbsandbox/site1/
   | Site config file - /home/cbuser/cbsandbox/site1//server.json
   | WAR/zip archive already installed.
   | Server start command: 
   |     /bin/bash /home/cbuser/.CommandBox/cfml/system/modules_app/server-commands/bin/server_spawner.sh /home/cbuser/.CommandBox/server/D6436B8096FF1E2B8ED64B21BC044AB6-si
   | te1/lucee-5.4.4.38/nohup.log /usr/lib/jvm/java-17-openjdk-amd64/bin/java
   |     -Xmx4G 
   |     -cp /home/cbuser/.CommandBox/lib/runwar-5.0.0.jar runwar.Start /home/cbuser/.CommandBox/server/D6436B8096FF1E2B8ED64B21BC044AB6-site1/lucee-5.4.4.38/serverInfo.json
   | The server for /home/cbuser/cbsandbox/site1/ is starting on <http://127.0.0.1:44499> ...
   |------------------------------
   | √ | Setting site [site1] Profile to [development]
   |   |------------------------------------------------------------
   |   | Profile set from profile property in server.json
   |   | Block CF Admin disabled
   |   | Block Sensitive Paths enabled
   |   | Block Flash Remoting enabled
   |   | Directory Browsing enabled
   |   | File Caching disabled
   |   |------------------------------------------------------------
   | √ | Loading CFConfig into server
   |   |-------------------------------------------

WARNING: package com.sun.java.swing.plaf.windows not in java.desktop
Using Console logger layout: PatternLayout
Console logger layout option: pattern=[%-5p] %c: %m%n
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Starting Runwar
[INFO ] Runwar:   - Runwar Version: 5.0.0
[INFO ] Runwar:   - Java Version: 17.0.10+7-Debian-1deb12u1 (Debian)
[INFO ] Runwar:   - Java Home: /usr/lib/jvm/java-17-openjdk-amd64
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Listeners:
[INFO ] Runwar:   - Binding HTTP on 0.0.0.0:44499
[DEBUG] Runwar:      Setting HTTP/2 enabled: true
[DEBUG] Runwar:   Initializing classloader with 1 jar(s)
[DEBUG] Runwar: ******************************************************************************
[DEBUG] Runwar: Undertow Server:
[DEBUG] Runwar:   WAR root:/home/cbuser/cbsandbox/site1
[DEBUG] Runwar:   Servlet Context: /
[DEBUG] Runwar:   Log Directory: /home/cbuser/.CommandBox/server/D6436B8096FF1E2B8ED64B21BC044AB6-site1/lucee-5.4.4.38/logs
[DEBUG] Runwar:   Added shutdown hook
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Configuring Servlet
[DEBUG] Runwar:   File cache is disabled
[INFO ] Runwar:   Found WEB-INF: '/home/cbuser/.CommandBox/server/D6436B8096FF1E2B8ED64B21BC044AB6-site1/lucee-5.4.4.38/WEB-INF'
[DEBUG] Runwar:   Parsing '/home/cbuser/.CommandBox/server/D6436B8096FF1E2B8ED64B21BC044AB6-site1/lucee-5.4.4.38/WEB-INF/web.xml'
[DEBUG] Runwar:   Using webxml override: '/home/cbuser/cbsandbox/site1/web-override.xml'
[DEBUG] Runwar:   Parsing '/home/cbuser/cbsandbox/site1/web-override.xml'
[DEBUG] Runwar:   PID file: /home/cbuser/.CommandBox/server/D6436B8096FF1E2B8ED64B21BC044AB6-site1/lucee-5.4.4.38/.pid.txt
[INFO ] Runwar: ******************************************************************************
[INFO ] Runwar: Creating deployment [default]
[DEBUG] Runwar:   Initialized MappedResourceManager
[INFO ] Runwar:     Web Root: /home/cbuser/cbsandbox/site1
[DEBUG] Runwar:   Adding Server Rules
[DEBUG] Runwar:   Setting GZIP predicate to = request-larger-than(1500)
[DEBUG] Runwar:   New servlet context created for [default]
[DEBUG] Runwar: ******************************************************************************
[DEBUG] Runwar: Undertow Options:
[DEBUG] Runwar:   - ENABLE_HTTP2 = true
[DEBUG] Runwar: ******************************************************************************
[INFO ] Runwar: Starting 'stop' listener thread - Host: 127.0.0.1 - Socket: 43865
[DEBUG] Runwar: System tray integration disabled
[INFO ] Runwar: Server is up - stop-port:43865 PID:611361 version 5.0.0
We do notice the double ‘`//`’ in the site server.json path, although server.json is being read:
Copy code
Site config file - /home/cbuser/cbsandbox/site1//server.json
Another observation,
.cfm
files run but
.cfml
files also return the
powered by commandbox 404
page.
r
Well, it looks like it parsed the override fine. The only thing that caught my eye is Java 17. AFAIK, Lucee 5 isn't compatible with 5, although I don't think that's the problem. Just put
"javaVersion": "openjdk11_jdk"
in your JVM section. Maybe Brad or someone can offer more assistance.
Did you move your override file? You originally put it in "/home/cbuser/.CommandBox/web-override.xml" but the debug output shows that it parsed "/home/cbuser/cbsandbox/site1/web-override.xml".
👀 1
s
Yes, we moved it to /site1/ as part of our troubleshooting. We also moved to java 11 and we’re still seeing the same issue.
r
Yeah, I didn't think the Java version would solve the issue you're having. Unfortunately, I'm out of ideas now.
s
ok, thanks for the help.
After some direction from the fine people at Ortus we were able to get this working! I’ll add this here in case anyone else finds themselves in a similar situation. As per the commandbox 6 documents: 1. you need to define which requests should be forwarded to the servlet : https://commandbox.ortusbooks.com/embedded-server/multi-site-support/servlet-pass-predicate 2. and you need to override the default servlet mappings in web.xml to tell lucee what types of files it show process: https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/web.xml-overrides After configuring these we have Lucee processing .html files.
👍 1
👍🏻 1