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 thelibraries
folder.All
jar
files that are downloaded by the dependency manager are stored inWEB-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?