4

I have a webapp in a war archive which is deployed on cloudfoundry. One of the libraries ("somelib.jar") used by the app is made by another developer.

I would like a way for him to upload several different versions of somelib.jar and test the behaviour of the app. I have managed to get the jar uploaded to WEB-INF/lib directory of the deployment. I have also managed to unpack the jar into WEB-INF/classes. However, I have not managed to get the new version of the jar to be used. I tried various hacks such as those described in this question and this question without any luck.

Everytime, the classes/jars that get loaded the first time get used after that, even if we replace the actual .class or .jar file in the above directories.

Is there any easy way to achieve what I want?

Note: Since I dont have control of Tomcat (where it runs), I cannot configure Tomcat or make any changes to the server. I just have control on my war file, so everything needs to be done programmatically.

EDIT: the reason I want this is to reduce our testing time. Currently someone gives me a new version of somelib.jar, I repackage it into my application, upload to CF, send him a notification, then he tests the behavior of the new jar. What I would have preferred is that he upload his jar directly to CF and do the testing whenever he has a new version without the unnecessary intermediate delay.

Community
  • 1
  • 1
Jus12
  • 17,824
  • 28
  • 99
  • 157
  • you can drop a completely new war file, because the webapp directory is usually doing hot deploy unless that configuration is turned off in tomcat. That only allows you to have one version running at once but it does 'hot deploy' without a restart. There are problems with this and nobody would seriously consider doing this in a production environment. – Kevin Feb 27 '13 at 19:15
  • I can't believe there is not a simple solution to this. With the advent of PaaS, it is more and more likely that customers will not like to be bothered or be in control of the server configuration. – Jus12 Feb 28 '13 at 16:02
  • You're suffering from a process problem, not a technology problem. If you want a simple solution, give each team member a test environment and the ability to build their own deployable WAR. – parsifal Feb 28 '13 at 16:37
  • I managed to get it to work using standard java reflection API. I will put the solution here when I get some time. If anyone is interested, please comment here. – Jus12 Sep 06 '14 at 04:56

3 Answers3

2

In tomcat 7, you can version your WAR file and the new versions will gradually kick in.

http://www.tomcatexpert.com/blog/2011/05/31/parallel-deployment-tomcat-7

srini.venigalla
  • 5,137
  • 1
  • 18
  • 29
  • Like I said, I am running the app on cloudfoundry and I dont have control or any say on the configuration or the version of Tomcat they use. – Jus12 Feb 27 '13 at 19:08
  • As Ali said above, you can have control over the Tomcat version and config. Along with his link, this one has some good info:http://blog.cloudfoundry.org/2012/06/18/deploying-tomcat-7-using-the-standalone-framework/ – Scott Frederick Feb 28 '13 at 21:09
  • Also, this doesn't help you right now, but Cloud Foundry is implementing buildpacks to replace the existing method of staging apps. Modifying an existing buildpack will be an easy way to customize how apps are staged and configured. Watch for details here: http://cloudfoundry.github.com/docs/roadmap.html and here: https://groups.google.com/a/cloudfoundry.org/forum/#!forum/vcap-dev – Scott Frederick Feb 28 '13 at 21:15
2

Everytime, the classes/jars that get loaded the first time get used after that, even if we replace the actual .class or .jar file in the above directories

That's the way that normal Tomcat (Java EE) classloading works. Your classes are loaded when first deployed, and any changes will be ignored (JSPs are managed slightly differently, but only in a development environment).

You should be able to solve this problem by using the Equinox OSGi bridge servlet. I haven't done this myself, but here's a writeup by a person that I respect.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
parsifal
  • 529
  • 2
  • 4
2

In order for you to control the application server yourself, you would need to deploy a standalone app into Cloud Foundry.

This blog should help you out with that:

http://blog.cloudfoundry.com/2012/05/11/running-standalone-web-applications-on-cloud-foundry/

This way you can custom configure your tomcat.

Ali Moghadam
  • 1,270
  • 8
  • 17