You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alex K <ri...@gmail.com> on 2020/01/09 16:51:52 UTC

Tomcat app within docker container

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

Re: Tomcat app within docker container

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
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 <ri...@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 <ri...@gmail.com> wrote:
>
> > Hi,
> >
> > On Thu, Jan 9, 2020 at 7:50 PM Mark Eggers <it...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat app within docker container

Posted by Alex K <ri...@gmail.com>.
Thanx Logo,


On Fri, Jan 10, 2020 at 3:06 PM logo <lo...@kreuser.name> wrote:

> Alex,
>
> Am 2020-01-10 12:47, schrieb Alex K:
> > 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.
> >
> >
> Almost perfect.
>
> Now have a look at
>
> https://tomcat.apache.org/tomcat-9.0-doc/introduction.html#CATALINA_HOME_and_CATALINA_BASE
> .
>
> This way you don't have to change the installation directory.
>
> set CATALINA_BASE to /opt/tomcat and deploy all your conf and webapp to
> the directories underneath /opt/tomcat.
>
> like this:
>
> FROM tomcat:8-jdk8-openjdk-slim
>       #(slim saves you space)
>
> ENV CATALINA_BASE /opt/tomcat
> WORKDIR $CATALINA_BASE
> RUN mkdir -p temp logs work webapps conf
>
I had to create lib also, so as to copy  mariadb-java-client-2.4.1.jar

ADD iforms_files/app.war $CATALINA_BASE/webapps/
> ADD iforms_files/orbeon.war $CATALINA_BASE/webapps/
> ADD iforms_files/server.xml $CATALINA_BASE/conf/
> # you do need those:
> ADD iforms_files/tomcat-users.xml $CATALINA_BASE/conf/
> ADD iforms_files/web.xml $CATALINA_BASE/conf/
>
> ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_BASE/lib
> ADD iforms_files/setenv.sh $CATALINA_BASE/bin/
>
> EXPOSE 8443
> CMD ["catalina.sh", "run"]
>
> optionally I'd recommend to change the user to tomcat (root is baaah)
>
> ...
> RUN set -x \
>    && groupadd tomcat \
>    && useradd -g tomcat -s /usr/bin/nologin -m -d /home/tomcat tomcat \
>    && chown -R tomcat:tomcat $CATALINA_HOME $CATALINA_BASE
>
> USER tomcat
> ...
>
> Imagesize is sth like 300MB. Unique size 18MB
>
I get 633MB. The .war files I copy seems to add quite a lot. But this is
fine.


> HTH
>
> Peter
>
> <snip>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat app within docker container

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Peter,

On 1/10/20 8:06 AM, logo wrote:
> Alex,
> 
> Am 2020-01-10 12:47, schrieb Alex K:
>> 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/807a2b4f219d70f5ba6f477
3d4ee4ee155850b0d/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-ea81da311d33e052eeea34336018434bdc50596100f9c623193867faa
291b284
>>
>>
>>
>> 
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.
>> 
>> 
> Almost perfect.
> 
> Now have a look at 
> https://tomcat.apache.org/tomcat-9.0-doc/introduction.html#CATALINA_HO
ME_and_CATALINA_BASE.
>
> 
> 
> This way you don't have to change the installation directory.
> 
> set CATALINA_BASE to /opt/tomcat and deploy all your conf and
> webapp to the directories underneath /opt/tomcat.
> 
> like this:
> 
> FROM tomcat:8-jdk8-openjdk-slim #(slim saves you space)
> 
> ENV CATALINA_BASE /opt/tomcat WORKDIR $CATALINA_BASE RUN mkdir -p
> temp logs work webapps conf ADD iforms_files/app.war
> $CATALINA_BASE/webapps/ ADD iforms_files/orbeon.war
> $CATALINA_BASE/webapps/ ADD iforms_files/server.xml
> $CATALINA_BASE/conf/ # you do need those: ADD
> iforms_files/tomcat-users.xml $CATALINA_BASE/conf/ ADD
> iforms_files/web.xml $CATALINA_BASE/conf/
> 
> ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_BASE/lib 
> ADD iforms_files/setenv.sh $CATALINA_BASE/bin/
> 
> EXPOSE 8443 CMD ["catalina.sh", "run"]
> 
> optionally I'd recommend to change the user to tomcat (root is
> baaah)

+1 many times

Remember, root in Docker is also root outside docker.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4bTBsACgkQHPApP6U8
pFgtpxAAnie14dTJg+v/DEmFnPRKRietvBhTRqxduMVAUXr11L0G/m8Ibh5irwR8
ZhTkuiieWdtCz/+dQLMzQIHk/QIbQTK1xTXTrjKgZxCGG87/lmEft2hR3CU2IC5O
CZg1oyeGMpwJqYNOMszTbMeJcyU02qHpmf6iD8W3iPZVlDzkR3vjbA98V/+Q4KhZ
0Mv7uhE22/2Mq17CLFNo15zneP3oAg2UbGf8AzO3RM0ZGLKtGmBSUVz5nVvGxnp7
BS1VMXws66oy9LsLGvf5uf68VbYmh9VUIvODnb0HjKKxZBoWTfOwt/DKLj9QpUWr
2ucSrlt5iyjuT6zQPqDMH0V5GVtM2eXrlOSx6L2BYslgH6bG7eFRO7hU69RIlkLh
aQMjUSEBAd6QKS+6QdbD+9gU9ZAew7OMhW3oJv5Ym89YIFzSonwKdav9780QCEry
Pw5g4+gJBK/V+7tdjz0HVAO3NRpDOcxKAtpjFoJmtOWYf136jbwboyGMT1IOnksp
oZMAsnrv7sU1Ig28ETmGyBudzZWpWImY8CsXZVVozU9XjIh0ivsLhS0A9vmQ5SUs
Z+pwoQ/+tX0NQPh4gJCdX1hwt4CeCdNQ88fEvBgfho0p4LvvcdtBJcUlRGhy7xaq
IgB0C4kxE0PAjq864oKt+3deqcHVZYzByBUUNnHAtiAUhx28N/E=
=m7RV
-----END PGP SIGNATURE-----

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


Re: Tomcat app within docker container

Posted by logo <lo...@kreuser.name>.
Alex,

Am 2020-01-10 12:47, schrieb Alex K:
> 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.
> 
> 
Almost perfect.

Now have a look at 
https://tomcat.apache.org/tomcat-9.0-doc/introduction.html#CATALINA_HOME_and_CATALINA_BASE.

This way you don't have to change the installation directory.

set CATALINA_BASE to /opt/tomcat and deploy all your conf and webapp to 
the directories underneath /opt/tomcat.

like this:

FROM tomcat:8-jdk8-openjdk-slim
      #(slim saves you space)

ENV CATALINA_BASE /opt/tomcat
WORKDIR $CATALINA_BASE
RUN mkdir -p temp logs work webapps conf
ADD iforms_files/app.war $CATALINA_BASE/webapps/
ADD iforms_files/orbeon.war $CATALINA_BASE/webapps/
ADD iforms_files/server.xml $CATALINA_BASE/conf/
# you do need those:
ADD iforms_files/tomcat-users.xml $CATALINA_BASE/conf/
ADD iforms_files/web.xml $CATALINA_BASE/conf/

ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_BASE/lib
ADD iforms_files/setenv.sh $CATALINA_BASE/bin/

EXPOSE 8443
CMD ["catalina.sh", "run"]

optionally I'd recommend to change the user to tomcat (root is baaah)

...
RUN set -x \
   && groupadd tomcat \
   && useradd -g tomcat -s /usr/bin/nologin -m -d /home/tomcat tomcat \
   && chown -R tomcat:tomcat $CATALINA_HOME $CATALINA_BASE

USER tomcat
...

Imagesize is sth like 300MB. Unique size 18MB

HTH

Peter

<snip>

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


Re: Tomcat app within docker container

Posted by Alex K <ri...@gmail.com>.
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 <ri...@gmail.com> wrote:

> Hi,
>
> On Thu, Jan 9, 2020 at 7:50 PM Mark Eggers <it...@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
>

Re: Tomcat app within docker container

Posted by Alex K <ri...@gmail.com>.
Hi,

On Thu, Jan 9, 2020 at 7:50 PM Mark Eggers <it...@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

Re: Tomcat app within docker container

Posted by Mark Eggers <it...@yahoo.com.INVALID>.
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?

. . . just my two cents
/mde/


Re: [OT] Tomcat app within docker container

Posted by logo <lo...@kreuser.name>.
Martynas,

> Am 09.01.2020 um 23:12 schrieb Martynas Jusevičius <ma...@atomgraph.com>:
> 
> Forget Kubernetes for now :)
> 
> My recipe is using a multi-stage build. Very crudely:
> 
> FROM maven as maven
> # build your webapp into a .war
> mvn clean install
> 
> FROM tomcat
> COPY --from=maven /webapp/target/ROOT webapps/ROOT/
> 

NICE!

> It copies the whole folder from the build directory rather than the .war file.
> Here is an example:
> https://github.com/AtomGraph/LinkedDataHub/blob/master/Dockerfile
> 
> It does not use tomcat image directly but rather an intermediary image
> which adds config as ENV capabilities as well as LetsEncrypt
> certificates:
> https://hub.docker.com/r/atomgraph/letsencrypt-tomcat/
> 
> You might also want to take a look at the entrypoint script which is a
> bit more involved:
> https://github.com/AtomGraph/LinkedDataHub/blob/master/platform/entrypoint.sh
> 

Thanks for sharing. Will be very interesting to improve my deployment.


> Look at the container as a large function. Minimize the number of
> inputs to it - generate all the configs that can be generated and
> execute the init actions within Dockerfile and/or entrypoint. Mount
> the rest from host as volumes, under Tomcat's webapps/ROOT (assuming
> you're Dockerizing one webapp).
> 
> Martynas
> atomgraph.com
> 
> On Thu, Jan 9, 2020 at 8:32 PM Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>> 
>> Pater,
>> 
>> On 1/9/20 12:39 PM, logo wrote:
>>>> Am 09.01.2020 um 17:51 schrieb Alex K <ri...@gmail.com>:
>>>> 
>>>> 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
>>> 
>>> Why not using any of the different flavored tomcat images?
>>> 
>>> https://hub.docker.com/_/tomcat <https://hub.docker.com/_/tomcat>
>>> 
>>> You get a working jdk (oracle, adopt, openjdk) and don’t have to
>>> build the system yourself. That may help to get the base running
>>> and then copy your file to the correct spots.
>> 
>> If you've got experience with Docker, I'd love for someone to put
>> together a post/presenation/whatever which addresses this question:
>> 
>> I've got an application that I deploy to Tomcat on a traditional
>> server; How do I Dockerize that?
>> 
>> Specifically, I'd like more than just "well, docker-compose with your
>> WAR file and put it in the right place" because we all know that there
>> are plenty of configuration files, etc. that don't work well with a
>> WAR file, etc.
>> 
>> So maybe this bleeds into "well, if you want to use Docker, maybe you
>> want to consider Kubernetes for configuration" and then explain how
>> you might move some of your server/application configuration into
>> Kubernetes (or similar). I'd like to understand how to package-up
>> things like this to be able to eventually use something like AWS's
>> auto-scaling.
>> 
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>> 
>> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4Xf6sACgkQHPApP6U8
>> pFgobg//Zf5fQ5RqqNDYRDk8KFuS7QWmsZWxUez/waeEbrLW0z/iBRYaIDf63dDs
>> G6/XOPAKov5K4jWxLxTeUY/GUVklwdqy8mGnQJwEmBOlFrMqidfrYZEbx4b6Us1o
>> /GiAch2QUFhflaZ7DzSjxLYosMdReiQRl4PXnLVxNUQ7jB7aRaYRMwXgjCJGc66b
>> PXJSUamYhngIlV4ZYB23ACJsbUlaacsyiYdXOJNSuip/xb8atz547KuGT7shCT0P
>> QqJMNDD91KHWBtgrldkO9pb6zYMpwCUxf5PE9jpgk6U6MDlXeXF+HGEnYY6PFxwV
>> kJfsPt2JUIC8Coo7ydkboxUgSQ16xvV6/PvhAdUGiaadS+WF4ZullveqSyNVHBQw
>> dQI563oQYZ1qfh8zcHeZdsb7TLIaVh9Vx2Vn/+XN1bA1tcvjJx+Pz0fEHjtTy8Q+
>> JW2nLIV2ZdbpsdHi0FjdIWIXscg+EyVMUiPx+qmpVyFA3Al7GWLc1h7yQic+hsuT
>> oscRQf2crbu2tpPBBRP5YodtcAtOOvxbbRsQnALxKuBhBDmFzdl4taPTXlko6Kqc
>> b1C/onqwrDlVPKwySPWFU43rTCLImD0L7eGCDxIzDX5z/HbGahtvYxKXf/Jpg7Sl
>> lZuGlyhIIgRoWZF3utUsI11YjRsmRFme0EtfpMdBz/Xb4v/9YeU=
>> =PK8y
>> -----END PGP SIGNATURE-----
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


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


Re: [OT] Tomcat app within docker container

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Forget Kubernetes for now :)

My recipe is using a multi-stage build. Very crudely:

FROM maven as maven
# build your webapp into a .war
mvn clean install

FROM tomcat
COPY --from=maven /webapp/target/ROOT webapps/ROOT/

It copies the whole folder from the build directory rather than the .war file.
Here is an example:
https://github.com/AtomGraph/LinkedDataHub/blob/master/Dockerfile

It does not use tomcat image directly but rather an intermediary image
which adds config as ENV capabilities as well as LetsEncrypt
certificates:
https://hub.docker.com/r/atomgraph/letsencrypt-tomcat/

You might also want to take a look at the entrypoint script which is a
bit more involved:
https://github.com/AtomGraph/LinkedDataHub/blob/master/platform/entrypoint.sh

Look at the container as a large function. Minimize the number of
inputs to it - generate all the configs that can be generated and
execute the init actions within Dockerfile and/or entrypoint. Mount
the rest from host as volumes, under Tomcat's webapps/ROOT (assuming
you're Dockerizing one webapp).

Martynas
atomgraph.com

On Thu, Jan 9, 2020 at 8:32 PM Christopher Schultz
<ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Pater,
>
> On 1/9/20 12:39 PM, logo wrote:
> >> Am 09.01.2020 um 17:51 schrieb Alex K <ri...@gmail.com>:
> >>
> >> 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
> >
> > Why not using any of the different flavored tomcat images?
> >
> > https://hub.docker.com/_/tomcat <https://hub.docker.com/_/tomcat>
> >
> > You get a working jdk (oracle, adopt, openjdk) and don’t have to
> > build the system yourself. That may help to get the base running
> > and then copy your file to the correct spots.
>
> If you've got experience with Docker, I'd love for someone to put
> together a post/presenation/whatever which addresses this question:
>
> I've got an application that I deploy to Tomcat on a traditional
> server; How do I Dockerize that?
>
> Specifically, I'd like more than just "well, docker-compose with your
> WAR file and put it in the right place" because we all know that there
> are plenty of configuration files, etc. that don't work well with a
> WAR file, etc.
>
> So maybe this bleeds into "well, if you want to use Docker, maybe you
> want to consider Kubernetes for configuration" and then explain how
> you might move some of your server/application configuration into
> Kubernetes (or similar). I'd like to understand how to package-up
> things like this to be able to eventually use something like AWS's
> auto-scaling.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4Xf6sACgkQHPApP6U8
> pFgobg//Zf5fQ5RqqNDYRDk8KFuS7QWmsZWxUez/waeEbrLW0z/iBRYaIDf63dDs
> G6/XOPAKov5K4jWxLxTeUY/GUVklwdqy8mGnQJwEmBOlFrMqidfrYZEbx4b6Us1o
> /GiAch2QUFhflaZ7DzSjxLYosMdReiQRl4PXnLVxNUQ7jB7aRaYRMwXgjCJGc66b
> PXJSUamYhngIlV4ZYB23ACJsbUlaacsyiYdXOJNSuip/xb8atz547KuGT7shCT0P
> QqJMNDD91KHWBtgrldkO9pb6zYMpwCUxf5PE9jpgk6U6MDlXeXF+HGEnYY6PFxwV
> kJfsPt2JUIC8Coo7ydkboxUgSQ16xvV6/PvhAdUGiaadS+WF4ZullveqSyNVHBQw
> dQI563oQYZ1qfh8zcHeZdsb7TLIaVh9Vx2Vn/+XN1bA1tcvjJx+Pz0fEHjtTy8Q+
> JW2nLIV2ZdbpsdHi0FjdIWIXscg+EyVMUiPx+qmpVyFA3Al7GWLc1h7yQic+hsuT
> oscRQf2crbu2tpPBBRP5YodtcAtOOvxbbRsQnALxKuBhBDmFzdl4taPTXlko6Kqc
> b1C/onqwrDlVPKwySPWFU43rTCLImD0L7eGCDxIzDX5z/HbGahtvYxKXf/Jpg7Sl
> lZuGlyhIIgRoWZF3utUsI11YjRsmRFme0EtfpMdBz/Xb4v/9YeU=
> =PK8y
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

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


Re: [OT] Tomcat app within docker container

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Pater,

On 1/9/20 12:39 PM, logo wrote:
>> Am 09.01.2020 um 17:51 schrieb Alex K <ri...@gmail.com>:
>> 
>> 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
> 
> Why not using any of the different flavored tomcat images?
> 
> https://hub.docker.com/_/tomcat <https://hub.docker.com/_/tomcat>
> 
> You get a working jdk (oracle, adopt, openjdk) and don’t have to
> build the system yourself. That may help to get the base running
> and then copy your file to the correct spots.

If you've got experience with Docker, I'd love for someone to put
together a post/presenation/whatever which addresses this question:

I've got an application that I deploy to Tomcat on a traditional
server; How do I Dockerize that?

Specifically, I'd like more than just "well, docker-compose with your
WAR file and put it in the right place" because we all know that there
are plenty of configuration files, etc. that don't work well with a
WAR file, etc.

So maybe this bleeds into "well, if you want to use Docker, maybe you
want to consider Kubernetes for configuration" and then explain how
you might move some of your server/application configuration into
Kubernetes (or similar). I'd like to understand how to package-up
things like this to be able to eventually use something like AWS's
auto-scaling.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4Xf6sACgkQHPApP6U8
pFgobg//Zf5fQ5RqqNDYRDk8KFuS7QWmsZWxUez/waeEbrLW0z/iBRYaIDf63dDs
G6/XOPAKov5K4jWxLxTeUY/GUVklwdqy8mGnQJwEmBOlFrMqidfrYZEbx4b6Us1o
/GiAch2QUFhflaZ7DzSjxLYosMdReiQRl4PXnLVxNUQ7jB7aRaYRMwXgjCJGc66b
PXJSUamYhngIlV4ZYB23ACJsbUlaacsyiYdXOJNSuip/xb8atz547KuGT7shCT0P
QqJMNDD91KHWBtgrldkO9pb6zYMpwCUxf5PE9jpgk6U6MDlXeXF+HGEnYY6PFxwV
kJfsPt2JUIC8Coo7ydkboxUgSQ16xvV6/PvhAdUGiaadS+WF4ZullveqSyNVHBQw
dQI563oQYZ1qfh8zcHeZdsb7TLIaVh9Vx2Vn/+XN1bA1tcvjJx+Pz0fEHjtTy8Q+
JW2nLIV2ZdbpsdHi0FjdIWIXscg+EyVMUiPx+qmpVyFA3Al7GWLc1h7yQic+hsuT
oscRQf2crbu2tpPBBRP5YodtcAtOOvxbbRsQnALxKuBhBDmFzdl4taPTXlko6Kqc
b1C/onqwrDlVPKwySPWFU43rTCLImD0L7eGCDxIzDX5z/HbGahtvYxKXf/Jpg7Sl
lZuGlyhIIgRoWZF3utUsI11YjRsmRFme0EtfpMdBz/Xb4v/9YeU=
=PK8y
-----END PGP SIGNATURE-----

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


Re: Tomcat app within docker container

Posted by Alex K <ri...@gmail.com>.
Hi Logo,

On Thu, Jan 9, 2020 at 7:40 PM logo <lo...@kreuser.name> wrote:

> Hi Alex,
>
>
>
> > Am 09.01.2020 um 17:51 schrieb Alex K <ri...@gmail.com>:
> >
> > 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
>
> Why not using any of the different flavored tomcat images?
>
Tried to to that but I failed also with some other errors. Also I tried to
build the official tomcat image so as to change the default tomcat home
dir, as I wanted to be /opt/tomcat instead of /usr/local/tomcat. I will try
again to use such tomcat images, as going from scratch with debian it gives
me approx 1 GB image size which is somehow big to deploy.


> https://hub.docker.com/_/tomcat <https://hub.docker.com/_/tomcat>
>
> You get a working jdk (oracle, adopt, openjdk) and don’t have to build the
> system yourself.
> That may help to get the base running and then copy your file to the
> correct spots.
>
>
> > 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
> >
> >
>
> javax.xml.bind libs are no longer bundled from JDK 11 onwards. You have to
> add them to the (WEB-INF/) lib directory yourself ...
>
It seems I had a version issue. Using debian:latest at Dockerfile was
deploying the Debian 10 instead of 9, where I initially tested the app.

Using the following docker file I was able to successfully deploy:

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"]


> With the above tomcat images you could also go back to an older JDK (9 or
> even 8).
>
> > Since I am not very familiar with tomcat, I would appreciate any pointers
> > how to troubleshoot this.
> >
> > Thanx,
> > Alex
>
> Peter
>
>

Re: Tomcat app within docker container

Posted by logo <lo...@kreuser.name>.
Hi Alex,



> Am 09.01.2020 um 17:51 schrieb Alex K <ri...@gmail.com>:
> 
> 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

Why not using any of the different flavored tomcat images?

https://hub.docker.com/_/tomcat <https://hub.docker.com/_/tomcat>

You get a working jdk (oracle, adopt, openjdk) and don’t have to build the system yourself.
That may help to get the base running and then copy your file to the correct spots.


> 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
> 
> 

javax.xml.bind libs are no longer bundled from JDK 11 onwards. You have to add them to the (WEB-INF/) lib directory yourself ...

With the above tomcat images you could also go back to an older JDK (9 or even 8).

> Since I am not very familiar with tomcat, I would appreciate any pointers
> how to troubleshoot this.
> 
> Thanx,
> Alex

Peter