Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot app runs on host tomcat, fails on docker tomcat #13546

Closed
marvin226 opened this issue Jun 21, 2018 · 1 comment
Closed

Spring Boot app runs on host tomcat, fails on docker tomcat #13546

marvin226 opened this issue Jun 21, 2018 · 1 comment
Labels
status: invalid An issue that we don't feel is valid

Comments

@marvin226
Copy link

Hello, i have the following problem / bug:

Short:
The war file of the application is running fine on a tomcat server on my mac (no docker), but it is not working in the tomcat instance of a docker container.

Log file

I hope it is okay to open this issue :)

Long:
We have a SpringBoot app which should run in a Tomcat instance in a Docker container, the problem is that the Spring app fails to startup on my MacOS host but successfully starts up on a Ubuntu host.

Log for Spring Application start:

2018-06-20 13:28:12.123  INFO 7 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1073 ms
2018-06-20 13:28:12.176  WARN 7 --- [ost-startStop-1] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; 
  nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletRegistrationBean' defined in class path resource [frontend/spring/report/BirtEngineServletConfiguration.class]: 
  Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.ServletRegistrationBean]: Factory method 'servletRegistrationBean' threw exception; nested exception is java.lang.ExceptionInInitializerError
Basically this type of error is happening everytime, even if I remove the whole Birt Stack of our application, then the faulty classes will be just some others.

This led me to the suspicion that my environment could cause the error, because the difference between my log to the log of my colleagues is that the following only appears on my host but not on the other hosts:

13:28:10.333 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletConfigInitParams' with lowest search precedence
13:28:10.336 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'servletContextInitParams' with lowest search precedence
13:28:10.341 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'jndiProperties' with lowest search precedence
13:28:10.342 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemProperties' with lowest search precedence
13:28:10.342 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding PropertySource 'systemEnvironment' with lowest search precedence
13:28:10.342 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [StubPropertySource@354020215 {name='servletConfigInitParams', properties=java.lang.Object@5420df83}, StubPropertySource@825691136 {name='servletContextInitParams', properties=java.lang.Object@51372fd5}, JndiPropertySource@196027607 {name='jndiProperties', properties=org.springframework.jndi.JndiLocatorDelegate@59a13ee6}, MapPropertySource@1350532830 {name='systemProperties', properties={java.runtime.name=Java(TM) SE Runtime Environment, java.protocol.handler.pkgs=org.apache.catalina.webresources, sun.boot.library.path=/usr/lib/jvm/jre8/lib/amd64, java.vm.version=25.161-b12, shared.loader=, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=:, tomcat.util.buf.StringCache.byte.enabled=true, java.util.logging.config.file=/opt/tomcat/conf/logging.properties, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, file.encoding.pkg=sun.io, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, tomcat.util.scan.StandardJarScanFilter.jarsToScan=log4j-web*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/opt/tomcat, java.runtime.version=1.8.0_161-b12, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/lib/jvm/jre8/lib/endorsed, os.arch=amd64, java.io.tmpdir=/opt/tomcat/temp, line.separator=
, java.vm.specification.vendor=Oracle Corporation, java.naming.factory.url.pkgs=org.apache.naming, java.util.logging.manager=org.apache.juli.ClassLoaderLogManager, os.name=Linux, ignore.endorsed.dirs=, sun.jnu.encoding=ANSI_X3.4-1968, java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.specification.name=Java Platform API Specification, java.class.version=52.0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.version=4.9.87-linuxkit-aufs, java.util.concurrent.ForkJoinPool.common.threadFactory=org.apache.catalina.startup.SafeForkJoinWorkerThreadFactory, user.home=/root, catalina.useNaming=true, user.timezone=Etc/UTC, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=ANSI_X3.4-1968, java.specification.version=1.8, tomcat.util.scan.StandardJarScanFilter.jarsToSkip=bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,jaspic-api.jar,catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,catalina-tribes.jar,jasper.jar,jasper-el.jar,ecj-*.jar,tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,tomcat-jdbc.jar,tools.jar,commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl.jar,taglibs-standard-spec-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,junit.jar,junit-*.jar,hamcrest-*.jar,easymock-*.jar,cglib-*.jar,objenesis-*.jar,ant-launcher.jar,cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,xom-*.jar, catalina.home=/opt/tomcat, java.class.path=/opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar, user.name=root, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.,org.apache.tomcat., java.vm.specification.version=1.8, sun.java.command=org.apache.catalina.startup.Bootstrap start, java.home=/usr/lib/jvm/jre8, sun.arch.data.model=64, user.language=en, java.specification.vendor=Oracle Corporation, awt.toolkit=sun.awt.X11.XToolkit, java.vm.info=mixed mode, java.version=1.8.0_161, java.ext.dirs=/usr/lib/jvm/jre8/lib/ext:/usr/java/packages/lib/ext, sun.boot.class.path=/usr/lib/jvm/jre8/lib/resources.jar:/usr/lib/jvm/jre8/lib/rt.jar:/usr/lib/jvm/jre8/lib/sunrsasign.jar:/usr/lib/jvm/jre8/lib/jsse.jar:/usr/lib/jvm/jre8/lib/jce.jar:/usr/lib/jvm/jre8/lib/charsets.jar:/usr/lib/jvm/jre8/lib/jfr.jar:/usr/lib/jvm/jre8/classes, server.loader=, java.vendor=Oracle Corporation, catalina.base=/opt/tomcat, jdk.tls.ephemeralDHKeySize=2048, file.separator=/, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar", sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.tomcat., sun.cpu.isalist=}}, SystemEnvironmentPropertySource@945732227 {name='systemEnvironment', properties={PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tomcat/bin, TOMCAT_VERSION=8.5.24, HOSTNAME=1dac3826ef98, JAVA_HOME=/usr/lib/jvm/jre8, CATALINA_HOME=/opt/tomcat, JDK_JAVA_OPTIONS= --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED, PWD=/opt/tomcat, HOME=/root, SHLVL=0}}]
13:28:10.345 [localhost-startStop-1] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'

(This happens before the Spring application start)

I have tried a docker image from ubuntu with oracle java and tomcat manually installed and the official tomcat image.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 21, 2018
@wilkinsona
Copy link
Member

This is the underlying cause of the failures:

Caused by: java.lang.SecurityException: class "org.apache.commons.logging.LogConfigurationException"'s signer information does not match signer information of other classes in the same package
        at java.lang.ClassLoader.checkCerts(ClassLoader.java:898) ~[na:1.8.0_161]
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668) ~[na:1.8.0_161]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:761) ~[na:1.8.0_161]
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_161]
        at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2283) ~[catalina.jar:8.5.24]
        at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:811) ~[catalina.jar:8.5.24]
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1260) ~[catalina.jar:8.5.24]
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) ~[catalina.jar:8.5.24]
        at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_161]
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_161]
        at java.lang.Class.getConstructor0(Class.java:3075) ~[na:1.8.0_161]
        at java.lang.Class.newInstance(Class.java:412) ~[na:1.8.0_161]
        at org.apache.commons.discovery.tools.ClassUtils.newInstance(ClassUtils.java:157) ~[commons-discovery-0.2.jar-4.7.0.jar:0.2]
        at org.apache.commons.discovery.tools.SPInterface.newInstance(SPInterface.java:197) ~[commons-discovery-0.2.jar-4.7.0.jar:0.2]
        at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:579) ~[commons-discovery-0.2.jar-4.7.0.jar:0.2]
        at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:418) ~[commons-discovery-0.2.jar-4.7.0.jar:0.2]
        ... 55 common frames omitted

It looks like you have Commons Logging classes in multiple places in your Tomcat instance in Docker. As you suspected this is an issue with your environment and is out of Spring Boot’s control.

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants