How to deploy ADF generated app to Tomcat(?)

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
thatkidmike
Active Member

How to deploy ADF generated app to Tomcat(?)

Jump to solution

Hello!

 
I am complete newbie if it comes to, not only Alfresco, but web-developing in general. What I want to achive is to use this tutorial: Creating your first ADF app - Alfresco Builder Network - to generate an example ADF app - wich I did. The next thing I would like to do is put this app into Tomcat (wich I beleive is installed since I successfuly managed to use it with "/share" on another computer in the same network) - so all the PCs in the network would be able to access my application just via, i.e. "hostname/appname" - put in the browser. Unfortunately I couldn't get it working well - also couldn't find any solution for this, seems to be, simple problem.

 


The things I did so far is installing the Alfresco Community Edition and all things used in the above tutorial to generate an app. Moreover I started the Alfresco Community along with Tomcat and Postgres so the "localhost/share" - is working well and since the example app uses a "login component" - wich directs to the Alfresco Content Services (if I am not wrong) - if another computer put my localhost adress in the "proxy.conf.js" file and start their own application, the login component actualy uses ACS from my own computer (user made in the localhost/share is recognized in the login component in the generated app)*. I also put the whole project folder into the webapps in the Tomcat folder but I was just a wild guess - didn't work.

 

* - all the PCs are in the same network for testing purposes

 

So simply - how to put that generated app into the Tomcat so another PC in the same network could access it as a client and later on (if I'll be able to add the functionalities) - put some file onto the server and it will be stored on my computer but also it will be visible for all the users who will access the app via browser by, i. e. "localhost/appname".

1 Solution

Accepted Solutions
d_moeyersons
Active Member II

Re: How to deploy ADF generated app to Tomcat(?)

Jump to solution

Hi,

To deploy an ADF app to Tomcat:

  • Open package.json and change
    • "build": "ng build", to "build": "ng build --base-href /destination-folder/",
    • "build:dist": "ng build --prod", to "build": "ng build --prod --base-href /destination-folder/",(The base href will be the folder that you will create inside webapps)
  • Generate the app using: npm run build (or for a distribution build: npm run build:dist)
  • A new folder /dist/ will be created with the content of your compiled app
  • Copy the content of the /dist/ folder to a new folder inside Tomcat webapps with the exact same name as given in --base-href in package.json
    (For example: if you defined the following in package.json: "ng build --base-href /adf/" your app will have to be copied to: tomcat/webapps/adf/)
  • Open app.config.json and edit the value of ecmHost to the ACS platform server (without the /alfresco/ folder)
    For example:
    tomcat/webapps/adf/app.config.json
    {
    "$schema": "../node_modules/@alfresco/adf-core/app.config.schema.json",
    "ecmHost": "https://alfresco.mycompany.com",
    "providers" : "ECM",
    "application": {
    "name": "My adf application"
    },
    "languages": [
    {
    "key": "nl",
    "label": "Dutch"
    }
    ],
    "logLevel" : "trace"
    }
  • (This step is optional but recommended, it allows deep linking on Tomcat)
    Create the WEB-INF folder inside your new tomcat webapp, create a new file in the new folder:web.xml with following content:
    tomcat/webapps/adf/WEB-INF/web.xml

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0"
    metadata-complete="true">

    <display-name>My adf application</display-name>
    <description>
    My adf application
    </description>

    <error-page>
    <error-code>404</error-code>
    <location>/index.html</location>
    </error-page>
    </web-app>

  • If you have CORS issues, there are 2 options:

I did it the same way on our environment, ADF is running on the same Tomcat server as my Share environment and it is working perfectly

Best regards & good luck,

David Moeyersons

3 Replies
abbask01
Established Member II

Re: How to deploy ADF generated app to Tomcat(?)

Jump to solution

when you execute npm start, your app is deployed and run on your local node server. So it should be accessible via the configured host & port across your connected PCs. 

P.S. the "proxy.conf.js" cannot change the host of ACS. You need to it from "app.config.json", change the value of ecmHost

thatkidmike
Active Member

Re: How to deploy ADF generated app to Tomcat(?)

Jump to solution

Thanks for the answer. Nontheless - it wasn't accessible by machines in the local network after "npm start" - I don't know why.

Okey, using this: How to deploy an ADF application on Tomcat Server?  - with understanding more I managed to deploy the app on the Tomcat server so the other PCs have access to it by my "ipSmiley Tongueort/appname" - but now the inbuild login component doesn't work. When I try to login in (or any other user from their PCs) it shows:

Not sure what to do about it - I added the filters in tomcat/conf/web.xml file like in here: https://community.alfresco.com/community/application-development-framework/blog/2017/06/20/adf-cors-... 

d_moeyersons
Active Member II

Re: How to deploy ADF generated app to Tomcat(?)

Jump to solution

Hi,

To deploy an ADF app to Tomcat:

  • Open package.json and change
    • "build": "ng build", to "build": "ng build --base-href /destination-folder/",
    • "build:dist": "ng build --prod", to "build": "ng build --prod --base-href /destination-folder/",(The base href will be the folder that you will create inside webapps)
  • Generate the app using: npm run build (or for a distribution build: npm run build:dist)
  • A new folder /dist/ will be created with the content of your compiled app
  • Copy the content of the /dist/ folder to a new folder inside Tomcat webapps with the exact same name as given in --base-href in package.json
    (For example: if you defined the following in package.json: "ng build --base-href /adf/" your app will have to be copied to: tomcat/webapps/adf/)
  • Open app.config.json and edit the value of ecmHost to the ACS platform server (without the /alfresco/ folder)
    For example:
    tomcat/webapps/adf/app.config.json
    {
    "$schema": "../node_modules/@alfresco/adf-core/app.config.schema.json",
    "ecmHost": "https://alfresco.mycompany.com",
    "providers" : "ECM",
    "application": {
    "name": "My adf application"
    },
    "languages": [
    {
    "key": "nl",
    "label": "Dutch"
    }
    ],
    "logLevel" : "trace"
    }
  • (This step is optional but recommended, it allows deep linking on Tomcat)
    Create the WEB-INF folder inside your new tomcat webapp, create a new file in the new folder:web.xml with following content:
    tomcat/webapps/adf/WEB-INF/web.xml

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0"
    metadata-complete="true">

    <display-name>My adf application</display-name>
    <description>
    My adf application
    </description>

    <error-page>
    <error-code>404</error-code>
    <location>/index.html</location>
    </error-page>
    </web-app>

  • If you have CORS issues, there are 2 options:

I did it the same way on our environment, ADF is running on the same Tomcat server as my Share environment and it is working perfectly

Best regards & good luck,

David Moeyersons