Why build the webapp outside Docker? It means that docker build is not
enough to give you an image, it needs some extra steps beforehand.

On Fri, Jan 10, 2020 at 12:47 PM Alex K <rightkickt...@gmail.com> wrote:
>
> Just to follow-up on this in case it will be useful to anyone, I managed to
> use also the official tomcat image. I had to amend my .war files and use
> the openjdk:8-jdk version instead of openjdk:11-jdk.
>
> I have used the following Docker files to prepare my custom tomcat image
> (so as to have tomcat home at /opt/tomcat) and then deployed the final app
> as following:
>
> Got openjdk:8-jdk Docker file from:
> https://github.com/docker-library/tomcat/blob/807a2b4f219d70f5ba6f4773d4ee4ee155850b0d/8.5/jdk8/openjdk/Dockerfile
> Amended the tomcat home to /opt/tomcat.
>
> Then deployed the app using the following Docker file:
>
> FROM tomcat:custom
> USER root
> ENV CATALINA_HOME /opt/tomcat
> ENV PATH $CATALINA_HOME/bin:$PATH
> RUN mkdir -p "$CATALINA_HOME"
> WORKDIR $CATALINA_HOME
> ADD iforms_files/app.war $CATALINA_HOME/webapps/
> ADD iforms_files/orbeon.war $CATALINA_HOME/webapps/
> ADD iforms_files/server.xml $CATALINA_HOME/conf/
> ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_HOME/lib
> ADD iforms_files/setenv.sh $CATALINA_HOME/bin/
> EXPOSE 8443
> CMD ["catalina.sh", "run"]
>
> I also tried the alpine versions:
> https://hub.docker.com/layers/openjdk/library/openjdk/8-jre-alpine3.9/images/sha256-ea81da311d33e052eeea34336018434bdc50596100f9c623193867faa291b284
>
> by using the same Dockerfile (by pointing to the custom built image FROM
> tomcat:alpine) I was able to deploy same app successfully reaching image
> size 281MB instead of 660MB with the default tomcat image.
>
>
>
>
> On Fri, Jan 10, 2020 at 11:52 AM Alex K <rightkickt...@gmail.com> wrote:
>
> > Hi,
> >
> > On Thu, Jan 9, 2020 at 7:50 PM Mark Eggers <its_toas...@yahoo.com.invalid>
> > wrote:
> >
> >> Alex,
> >>
> >> On 1/9/2020 8:51 AM, Alex K wrote:
> >> > Hi all,
> >> >
> >> > I have two .war files that when deployed at a plain Debian 9 VM are
> >> working
> >> > fine.
> >> > I have prepared a docker file so as to deploy the same apps within a
> >> docker
> >> > container and for some reason one of the apps is not loading due to some
> >> > error.
> >> >
> >> > Dockerfile:
> >> > FROM debian:latest
> >> > USER root
> >> >
> >> > ENV CATALINA_HOME /opt/tomcat
> >> > ENV PATH $CATALINA_HOME/bin:$PATH
> >> > RUN mkdir -p "$CATALINA_HOME"
> >> > WORKDIR $CATALINA_HOME
> >> >
> >> > # Install packages
> >> > RUN apt update && apt install default-jdk -y && groupadd tomcat &&
> >> useradd
> >> > -s /bin/false -g tomcat -d $CATALINA_HOME tomcat
> >> > COPY apache-tomcat-8.5.50.tar.gz /tmp/
> >> >
> >> > RUN tar xzvf /tmp/apache-tomcat-8.5.50.tar.gz -C /opt/tomcat
> >> > --strip-components=1
> >> >
> >> > ADD app.war $CATALINA_HOME/webapps/
> >> > ADD orbeon.war $CATALINA_HOME/webapps/
> >> > ADD server.xml $CATALINA_HOME/conf/
> >> > ADD web.xml $CATALINA_HOME/conf/
> >> > ADD mariadb-java-client-2.4.1.jar $CATALINA_HOME/lib
> >> > ADD setenv.sh $CATALINA_HOME/bin/
> >> >
> >> > RUN chgrp -R tomcat $CATALINA_HOME && \
> >> >     chown -R tomcat webapps/ work/ temp/ logs/ && \
> >> >     chmod -R g+r conf && \
> >> >     chmod g+x conf && \
> >> >     chmod 750 $CATALINA_HOME/bin/setenv.sh && \
> >> >     rm -f /tmp/apache-tomcat-8.5.50.tar.gz;
> >> >
> >> > EXPOSE 8443
> >> > CMD ["catalina.sh", "run"]
> >> >
> >> > I have tried also several other ways, by using directly other docker
> >> tomcat
> >> > images everytime resulting with some error.
> >> >
> >> > The error I am getting now is:
> >> >
> >> > 10:21:32.201 WARN  c.h.c.c.s.CubaXmlWebApplicationContext  - Exception
> >> > encountered during context initialization - cancelling refresh attempt:
> >> > org.springframework.beans.factory.BeanCreationException: Error creating
> >> > bean with name 'org.springframework.security.filterChains': Cannot
> >> resolve
> >> > reference to bean
> >> > 'org.springframework.security.web.DefaultSecurityFilterChain#0' while
> >> > setting bean property 'sourceList' with key [0]; nested exception is
> >> > org.springframework.beans.factory.BeanCreationException: Error creating
> >> > bean with name
> >> > 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot
> >> > create inner bean '(inner bean)#27690bd5' of type
> >> >
> >> [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]
> >> > while setting constructor argument with key [4]; nested exception is
> >> > org.springframework.beans.factory.BeanCreationException: Error creating
> >> > bean with name '(inner bean)#27690bd5': Cannot resolve reference to bean
> >> > 'clientAuthenticationEntryPoint' while setting constructor argument;
> >> nested
> >> > exception is org.springframework.beans.factory.BeanCreationException:
> >> Error
> >> > creating bean with name 'clientAuthenticationEntryPoint' defined in
> >> class
> >> > path resource [com/haulmont/addon/restapi/rest-dispatcher-spring.xml]:
> >> > Instantiation of bean failed; nested exception is
> >> > org.springframework.beans.BeanInstantiationException: Failed to
> >> instantiate
> >> >
> >> [org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint]:
> >> > Constructor threw exception; nested exception is
> >> > java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
> >> > 10:21:32.243 ERROR c.h.a.r.a.r.RestAPIDispatcherServlet    - Context
> >> > initialization failed
> >> > org.springframework.beans.factory.BeanCreationException: Error creating
> >> > bean with name 'org.springframework.security.filterChains': Cannot
> >> resolve
> >> > reference to bean
> >> > 'org.springframework.security.web.DefaultSecurityFilterChain#0' while
> >> > setting bean property 'sourceList' with key [0]; nested exception is
> >> > org.springframework.beans.factory.BeanCreationException: Error creating
> >> > bean with name
> >> > 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot
> >> > create inner bean '(inner bean)#27690bd5' of type
> >> >
> >> [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]
> >> > while setting constructor argument with key [4]; nested exception is
> >> > org.springframework.beans.factory.BeanCreationException: Error creating
> >> > bean with name '(inner bean)#27690bd5': Cannot resolve reference to bean
> >> > 'clientAuthenticationEntryPoint' while setting constructor argument;
> >> nested
> >> > exception is org.springframework.beans.factory.BeanCreationException:
> >> Error
> >> > creating bean with name 'clientAuthenticationEntryPoint' defined in
> >> class
> >> > path resource [com/haulmont/addon/restapi/rest-dispatcher-spring.xml]:
> >> > Instantiation of bean failed; nested exception is
> >> > org.springframework.beans.BeanInstantiationException: Failed to
> >> instantiate
> >> >
> >> [org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint]:
> >> > Constructor threw exception; nested exception is
> >> > java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
> >> >
> >> >
> >> > Since I am not very familiar with tomcat, I would appreciate any
> >> pointers
> >> > how to troubleshoot this.
> >> >
> >> > Thanx,
> >> > Alex
> >> >
> >>
> >> What's the Java version for Debian 9 versus the debian:latest docker
> >> image?
> >>
> > Thanx for your pointer. It seems it as a version issue I had as using
> > debian:stretch image I was able to deploy successfully as a container.
> > The version I have at Debian 9 is:
> >
> > root@debian9:~# java -version
> > openjdk version "1.8.0_232"
> > OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
> > OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
> >
> > The docker file that successfully deployed the app is:
> >
> > FROM debian:stretch
> > USER root
> >
> > ENV CATALINA_HOME /opt/tomcat
> > ENV PATH $CATALINA_HOME/bin:$PATH
> > RUN mkdir -p "$CATALINA_HOME"
> > WORKDIR $CATALINA_HOME
> >
> > # Install packages
> > RUN apt update && apt install default-jdk -y && groupadd tomcat && useradd
> > -s /bin/false -g tomcat -d $CATALINA_HOME tomcat
> > COPY iforms_files/apache-tomcat-8.5.50.tar.gz /tmp/
> >
> > RUN tar xzvf /tmp/apache-tomcat-8.5.50.tar.gz -C /opt/tomcat
> > --strip-components=1
> >
> > ADD iforms_files/app.war $CATALINA_HOME/webapps/
> > ADD iforms_files/orbeon.war $CATALINA_HOME/webapps/
> > ADD iforms_files/server.xml $CATALINA_HOME/conf/
> > ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_HOME/lib
> > ADD iforms_files/setenv.sh $CATALINA_HOME/bin/
> >
> > RUN chgrp -R tomcat $CATALINA_HOME && \
> >     chown -R tomcat webapps/ work/ temp/ logs/ && \
> >     chmod -R g+r conf && \
> >     chmod g+x conf && \
> >     chmod 750 $CATALINA_HOME/bin/setenv.sh && \
> >     rm -f /tmp/apache-tomcat-8.5.50.tar.gz;
> >
> > EXPOSE 8443
> > CMD ["catalina.sh", "run"]
> >
> >
> >> . . . just my two cents
> >> /mde/
> >>
> >>
> > Thank you all for your assistance!
> >
> > Alex
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to