Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Deploy GIT files to tomcat server

 
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Currently we are working on a Spring project which is uploaded to Github. Our designers, usually get a WAR file from us and upload it to their local tomcat and then make the design changes and give us the changed files. Recently we taught them GIT but we are facing the following problem

When we are pulling from GIT, we don't get the compiled classes. So when we deploy it in the webapps folder, it doesn't run. So how can we run the files fetched from GIT?
 
Saloon Keeper
Posts: 22265
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Playing around with loose files is a really slipshod way to manage applications. There's a reason why the J2EE spec is built on WAR files. Actually, Tomcat's ability to deploy an unzipped WAR (formally known as an "exploded" WAR) is an extension to the standard and it can be turned off.

However, IF you Must...

First, make sure that when the project is exported to git, that the class files actually make it into the git repository. That is, no ".gitignore for "*.class". If it doesn't go up, it won't come down.

Then, if that's the case, make sure that what you are pulling is in fact an exploded WAR. You cannot just dump loose files into Tomcat. They HAVE to form something that, if zipped up, would be a valid WAR. This is especially important to note if the git repository is the entire project and not just the files in the WAR, since unlike Subversion, you cannot check out a subtree from a git archive. So the repository must contain the WAR and only the WAR.

Finally, remember that if you're going to take the defaults on Tomcat deployment, the WAR has to be a named directory directly under TOMCAT_HOME/webapps. That is, TOMCAT_HOME/webapps/mywebapp/(the war files) is what you need. You cannot dump the files directly into TOMCAT_HOME/webapps. The WAR directory name will be used (by default) to construct the webapp's Context path.

Then again, you might want to consider using something like Jenkins to make all of this a little easier.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have no build process?
 
Partheban Udayakumar
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway & Bear Bibeault,
Thanks for the reply.

Tim Holloway wrote:
Finally, remember that if you're going to take the defaults on Tomcat deployment, the WAR has to be a named directory directly under TOMCAT_HOME/webapps. That is, TOMCAT_HOME/webapps/mywebapp/(the war files) is what you need. You cannot dump the files directly into TOMCAT_HOME/webapps. The WAR directory name will be used (by default) to construct the webapp's Context path.



What we usually do is copy the war file to webapps directory and let tomcat unwrap it. When I am uploading a folder, I will create the mywebapp folder in webapps and then use the files there. Is this the correct way?

Tim Holloway wrote:Then again, you might want to consider using something like Jenkins to make all of this a little easier.


I don't have any idea about Jenkins. I will definitely try to learn it. My IT support team has worked in it as they are the ones deploying files in the server.

Bear Bibeault wrote:You have no build process?


No. Sorry to say this but I don't have any idea about build process. Can you provide me some example links?
 
Tim Holloway
Saloon Keeper
Posts: 22265
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are building a WAR file, keep building it. It originally sounded to me like you weren't doing that anymore.

Be sure to delete the OLD exploded WAR directory before copying in the new WAR file, though. Once Tomcat has exploded the WAR, it will ignore the WAR file, even if it is newer than the WAR directory.

Everyone creating WARs should have a decent build tool. Windows batch files and the like are far too primitive. The 2 most widely-known such tools are Ant and Maven, although we now have additional ones such as Gradle. Maven is good because it encourages a standard project structure and you don't have to set up a complex chain of build rules - it already knows how to take a Maven-standard project and produce a target. Gradle goes one step further and replaces the Maven POM file with a YAML build file, which is a lot easier to code. Bot Ant and Maven are available from their respective project websites at apache.org.

Jenkins itself isn't really so much a build tool as a GUI-based build manager. I use it to run Maven-based builds. Among its virtues are that any authorized user can check the state of the project, including the test results, builds can be triggered automatically when code is checked in or on a regular schedule (if you are into nightly builds) and more.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:If you are building a WAR file, keep building it. It originally sounded to me like you weren't doing that anymore.



So we will have to build a war and upload it every time and if our designers change something and want to see the changes they will have to change the files in the server. Am I right?

Tim Holloway wrote:Maven is good because it encourages a standard project structure and you don't have to set up a complex chain of build rules - it already knows how to take a Maven-standard project and produce a target.



We are actually using a spring maven project. I have a doubt here. When I use the Export -> WAR file option in eclipse on a maven project. Does it war normally or does it use maven to war it?

Tim Holloway wrote:Jenkins itself isn't really so much a build tool as a GUI-based build manager. I use it to run Maven-based builds. Among its virtues are that any authorized user can check the state of the project, including the test results, builds can be triggered automatically when code is checked in or on a regular schedule (if you are into nightly builds) and more.



I haven't looked into Jenkins but I know that our IT support team uses it to build and deploy in server. Since the project is to be handled to the client asap, we are concentrating on that first.
 
Tim Holloway
Saloon Keeper
Posts: 22265
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For design and test purposes, I run Tomcat on my local desktop. Tomcat doesn't require a whole lot of resources and it doesn't need any special administrative privileges and that saves me the cumbersome efforts required to assemble a deployable, post the deployable to a remote server and (usually) stope/restart the server (although I hope that getting rid of PermGen in Java 8 has helped that). In fact, by configuring my local Tomcat settings correctly, I can skip the actual packing of a WAR and go ready-to-run with just a simple "mvn war:exploded" command when all I'm doing is messing around with the JavaScript and CSS. The Maven war goal doesn't recompile classes, so a Java code change would require "mvn compile war:exploded". The only thing faster than that would be to alter the files in the WAR directly and I learned a long time ago not to do that, since I tended to lose changes when I was done.

I'm fairly certain that the Maven plugin doesn't hook into Eclipse's Export function. On the other hand, there are some Maven deployer mojos for Tomcat and various webservers, so it is possible to run a Maven goal to rebuild a WAR and install it directly to a remote server. Some people here do that, but I'm not one, since I prefer a more metered approach. Partly because I build a one-size-fits-all WAR, post it to the Beta test server, and then, if it passes, the exact same WAR file can be deployed unchanged to the production server. Which means that I don't get zapped if I have to go back and debug a production problem using the Beta or local servers, as the exact same code runs on all of them.
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic