Build from 'CORE' repository

Hi Admin,

We need to modify the logic of the CORE logic of mobile coach (by adding REST API for some new logics etc), and so I tried to build the MC.war from the CORE repository with Eclipse, and then based on the file update the docker-compose.yml file as:

version: '3'

services:
  mongodbservice:
    image: mobilecoach/mongo:1.0.1
    environment:
      - MONGO_INITDB_DATABASE=mc
    volumes:
      - ./mc_global/mongo_data:/data/db
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    logging:
        driver: "json-file"
        options:
            max-file: "10"
            max-size: 10m    
    restart: always

  tomcatservice:
    build: .
    ports:
#      - "80:80"
      - "<port_tomcat>:443"
    depends_on: 
      - mongodbservice
      - deepstreamservice
    volumes:
      - ./mc_global/mc_data:/mc_data
      - ./certs/keystore_tomcat:/keystore_tomcat
      - ./tomcat/conf/server.xml:/usr/local/tomcat/conf/server.xml
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    logging:
        driver: "json-file"
        options:
            max-file: "10"
            max-size: 10m      
    restart: always 

  deepstreamservice:
    image: mobilecoach/deepstream.io:2.0.1
    ports:
      - "<port_deepstream>:6020"
    depends_on: 
      - mongodbservice
    volumes:
      - ./deepstream/config.yml:/etc/deepstream/config.yml
      - ./letsencrypt/config/live/<hostname>/privkey.pem:/etc/deepstream/certs/privkey.pem
      - ./letsencrypt/config/live/<hostname>/cert.pem:/etc/deepstream/certs/cert.pem
      - ./letsencrypt/config/live/<hostname>/chain.pem:/etc/deepstream/certs/chain.pem
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    logging:
        driver: "json-file"
        options:
            max-file: "10"
            max-size: 10m    
    restart: always

  nginxservice:
    image: mobilecoach/nginx:1.0.1
    ports:
      - "443:443"
    volumes:
      - ./nginx-reverse-proxy/nginx.conf:/etc/nginx/nginx.conf
      - ./letsencrypt/config/live/<hostname>/privkey.pem:/etc/ssl/private/privkey.pem
      - ./letsencrypt/config/live/<hostname>/fullchain.pem:/etc/ssl/certs/fullchain.pem
      - ./letsencrypt/config/live/<hostname>/cert.pem:/etc/ssl/certs/cert.pem
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    command: [nginx-debug, '-g', 'daemon off;']
    depends_on:
      - tomcatservice
      - deepstreamservice
    logging:
        driver: "json-file"
        options:
            max-file: "10"
            max-size: 10m
    restart: always

and the corresponding Dockerfile referencing the repository:

FROM tomcat:8

MAINTAINER Ralph Chan (dev@ralphchan.com)

RUN mkdir /mc_data
RUN mkdir /certs
RUN apt-get update && apt-get install -y netcat

# COPY configuration.properties /mc_data

COPY setenv.sh /usr/local/tomcat/bin
COPY run.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/run.sh

COPY MC.war /usr/local/tomcat/webapps

CMD ["run.sh"]

Both the setenv.sh and run.sh files are copied directory from the repository.

The container can be built and started. However, the following error was discovered:

23-Jul-2020 07:19:22.924 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
	org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MC]]
		at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
		at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
		at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
		at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:970)
		at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1840)
		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
		at java.lang.Thread.run(Thread.java:748)
	Caused by: java.lang.NoClassDefFoundError: ServletContextEvent
		at java.lang.Class.getDeclaredMethods0(Native Method)
		at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
		at java.lang.Class.getDeclaredMethods(Class.java:1975)
		at org.apache.catalina.util.Introspection.getDeclaredMethods(Introspection.java:133)
		at org.apache.catalina.startup.WebAnnotationSet.loadMethodsAnnotation(WebAnnotationSet.java:285)
		at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:90)
		at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
		at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:328)
		at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:782)
		at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
		at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
		at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5053)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
		... 10 more
	Caused by: java.lang.ClassNotFoundException: ServletContextEvent
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
		... 23 more
23-Jul-2020 07:19:22.930 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [/usr/local/tomcat/webapps/MC.war]
	java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MC]]
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:747)
		at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
		at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
		at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:970)
		at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1840)
		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
		at java.lang.Thread.run(Thread.java:748)
23-Jul-2020 07:19:22.932 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/MC.war] has finished in [1,050] ms
23-Jul-2020 07:19:22.944 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
23-Jul-2020 07:19:22.979 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["https-openssl-nio-443"]
23-Jul-2020 07:19:23.003 SEVERE [main] org.apache.catalina.core.StandardService.startInternal Failed to start connector [Connector[AJP/1.3-8009]]
	org.apache.catalina.LifecycleException: Protocol handler start failed
		at org.apache.catalina.connector.Connector.startInternal(Connector.java:1102)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
		at org.apache.catalina.core.StandardService.startInternal(StandardService.java:440)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
		at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:766)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
		at org.apache.catalina.startup.Catalina.start(Catalina.java:688)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342)
		at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
	Caused by: java.lang.IllegalArgumentException: The AJP Connector is configured with secretRequired="true" but the secret attribute is either null or "". This combination is not valid.
		at org.apache.coyote.ajp.AbstractAjpProtocol.start(AbstractAjpProtocol.java:274)
		at org.apache.catalina.connector.Connector.startInternal(Connector.java:1100)
		... 12 more
23-Jul-2020 07:19:23.004 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1266 ms

May I know how should I update the codes / configs etc to make it working? After that I can add more routes / logic in the CORE repository to build the MC.war file later.

Thanks!