2
votes

Setup

I have a maven project which creates a war file, I then deploy the war file to a glassfish server (3.1).

My Manifest is default one with just the basic info, but I've also tried maven-war-plugin to add classpath to the Manifest. From my understanding of that plugin it should only help me determine libs outside my web-inf/lib scope.

Problem

In my war file I have two dependencies which both contain the same class but two different version of that class, so I need to specify my Glassfish Archive class loader to load them in a certain order. Now I'm completely lost as how to do this, which leads me to my questions.

Questions

  1. Is it possible to use the Manifest file to force Glassfish to use a specific classpath?
  2. How does Glassfish determine in which order it loads the jar files in WEB-INF/lib?
  3. Is it possible to tell Glassfish how to specify the classpath in some other way?
  4. If not, is it possible to affect the order Glassfish loads the jar files in WEB-INF/lib?
1
why you dont use maven to pack only the dependency you want to have to avoid multiple versions of the same lib? If those come as transitive libs, just figure out which libs take them and exclude in pom.xmlNadir
I wish I could, but sadly we are in the middle of a lot of components and have a lot of dependencies which we have to have, and these dependencies have their own dependencies.. If I exclude them in the pom.xml other dependencies will not work. Hence I need to use the newest version of one specific class, and allow the other classes to be in the classpath too. We have two clients which are using two different versions of Jersey REST Client, and Jersey is packed with javax rs, if either Jersey is excluded it will stop working, if I use javax rs dependency directly I get a backwards-comp version.nesohc
You have clashing classes coming from different artifacts? You should clean up your build otherwise you will running against a wall...If you say you can't do that than you can't handle that. You have to find the root cause of the problem...If you are using two versions of Jersey REST client...sound weird to me...clean up your build.khmarbaise
My project is not using two different version, but my project is in the middle of many other projects that are maintained by different teams with different release cycles.. I know that I do NOT want clashing classes from different artifacts, but I don't really have an option.. Yes two different dependencies are using two different Jersey REST client, and the fact that older Jersey versions include the javax rs packages themselves is the root cause of my problem.. Which is why I have this problem and would gladly accept any help you can offer!nesohc

1 Answers

0
votes

(I don't have privileges to comment in SO, hence the answer) The following link describes one way of managing the order of class loading.However, as others have rightly pointed out, what you are trying to achieve is not good at all.

https://www.java.net/node/704037