Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Loading different version of jar lib from servlet

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Loading different version of jar lib from servlet

    I have several third party JARs which will be used by my webapps. These JAR files are actually available in different versions.

    E.g.
    Version 1.0 JARs
    /opt/lib/third-party-jars/1.0/3rdparty1.jar
    /opt/lib/third-party-jars/1.0/3rdparty2.jar

    Version 2.0 JARs
    /opt/lib/third-party-jars/2.0/3rdparty1.jar
    /opt/lib/third-party-jars/2.0/3rdparty2.jar

    Is it possible to load a different version of library dynamically before the servlet get loaded? Is any framework able to do this without changing my existing code?

    public class Servlet1 extends HttpServlet {

    protected void doPost(....) {
    MyBusinessLogic businessLogic = new MyBusinessLogic();
    businessLogic.run() // My business logic spawns here which will start involving third-party classes
    }
    }

    Or is it possible to load version 1.0 or 2.0 library dynamically in the code before my business logic get invoked? One approach I can come up is using custom classloader and "setContextClassLoader" but this requires to refactor all my business logic using reflection. This will be a huge effort. I am trying not to change my existing business logic code.


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Loading different version of jar lib from servlet

    How do you determine which client gets which version of the software?

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Loading different version of jar lib from servlet

    Hi,
    I ll suggest better you use maven project for such requirement.

    bean factory
    Last edited by abani; December 18th, 2011 at 02:04 AM.

Similar Threads

  1. jre version in command line
    By major in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 14th, 2011, 06:55 AM
  2. Need to uninstall the previous version of java?
    By akanksha4000 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 25th, 2011, 09:40 AM
  3. collecting information/moving from servlet to servlet
    By CBird in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 1st, 2011, 07:04 PM
  4. MarshallableObject for java 6 version
    By AllenK in forum Java SE APIs
    Replies: 12
    Last Post: July 5th, 2010, 02:51 AM
  5. Replies: 5
    Last Post: April 20th, 2009, 06:47 AM

Tags for this Thread