How to deploy Ember-Cli App in Tomcat

Hi, I am new to ember-cli. I developed my application. I read how to deploy the app in Heroku, but i need to know how to deploy the it in tomcat?

The output of ember-cli is a set of HTML, JS and CSS files. These can be deployed as any other static website.

I’ve never used tomcat, but I think these links will put you on the right track:

  1. http://stackoverflow.com/questions/3954621/deploying-just-html-css-webpage-to-tomcat
  2. http://www.moreofless.co.uk/static-content-web-pages-images-tomcat-outside-war/

Most people will use scripts automating the process. The basics are something like this:

  1. trigger [a cli command, commit to master branch on git repo, etc]
  2. run ember build --environment=production
  3. copy the files from /dist to a location on the webserver
  4. restart webserver (typically not needed)

fabric, capistrano and terraform are examples of tools that simplify deployment.

Tried using the methods shown above it didnt work as expected!!. There is no output on the screen,it shows no error in console and all the routes are shown when ember Inspector was used to debug.

1 Like

I am getting exactly the same as this

@Wayne_Douglas:

  • Open config/environment.js
  • You could see baseURL as / . Change it to /your_app_root_folder (e.g: /myember) that will be stored under tomcat webapps/ folder.
  • In terminal, execute ‘ember build production
  • Now, copy /dist and paste it in tomcat webapps/
  • rename /dist to /your_app_root_folder (e.g: /myember)
  • Start tomcat and connect localhost:port/myember in browser.

This is worked for us. Anyway i am not sure what happening behind this scene, need to get clear with the concept.

2 Likes

Hey

I have had a level of success with

ember build --watch

and using bower link to push changes to my serverside project

Give me a shout if I can help - the only issue i have atm is that the SCSS isn’t being compiled properly under the dev build - and i really don’t want to push minified code unless I am deploying but atm I just want to be able to dev with index.html being a dynamic page (cshtml)

@Wayne_Douglas: Could you please provide doc link where i can understand what you are doing or please explain me the steps

I’ve blogged about it because I am spiking the code to weigh up whether or not we should be refactoring our site to be an ember SPA:

1 Like

This thread is an old thread but I see there is still some problem in ember run under tomcat.

First, after set the rootURL to /emberapp, you can start /emberapp to visit it.

  1. It only works for you when you direct access to the first level as /emberapp which will load index.html under /emberapp folder, then all ember content was downloaded through index.html and start working. From the page you can jump to other routes.

  2. If you direct access to sub route, such as typing in url like: /emberapp/contact, then it will say 404, since tomcat trying to find default doc under emberapp/contact folder, but there is no default document file (index.html etc.) under emberapp/contact folder. Which cause 404.

Please note: This failure only happened when it was run under Tomcat or other service container. The Ember project service as ‘File’ static content. It works well when run under ember service.

One way to work around it is: in the config/environment.js, set the locationType:‘hash’, when it is in ‘hash’, the sub route URL become /emberapp/#/contact, then tomcat will try to load emberapp/ index.html first then jump to ‘#/contact’.

For some complex scenarios, we still want to use /emberapp/contact as URL, then how can we do it?

If you have a solution, please help to post it. Thanks.