Node app and cfexecute

Thank you very much for the informative post on commandbox, Joe.

Since it can run a Lucee server in a jvm on my Ubuntu host I can use nodejs and most likely be able to solve the "dependent node_modules” issue, yes?

Yep, all the paths in lucee code match your host, if it works on the host it should work in lucee too.

1 Like

Great to know, Joe, I’ll try out Commandbox in a few days and then update you. Many thanks.

I tried to install commandbox onto my Ubuntu box with the “Linux apt-get” method.

Installation seems successful.

So, I proceeded with the following:
which commandbox
userid@ubuntu-s-2vcpu-4gb-sfo2x-01:~$ which boxx
userid@ubuntu-s-2vcpu-4gb-sfo2x-01:~$ which box
/usr/local/bin/box
userid@ubuntu-s-2vcpu-4gb-sfo2x-01:~$ box
/usr/local/bin/box: 87: exec: java: not found
userid@ubuntu-s-2vcpu-4gb-sfo2x-01:~$ /usr/local/bin/box
/usr/local/bin/box: 87: exec: java: not found

Do I need to add some parameter to box?

Thanks.

You need to have Java installed and in the path. As indicated by the message “java: not found”.

1 Like

my bad, I thought the get-apt would automatically download java as well…

per Install Java on Ubuntu 16.04 | Linode

run prerequisite commands…

sudo apt-get install oracle-java8-installer

failed with err msg:
E: Package ‘oracle-java8-installer’ has no installation candidate
tried java7 and java9 with same result.

what else can I try?

update;
after running
sudo apt install default-jdk
java8 has been installed.

after executing
box server start host=0.0.0.0 port=8080 openbrowser=false rewritesEnable=true cfengine=lucee@5
then, have a browser accessing the following url,
{myhost}:8080/{webroot}/{aDirectory}{mycfm.cfm}
it complained that
“/home/myuserid”/index.cfm not found
so,
at “/home/myuserid” level,
I touched index.cfm to create such a dummy file.
Then, I accessed
{myhost}:8080/{webroot}/{aDirectory}{mycfm.cfm} again
browser presented a blank screen, reveal source showed nothing as well.
trying another URL, same outcome.
probably Commandbox does not like me… Earnestly, why and how to fix it?

Thanks.

Oracle java8 installer requires the webteam8 ppa.

You can install openjdk. Its likely what your container is using anyway.

apt-get install ca-certificates-java openjdk-8-jre

1 Like

The article you provided included ppa instructions. It was step 1 and 2 :slight_smile:

Regardless oracle java 8 is now unsupported without a paid license.

More about openjdk command lines

https://openjdk.java.net/install/

I believe xenial has openjdk8, bionic has 11.

You could also just try apt-get install default-jre-headless

@bdw429s he has a valid point about deps - the commandbox deb should probably have:

Depends: default-jre-headless | java8-runtime-headless | java8-runtime

In the control file

(Java 11 packages also define java8-runtime since its backwards compatible)

After executing apt-get install ca-certificates-java openjdk-8-jre
output:
ca-certificates-java is already the newest version (20160321ubuntu1).
ca-certificates-java set to manually installed.
openjdk-8-jre is already the newest version (8u191-b12-2ubuntu0.16.04.1).
openjdk-8-jre set to manually installed.
The following package was automatically installed and is no longer required:
grub-pc-bin
Use ‘sudo apt autoremove’ to remove it.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

cf script under Commandbox still renders nothing.

also, tried apt-get install default-jre-headless to no avail.

Thanks.

Then you have java.

What happens when you type java -version

Try box version

What do you mean “cf script under Commandbox still renders nothing.”… Can you run box or not?

1 Like

java -version
openjdk version “1.8.0_191”
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

box version
CommandBox 4.6.0+00003

“cf script under Commandbox still renders nothing.”:
loads a URL for a cf/lucee script at port 8080 (under Commandbox) at a browser,
the browser returns nothing, a blank screen, reveal code returns nothing as well.

Is there a way to run Commandbox in debugging mode?
If so, how do I shut it down?

Thanks.

(snip)

As someone who only reads this in email… I won’t see if you edit a post later… so let’s try this again.

Try box server list

Try running box server start with console=true

The full Lucee install, with logs, will be in $HOME/.CommandBox/engine/ somewhere, depending on the server name you want.

Note also, the box server log command

box help server

It’s also a full lucee server, so you can access the server and web admins at their normal URLs.

What you’ve described sounds correct to me. You created an empty index.cfm, then you went to that index.cfm and you got a blank page. That sounds right.

You have to realize when using commandbox that the server webroot is defined by where you are when you run box server start (unless you’re referencing a named server)… So… Did you REALLY want your webroot to be $HOME? Why wouldn’t you start it at $HOME/{webroot} instead? If so, stop your box server, go to the webroot folder, and start an appropriate server there.

rewritesEnabled means “If I can’t find the file you’ve referenced, redirect myself to /index.cfm/file/you/referenced”. IF you don’t want that behavior, don’t turn on rewrites. (If you’re using a coldbox app at the root of your webroot, you want it, otherwise, you probably don’t)

1 Like

Thank you so much Joe.

I’d like Commandbox to use the same web application directory structure that is being used for Lucee docker image, which is, /home/myuserid/lucee/www
What do I need to do to make that happen?

Move your files there.

The point of using commandbox was to use the same structure as your host… so you didnt have to build a specific container with node and dependencies. So now you’re using the structure of your host. :slight_smile:

1 Like

Ok, so, it seems that Commandbox, by default, is looking for cf/lucee scripts/files under its own directory, I’ll check them out later and possibly search for Commandbox tutorials to get a better understanding of it first and update you then.

Thanks.

Hi Joe,

I’m revisiting this subject. Just tested CommandBox with the said scripts like
box mycfcode.cfm,
it worked.
Now, I need to execute it from a web browser, would I use something like
<cfexecute name="mypath/box mycfcode.cfm"> or ?

Thanks.

Running cfexecute implies you’re already running CF, so why wouldn’t you just run the CFM code? You can cfinclude it directly, or make a function or cfc, or any other way you’d reuse code.

1 Like

ok, am working on it now… thanks

Working now, many thanks.