I might have found another problem with commandbox...
# box-products
b
I might have found another problem with commandbox 5.5.1 It seems like the rest api is not working anymore. We use Adobe CF 2018, In the server.json file we added a restMapping property to map the api to
/api/*
On Commandbox 5.5.1 I suddenly get a
404 not found
. I'll try to create a demo project to have a simple way of reproducing the problem
Here is the test project to demonstrate the problem: https://github.com/bferdinandus/commandbox-cf-api-test
b
@birdy1980 Thanks for the report, I'll take a look
I don't recall touching any of the rest handler logic, but we did have a ticket related to overriding web.xml servlet mappings, so perhaps that changed something
I don't ever use the CF engine rest mappings myself and not many people do
The first thing I'll test is just doing a
--trace
start and inspecting the console output to see if the rest servlet mappings were added to the server!
@birdy1980 Ok, I think I see the issue
Here's what I found in the console output, which I'm putting here just so you know what to look for 🙂
The JVM args to the server look great
Copy code
--servlet-rest-mappings /api/*
and this log here is correct
Copy code
[DEBUG] Runwar: Overriding web.xml rest mappings with [/api/*]
We can see the rest servlet being added down below
Copy code
[TRACE] Runwar: servlet-name: CFRestServlet, servlet-class: coldfusion.bootstrap.BootstrapServlet
[TRACE] Runwar: Adding servlet: ***** CFRestServlet: coldfusion.bootstrap.BootstrapServlet *****
And below that, we can see the default rest mappings were skipped since we had an explicit one we wanted to override
Copy code
[TRACE] Runwar: Skipping mapping servlet-name: CFRestServlet, url-partern: /rest/*
[TRACE] Runwar: Skipping mapping servlet-name: CFRestServlet, url-partern: /restapps/*
So if we go back up to that second message above where we override the servlet mappings we DON'T see this line of code getting hit
Copy code
LOG.debug("Added rest mapping: " + path + " to " + restServlet.getName());
The reason is because there IS no rest servlet defined at that point in time
When this logic got refactored the logic that overrides the rest mapping was moved BEFORE the
web.xml
servlets were added, so there is no rest mapping in existence yet
This is fairly simple to fix
In the mean time, if you want to get 5.5 working, you should be able to create a web.xml file with JUST the rest servlet mapping defined and used the webxmloverride feature
which is basically a manual method of setting the rest mapping. The top level server.json setting we give you is more of a convenience since XML sucks
@birdy1980 I have your sample app running locally with a bit of hackery to get you going today until I can release 5.5.2
I placed the following file in the web root
web-override.xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "<http://java.sun.com/dtd/web-app_2_3.dtd>">
<web-app id="adobe_coldfusion">
	<servlet-mapping id="coldfusion_mapping_rest">
        <servlet-name>CFRestServlet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
</web-app>
and changed the
server.json
like so
Copy code
"app":{
        "cfengine":"adobe@2018",
        "restMappings":",",
        "webXMLOverride":"web-override.xml"
    },
You can test that ticket on the bleeding edge of 5.5.2 once the build runs too
b
Thanks for al the info and the quick fix. I'll test it on monday.
Yes 🎉 problem solved in v5.5.2-alpha+00567
👍 1
b
Excellent, I'll probably push out 5.5.2 this week so long as nothing new crops up.