I'm trying to deploy a minimal Scalatra application on Openshift with DIY cartridge. I've managed to get SBT working, but when it comes to container:start
, I get the error:
FAILED SelectChannelConnector@0.0.0.0:8080: java.net.SocketException: Permission denied
Apparently, embedded Jetty tries to open socket at 0.0.0.0, which is prohibited by Openshift (you can only open ports at $OPENSHIFT_INTERNAL_IP). How can I tell Jetty exactly which IP I need it to listen?
To get running with jetty 9.2.13.v20150730 on the Openshift with DIY cartridge you have to run with Java8 setting it to run on the
$OPENSHIFT_INTERNAL_IP
as follows. First ssh onto the host and download a jdk8 withThen in your
.openshift\action_hooks\start
ensure you have the same exported variables with something like:(Note that
jdk-8u20-linux-x64.tar.gz
has also been reported to work so you may want to check for the latest available.)That setup does not need a
jetty.xml
as it sets the--host
and--port
to bind to the correct interface and run the built war file. What it does require is that jetty-runner.jar is copied out of the ivy cache into the target folder. With maven to do that you add something like:Google suggest that the SBT equivalent is simply
retrieveManaged := true
. You can ssh to the host and runfind
to figure out where thejetty-runner.jar
dependency has been copied to and update the start command appropriately.I've never used Openshift, so I'm groping a bit here.
Do you have a jetty.host set?
You may need to set up a jetty.xml file and set it in there. See http://docs.codehaus.org/display/JETTY/Newbie+Guide+to+Jetty for how to set the host. You can tell the xsbt web plugin about jetty.xml by setting your project up like this:
https://github.com/JamesEarlDouglas/xsbt-web-plugin/wiki/Settings
Alternately, you may be able to pass the parameter to Jetty during startup. That'd look like this:
-Djetty.host="yourhostname"
Yes you are right about $OPENSHIFT_INTERNAL_IP. So edit ${jetty.home}/etc/jetty.xml and set jetty.host in the connector section as follows: …..
hth