Error while trying to deploy java Tomcat application

Asked

Viewed 557 times

0

Good evening, I hired a hosting service on Uol host and went to try to deploy a java application. I put . From my application inside the webapps folder of Tomcat, it tries to upload the application and gives the following error :

019-01-03 21:57:51,446 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Server version:        Apache Tomcat/8.5.19
2019-01-03 21:57:51,447 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Server built:          Jul 24 2017 21:01:14 UTC
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Server number:         8.5.19.0
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- OS Name:               Linux
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- OS Version:            4.9.6-1.el7.elrepo.x86_64
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Architecture:          amd64
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Java Home:             /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/jre
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- JVM Version:           1.8.0_131-b12
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- JVM Vendor:            Oracle Corporation
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- CATALINA_BASE:         /opt/tomcat8
2019-01-03 21:57:51,448 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- CATALINA_HOME:         /opt/tomcat8
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dnop
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:+DisableExplicitGC
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Xms51m
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Xmx204m
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Duser.timezone=America/Sao_Paulo
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -verbose:gc
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:+PrintGCTimeStamps
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Xloggc://opt/web/logs/1/loggc
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.io.tmpdir=/opt/web/temp/1
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:+UseGCLogFileRotation
2019-01-03 21:57:51,449 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:NumberOfGCLogFiles=5
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:GCLogFileSize=5M
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:MaxMetaspaceSize=34m
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -XX:MaxDirectMemorySize=17m
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcatalina.instance=1
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcatalina.base=/opt/tomcat8
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcatalina.home=/opt/tomcat8
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.io.tmpdir=/opt/web/temp/1
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.core.AprLifecycleListener- Loaded APR based Apache Tomcat Native library [1.2.12] using APR version [1.4.8].
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.core.AprLifecycleListener- APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-01-03 21:57:51,450 [main] INFO  org.apache.catalina.core.AprLifecycleListener- APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-01-03 21:57:51,750 [main] INFO  org.apache.coyote.http11.Http11NioProtocol- Initializing ProtocolHandler ["http-nio-8080"]
2019-01-03 21:57:51,770 [main] INFO  org.apache.tomcat.util.net.NioSelectorPool- Using a shared selector for servlet write/read
2019-01-03 21:57:51,773 [main] INFO  org.apache.catalina.startup.Catalina- Initialization processed in 1591 ms
2019-01-03 21:57:51,796 [main] INFO  org.apache.catalina.core.StandardService- Starting service [Catalina]
2019-01-03 21:57:51,796 [main] INFO  org.apache.catalina.core.StandardEngine- Starting Servlet Engine: Apache Tomcat/8.5.19
2019-01-03 21:57:51,882 [localhost-startStop-1] INFO  org.apache.catalina.startup.HostConfig- Deploying web application archive [/opt/web/webapps/webservicecpf.war]
2019-01-03 21:57:57,768 [localhost-startStop-1] INFO  org.apache.jasper.servlet.TldScanner- At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-01-03 21:57:58,176 [localhost-startStop-1] INFO  org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/webservicecpf]- 1 Spring WebApplicationInitializers detected on classpath
2019-01-03 21:57:58,454 [localhost-startStop-1] INFO  org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/webservicecpf]- Initializing Spring root WebApplicationContext
2019-01-03 21:57:58,454 [localhost-startStop-1] INFO  org.springframework.web.context.ContextLoader- Root WebApplicationContext: initialization started
2019-01-03 21:57:58,550 [localhost-startStop-1] INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext- Refreshing Root WebApplicationContext: startup date [Thu Jan 03 21:57:58 BRST 2019]; root of context hierarchy
2019-01-03 21:57:58,849 [localhost-startStop-1] INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext- Registering annotated classes: [class br.com.pedrodev.webservicecpf.config.Root]
2019-01-03 21:58:03,268 [localhost-startStop-1] INFO  org.springframework.jdbc.datasource.DriverManagerDataSource- Loaded JDBC driver: com.mysql.jdbc.Driver
2019-01-03 21:58:03,858 [localhost-startStop-1] INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean- Building JPA container EntityManagerFactory for persistence unit 'default'
2019-01-03 21:58:03,964 [localhost-startStop-1] INFO  org.hibernate.jpa.internal.util.LogHelper- HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2019-01-03 21:58:04,563 [localhost-startStop-1] INFO  org.hibernate.Version- HHH000412: Hibernate Core {5.2.8.Final}
2019-01-03 21:58:04,566 [localhost-startStop-1] INFO  org.hibernate.cfg.Environment- HHH000206: hibernate.properties not found
2019-01-03 21:58:04,757 [localhost-startStop-1] INFO  org.hibernate.annotations.common.Version- HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-01-03 21:58:06,129 [localhost-startStop-1] INFO  org.hibernate.dialect.Dialect- HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-01-03 21:58:46,084 [Catalina-startStop-1] ERROR org.apache.catalina.startup.HostConfig- Error waiting for multi-thread deployment of WAR files to complete
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Metaspace
    at java.util.concurrent.FutureTask.report[FutureTask.java:122]
    at java.util.concurrent.FutureTask.get[FutureTask.java:192]
    at org.apache.catalina.startup.HostConfig.deployWARs[HostConfig.java:778]
    at org.apache.catalina.startup.HostConfig.deployApps[HostConfig.java:441]
    at org.apache.catalina.startup.HostConfig.start[HostConfig.java:1588]
    at org.apache.catalina.startup.HostConfig.lifecycleEvent[HostConfig.java:318]
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent[LifecycleBase.java:94]
    at org.apache.catalina.util.LifecycleBase.setStateInternal[LifecycleBase.java:395]
    at org.apache.catalina.util.LifecycleBase.setState[LifecycleBase.java:339]
    at org.apache.catalina.core.ContainerBase.startInternal[ContainerBase.java:956]
    at org.apache.catalina.core.StandardHost.startInternal[StandardHost.java:872]
    at org.apache.catalina.util.LifecycleBase.start[LifecycleBase.java:150]
    at org.apache.catalina.core.ContainerBase$StartChild.call[ContainerBase.java:1419]
    at org.apache.catalina.core.ContainerBase$StartChild.call[ContainerBase.java:1409]
    at java.util.concurrent.FutureTask.run[FutureTask.java:266]
    at java.util.concurrent.ThreadPoolExecutor.runWorker[ThreadPoolExecutor.java:1142]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run[ThreadPoolExecutor.java:617]
    at java.lang.Thread.run[Thread.java:748]
Caused by: java.lang.OutOfMemoryError: Metaspace
2019-01-03 21:58:46,108 [main] INFO  org.apache.coyote.http11.Http11NioProtocol- Starting ProtocolHandler ["http-nio-8080"]

When I try to access the site the server returns error 502. You know what it can be?

1 answer

6


Caused by: java.lang.OutOfMemoryError: Metaspace

You are having a memory shortage problem available for the application.

From the boot logs above it appears that Tomcat has been set up with a low memory limit for Metaspace.

Command line argument: -XX:MaxMetaspaceSize=34m

The limit of heapspace (-Xmx204m) also delivers that this is a limited configuration for very simple applications. I don’t remember any production environment set up with so little memory in my entire career (even on my development machine, it’s not uncommon to set up containers that use some Gbs of memory).

I’ve never worked with UOL hosting and can’t tell you exactly where this setting was made. The default, though, is to use environment variables. Usually there is an option in the administrative interface or a file setenv.sh with a line similar to that:

export CATALINA_OPTS="[outros parâmetros] -XX:MaxMetaspaceSize=34m"

If you have access to this environment variable you can simply increase the maximum size or remove the limit. If you don’t have access I would recommend opening a call to ISP support and investigating the possibility of buying a thicker hosting package.

In the absence of the Directive XX:MaxMetaspaceSize=34m the Metaspace by default grows to occupy all available native memory.

It is also quite common for applications to have Classloader Leaks . Thus, deploy and redeploys "hot" in a container can lead to Metaspace exhaustion, even in the case of relatively simple applications. Unfortunately, in most cases the "offending" code is in some library / framework and not in the main application.

Often there is no trivial solution to this problem. Detection and correction of Classloader Leaks is a complex subject (which does not fit into an answer); however, as long as restarting Tomcat from time to time is not an impediment to you, the problem is easily manageable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.