This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Tomcat and the fly likes how to load a new jar file while server is running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "how to load a new jar file while server is running" Watch "how to load a new jar file while server is running" New topic
Author

how to load a new jar file while server is running

kiranrredy ad
Greenhorn

Joined: Feb 01, 2008
Posts: 5
Hi,

I need to place a new jar file into lib while server is running.
How can we load this jar(entirely a new file) into tomcat's current classpath without restarting the server.

Could you anyone help me out.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can restart the webapp itself, without restarting all of Tomcat from the Tomcat manager.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
kiranrredy ad
Greenhorn

Joined: Feb 01, 2008
Posts: 5
Originally posted by Ben Souther:
You can restart the webapp itself, without restarting all of Tomcat from the Tomcat manager.


Ben,
Thanks a lot.

Can we do the same action programatically without using tomcat manager?
kiranrredy ad
Greenhorn

Joined: Feb 01, 2008
Posts: 5
Ben,
Thanks a lot.

Can we do the same action programatically without using tomcat manager?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You could if you wrote your own custom class loader or, if you set your app to privileged, you could do whatever is is that the manager app does when it restarts an app. It's open source so you can look for yourself.

There is also another option of the <Context .../> element that allow you to make your app reloadable. This will cause the app to be reloaded any time a class file or jar file is uploaded. There is a small performance penalty but it's never been noticable to me.

See: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
kiranrredy ad
Greenhorn

Joined: Feb 01, 2008
Posts: 5
Ben,

First one will be the best option in this case. As Context.reload() loads only the classes if they are already in the classpath, here we are adding a new jar file(all new classes).

am i correct?
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: how to load a new jar file while server is running
 
jQuery in Action, 3rd edition