1

I have a Java web app that uses Netbeans with Ant and Ivy for management and Tomcat as the server. Tomcat version: 8.0.43

I have "Compile on save" checked so that every time I make a change to the code, the application redeploys.

So, I make a change, and then Netbeans automatically redeploys the app so that the changes can be seen in the browser when testing.

This redeploying used to take 1-3 seconds.

I recently added a large library with a lot of dependencies to my app (Apache Tika)

The result is now that redeploying when testing takes much longer (eg: 30 seconds).

Is there anything I can do in order to cut this redeploy time back down to a few seconds?

This is (the relevant part) printed to the log when the application redeploys (I set StandardContext logging to FINE):

19-Jun-2019 12:08:52.996 INFO [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.reload Reloading Context with name [] has started

19-Jun-2019 12:08:53.055 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.listenerStop Sending application stop events

19-Jun-2019 12:08:53.125 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.stopInternal Processing standard container shutdown

19-Jun-2019 12:08:53.171 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.resetContext resetContext Catalina:j2eeType=WebModule,name=//localhost/,J2EEApplication=none,J2EEServer=none

19-Jun-2019 12:08:53.171 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.stopInternal Stopping complete

19-Jun-2019 12:08:53.171 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.startInternal Starting ROOT

19-Jun-2019 12:08:53.627 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.startInternal Processing standard container startup

19-Jun-2019 12:09:11.856 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.setPublicId Setting deployment descriptor public ID to 'null'

19-Jun-2019 12:09:12.200 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.listenerStart Configuring application event listeners

19-Jun-2019 12:09:12.405 FINE [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.startInternal Starting completed

19-Jun-2019 12:09:12.405 INFO [http-apr-8080-exec-4] org.apache.catalina.core.StandardContext.reload Reloading Context with name [] is completed

As you can see, the long wait time occurs when StandardContext.reload is called. Specifically, between:

Processing standard container startup

And

Setting deployment descriptor public ID to 'null'

This corresponds to the code between lines 4325 and 4467 in the StandardContext.start() source code.

But I'm still not sure what the cause is in this portion of code.

Extra info:

  • The jar files that my app depends on are in the libraries folder.

  • All jar files that are downloaded by the dependency manager are stored in WEB-INF/lib.

Nothing is changing in my libraries folder and therefore I would think that, after the initial addition of the library, there shouldn't be any extra time required for the redeploy.

How can I change my set up so that I can redeploy the app in a few seconds again?

Or, is this redeploy time inevitable when including such a large amount of libraries?

theyuv
  • 1,556
  • 4
  • 26
  • 55
  • Apache Tika: https://tika.apache.org/ – theyuv Jun 19 '19 at 06:29
  • Ok, I added it. I figured it's the size of the library that's causing the slow-down, not the contents of the library; that's why I thought it wasn't really relevant to the question. Is this correct? – theyuv Jun 19 '19 at 06:51
  • Yes, I agree that it's probably the size rather than the content, but knowing which library you were using helps to reproduce your problem more closely - that's all. Also FYI, questions should be freestanding - it shouldn't be necessary to read the comments to obtain relevant information - so that's why it helps to update the question. – skomisa Jun 19 '19 at 06:57
  • I added some more detailed debug log messages as well if that helps... – theyuv Jun 19 '19 at 09:44
  • @skomisa Is it expected for the reload time to be this long if I include such a large amount of libraries? – theyuv Jun 19 '19 at 11:29

1 Answers1

0

Add the jars from the added library to the property:

tomcat.util.scan.StandardJarScanFilter.jarsToSkip

In Tomcat's catalina.properties file (found in the conf folder).

There are many questions that explain this issue, eg: How to fix JSP compiler warning: one JAR was scanned for TLDs yet contained no TLDs?

theyuv
  • 1,556
  • 4
  • 26
  • 55