MxLDevs
MxLDevs

Reputation: 19506

Running Java web application on tomcat without war

I have been assigned to work on a Java web application built on Spring/Hibernate using Wicket for the front-end, maven for dependency management, running on Tomcat server.

Using netbeans, whenever I make a change to the code, I hit run, and the IDE proceeds to rebuild the project, compiling the code to class files, and then packaging it into a .war file, which I understand is just a regular archive and nothing special.

But it takes up to 10 minutes to build everything, even if it's just one small little change to one of the wicket stuff or hibernate stuff or whatever, and it's very unproductive.

Looking at the deploy process, the biggest bottlenecks are

  1. Copying files from a src folder to a target folder
  2. Packaging everything into war archives
  3. Deploying it to tomcat

How can I speed up the development process? While 10 minutes per build may be relatively little compared to some other applications out there, time wasted is still time wasted to me.

Upvotes: 0

Views: 3212

Answers (4)

suenda
suenda

Reputation: 783

I understand your frustration. I have been through that. My cycle time was 20 minutes for a complete redeployment, by which I mean stopping Tomcat, recopying wars and jars and then restarting the server.

Over time, we refactored our codebase to make every functionality (or web resource) a war and we went from one war that did everything to about 100 wars that had each a single concern. If there were some shared modules between wars, we packaged the module as a jar and deployed it as a shared library. As everybody is working with one web resource at a time, there is always just one war concerned at a time, so redeploying a single war is enough, which is like few seconds (with tomcat-maven-plugin automatically). However if a shared module is concerned, Tomcat had to be restarted completely.

I would suggest you break your application into many deployables if that is possible. For start, you can break your front and backend into two wars and divide further when possible.

Upvotes: 3

duffymo
duffymo

Reputation: 308763

Here's a better suggestion: Use Spring Boot. You can run your app as an executable JAR on a JVM without a servlet engine or Java EE app server.

Upvotes: 3

Jayzb73
Jayzb73

Reputation: 32

I use Eclipse for development. But I believe options for both IDEs would be similar.

As you are using maven so default maven goal for run would be 'mvn package' which cleans target directory, create class files, run unit tests and prepare war file and deploy in tomcat.

Now, you should add a runtime server such as tomcat using New -> Server. and use Run as -> Run on server on your project and provide tomcat server as runtime. Next time when you change your code updated classes are hot deployed as long as tomcat is running. So you can test your code during development only. When you want to create war only then use mvn package to create war file.

Upvotes: -1

navy1978
navy1978

Reputation: 1439

You have at least 2 possibilities here:

1) Use JRebel: https://zeroturnaround.com/software/jrebel/

2) Go in the app folder of Tomcat: there you can find the folder with the unzipped content of the war file, just copy paste there (in the proper location) the JSP as it is, if you made a change into a jsp, or copy past the .class file of the classes you have changed... In most of the case no restart of Tomcat is needed.

Upvotes: 0

Related Questions