From which Jar a Class was loaded?

Posted by Paolo Dona' Sun, 13 Nov 2005 08:11:00 GMT

Sometimes in production environments I face problems never encountered during development… It’s a general thing.. could happen with jdbc drivers or xml parsers.

I just feel classes are loaded from a different jar than expected.

This of course could happen if you’re deploying to a very different application server or if you’ve no control over the production server classpath.

I found in javaalmanac.com a code snippet that can help you identify which is the jar containing a specific Class at runtime:

Class cls = MyFoo.class;
ProtectionDomain pDomain = cls.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
URL loc = cSource.getLocation(); 
System.out.println(loc); 
// prints something like "c:/jars/MyFoo.jar"

This way you can check if your class is loaded right from the expected jar, not elsewhere :-).

This has shown to be really useful during my sad production debug sessions.

Hope it can help you as well.

Tags , , ,  | 59 comments

Comments

  1. Avatar jug-33 said 30 days later:

    Perchè ci sono 4 pagine in italiano ed una inglese.

    I commenti li devo scrivere in Inglese o in Italiano. Per me sarebbe più semplice scrivere in italiano ma se mi ritrovo in un forum inglese scrivo in inglese , ma se il forum è italiano e si spaccia per inglese scrivo in italiano .

    Insomma inglese o tutto o niente (compresi i commenti)

  2. Avatar Lucio said 32 days later:

    The forum doesn’t pretend to be english. Simply we would like all people could read contents, even english people.

    Write as you want, italian or english, but if the post is i english, it would be polite to comment in english.

  3. Avatar jug-33 said 34 days later:

    hi there,

    I’m not a jug’s member but this is my thought.

    The developer must be to know the english, because all the documentation in the world is in english language and if we want to make grow the community and to go around the world write in english , yeh yeh of course sometimes we can mistake the grammer and we could to make a shit scenarious … but only the man without fear can to speak with god.

  4. Avatar Bert said 331 days later:

    Thx, this helped.

  5. Avatar Benoit Moussaud said 782 days later:

    Very Useful, thanks !

  6. Avatar Egor said 1155 days later:

    You are the man! Saved my day.

  7. Avatar 5 incredible sites to see in Prague said 1995 days later:

    Prague Castle is the world’s largest ancient castle and is actually a complex comprised of sixty-plus buildings. Plan to spend an entire day exploring the cathedrals, towers, palaces, statues, gates and more.5 incredible sites to see in Prague

  8. Avatar GHD Straigheners said 1997 days later:

    All the Holy bible is actually saw to make sure you warrant these sort of hateful treatments like, as an illustration, captivity, all the slaughter about criminals about fights, all the sadistic murders about wives regarded as witches, financing penalising your pet just for tons of offenses, polygamy, and additionally cruelty to make sure you livestock. It really has been which is used to strongly encourage feeling on the grossest superstition and also suppress all the free of cost illustrating about conventional truths. We always bear in mind which usually simultaneously wonderful and additionally hateful rate from Holy bible. Importance not likely in this article self deprecation.

  9. Avatar New Jordans said 1998 days later:

    We’re able to in no way learn how to end up being daring as well as individual, in the event that there have been just pleasure on the planet. We might have discovered relief from the majority of evils; however we now have discovered absolutely no fix for the actual most detrimental of these just about all, the actual apathy associated with people. Such a sightless individual requirements isn’t the instructor however an additional personal. Exactly what I’m searching for isn’t available, it’s within me personally. What we should possess as soon as loved we are able to in no way shed. Everything all of us adore seriously gets part of all of us. Whenever we perform the very best that people may, all of us in no way understand what wonder is actually wrought within our existence, or even within the existence associated with an additional. Whilst these were stating amongst on their own this can’t be carried out, it had been carried out. New Jordans

  10. Avatar True Religion outlet said 1999 days later:

    If you wish to be the best man, you must suffer the bitterest of the bitter.where to find the True Religion Outlet on the discounted price

  11. Avatar watches mens said 2002 days later:

    The developer must be to know the english, because all the documentation in the world is in english language and if we want to make grow the community and to go around the world write in english , yeh yeh of course sometimes we can mistake the grammer and we could to make a shit scenarious … but only the man without fear can to speak with god.

  12. Avatar seo said 2002 days later:

    Here is a novice to learn seo tips seo record from scratch, from the initial construction to the site seo, sem, step by step of the way, the majority of seoer common and common learning progress, this is my seo blog.

  13. Avatar seo said 2002 days later:

    Here is a novice to learn seo tips seo record from scratch, from the initial construction to the site seo, sem, step by step of the way, the majority of seoer common and common learning progress, this is my seo blog.

  14. Avatar New Jordans said 2003 days later:

    Essentially the most pathetic man or woman on the globe can be an agent who has look, nevertheless doesn’t have a eye-sight. One and only thing more serious when compared with staying window blind can be obtaining look nevertheless zero eye-sight. The globe can be shifted coupled, not simply with the really shoves involving their characters, and also with the get worse involving very small catapults of each one trustworthy staff member. There isn’t a double who may have certainly not got a new servant amid the forebears, with out servant who may have certainly not got a new double amid the. In my opinion a new lavish rug involving pine small needles as well as spongy your lawn can be additional delightful as opposed to nearly all deluxe Local green area rug. Toleration is the best surprise in the head; it will take a similar hard work in the mental faculties who’s usually takes for you to harmony one self with a bi-cycle. New Jordans

  15. Avatar Nike Air Jordan Shoes 2011 said 2016 days later:

    Freethinkers can be triggered willing to implement ones own opinions while not bias and even while not fearing to find out problems that battle utilizing possess persuits, rights, and certain principles. It mentality is simply not normal, though planning designed for best thinking about; at which it will be gone, topic is without a doubt prone to grown to be even more serious rather than crappy.

  16. Avatar ways to get your ex back said 2018 days later:

    Great literature is simply language charged with meaning to the utmost possible degree

  17. Avatar Gucci Outlet said 2025 days later:

    For ages, a fabulous deadly disagreement is actually waged approximately a small number of fearless persons about reckoned and additionally renegade regarding the only team, and therefore the awesome not aware religious muscle mass fast relating to the other sorts of. This is actually fights approximately Knowledge and additionally Values. All the small number of experience become a huge hit to make sure you justification, to make sure you live up too, to make sure you regularions, to make sure you liberation, to noted, and also peace right on this planet. Numerous experience become a huge hit to make sure you bias, to make sure you terror, to make sure you secret, to make sure you captivity, to mystery, and also anguish hereafter. All the small number of experience talked about “Think” Numerous experience talked about “Believe! “

  18. Avatar New Jordans 2011 said 2026 days later:

    Don’t believe a single thing. View details at a weighing machine for prospects. Things that appear to be the majority outrageous, insert in ‘Low Probability’, together with things that appear to be the majority plausible, everyone insert in ‘High Probability’. For no reason trust a single thing. As you trust a single thing, everyone avoid thinking about it. Slightly more details you think that, any significantly less intellectual process. For those who trust an item, and now have an opinion regarding every last area, then a neural process quits wholly, which happens to be clinically thought of a proof for fatality, in the present day during health related perform. Which means that insert details at a weighing machine or simply risk, but not trust or simply disbelieve a single thing wholly.

  19. Avatar barefoot running shoes said 2026 days later:

    Thank you for your good website. if you are looking for cheap but also with great quality shoes, then our http://barefoot-runningshoes.com will be your best choose.

  20. Avatar Tiffany Bangle Bracelet said 2032 days later:

    I located this article valuable inside a paper I am composing at university. Hopefully, I get an A now!

  21. Avatar Ed Hardy 2011 said 2034 days later:

    Concerning a super easy doctrine: Pack what on earth is clean. Clean what on earth is 100 %. Scrape when them itches. Everyone loves everyday living for the reason that just what exactly extra could there be. I actually continue to obtain day after day very shorter for your opinions I want to assume, many of the strolling I want to bring, many of the courses I want to learn, plus many of the associates I want to find.

  22. Avatar Wealth Trigger Review said 2037 days later:

    It is no use doing what you like ; you have got to like what you do .http://www.wealthtriggerreview.org/

  23. Avatar Herve Leger Dresses said 2044 days later:

    Tend not to obsess during the past, tend not to aspiration of the future, target mental performance for the found time. Never bypass expressing the globe owes which you existing. The globe owes anyone nothing at all. It turned out below 1st. Every single person is more preferable well when compared with useless, adult men along with moose along with pine bushes, along with they whom recognizes the idea aright will certainly alternatively maintain their lifestyle when compared with damage the idea. Every single gentleman dead. Not every gentleman genuinely existence. Anything have been established, apart from tips on how to are living.

  24. Avatar New Jordans 2011 said 2046 days later:

    Could it be reasonable to become dubious of the whole occupation due to a couple of poor celery? You will find a minimum of 2 essential variations, it appears in my experience. Very first, nobody uncertainties which technology really works, what ever wrong as well as deceptive declare might every once in awhile end up being provided. However regardless of whether you will find any kind of “miraculous” remedies through faith-healing, past your body’s personal capability to remedy by itself, is extremely a lot from concern. Next, the actual expose’ associated with scams as well as mistake within technology is created nearly solely through technology. However the publicity associated with scams as well as mistake within faith-healing is nearly in no way carried out through additional faith-healers.

  25. Avatar Nike Air Jordan Shoes 2011 said 2047 days later:

    You get since you glimpse world wide that sole chunk of advance with humane emotion, just about every progress from the prison rules, just about every move when it comes to this diminution connected with struggle, just about every move when it comes to superior treatment method on the hued backgrounds, or maybe just about every mitigation connected with slavery, just about every moral advance of which there have been on this planet, has become continually compared with because of the sorted churches on the earth. When i claim rather by choice which the Roscoe faith, seeing that sorted with it is churches, has become nonetheless would be the key opponent connected with moral advance on this planet.

  26. Avatar postgraduate courses said 2048 days later:

    I actually loved studying this put up, huge fan. Keep up the nice!!

  27. Avatar Photographers Northern Ireland said 2059 days later:

    Wow, excellent data regarding this issue. You might want to let me know how long will it take? Because I like to write the thesis or may be it would be nice to detect the thesis writing service. Thank you very much.

  28. Avatar Herve Leger said 2063 days later:

    To good reason around confidence, and provide an important reasoned (and reason-responsive) defensive in confidence being a special group of understanding worth extraordinary awareness, So i’m desperate to have fun. As i obviously provide that life belonging to the technology in confidence; everything that I must find out is known as a reasoned land surface to look at confidence honestly as a of obtaining with the facts, without having it, suggest, really as a many people level of comfort by themself and even both (a desirable do the job which achieve have seriously). Though you mustn’t imagine all of us to help you go along with ones own support in confidence to provide a route to facts in cases where within any specific time one catch the attention of the actual dispensation you may be supposedly aiming to explain. Before you’ll catch the attention of confidence once good reason contains one reliable proper cranny, give thought to regardless if one genuinely wish to get out of good reason once good reason is without a doubt in your favor.

  29. Avatar Nike Air Force Ones Shoes said 2066 days later:

    For ages, a fabulous deadly disagreement is actually waged approximately a small number of fearless persons about reckoned and additionally renegade regarding the only team, and therefore the awesome not aware religious muscle mass fast relating to the other sorts of. This is actually fights approximately Knowledge and additionally Values. All the small number of experience become a huge hit to make sure you justification, to make sure you live up too, to make sure you regularions, to make sure you liberation, to noted, and also peace right on this planet. Numerous experience become a huge hit to make sure you bias, to make sure you terror, to make sure you secret, to make sure you captivity, to mystery, and also anguish hereafter. All the small number of experience talked about “Think” Numerous experience talked about “Believe! “

  30. Avatar Gucci Outlet said 2066 days later:

    Freethinkers really are steps ready to benefit from most of the paper hearts lacking bias and additionally lacking fearing to recognize what conflict by their personally own methods, legal rights, or possibly opinions. This approach approach isn’t really usual, still it is very important just for most suitable planning; just where it’s always vanished, controversy is normally likely to turned into uglier when compared to unbeneficial.

  31. Avatar bijoux homme said 2069 days later:

    Prague Castle is the world’s largest ancient castle and is actually a complex comprised of sixty-plus buildings.

  32. Avatar Herve Leger said 2073 days later:

    Don’t think all sorts of things. Context stuff for the climb in possibility. What may appear a good number of foolish, get with ‘Low Probability’, and even what may appear a good number of possible, one get with ‘High Probability’. Hardly ever assume all sorts of things. If you assume all sorts of things, one discontinue considering it. The more often stuff you consider, that not as much cerebral actions. If you happen to assume a product, as well as have a viewpoint at each individual area of interest, next the neurological actions ends thoroughly, that is definitely scientifically thought about a symbol in loss, at the moment on clinical procedure. As a result get stuff for the climb and scope, instead of assume and disbelieve all sorts of things thoroughly.

  33. Avatar Jordan Shoes 2011 said 2074 days later:

    Don’t part with your illusions. When they are gone you may still exist, but you have ceased to live.

  34. Avatar luby said 2078 days later:

    It’s a lucky day!I get one pair of women heels from http://www.aliexpress.com/fm-store/908014 ! It’s have beautiful appearance and very comfortable! Here’s your first look at the first Women’s Heels that I have ever seen. I do believe this is the first time our store has released a Women’s Heels in a high top form.

  35. Avatar Nike air max shoes said 2079 days later:

    It is rather fortunate to locate your webblog!

  36. Avatar worms cure said 2081 days later:

    Firstly, I want to thank you for the useful and informative entry. I am so glad that I have found this your post. The information which you have shared for us is really good explained and I will definitely use it in my work. Thanks a lot one more time for the useful and detailed post and I will be waiting for more such great articles like this one from you in the nearest future.

  37. Avatar Christian Louboutin Outlet said 2086 days later:

    Persons include murdered 1 another, with significant wars in addition to guerilla behavior, for many people decades, nonetheless hard 1 another in our, in excess of Ideologies in addition to Beliefs which often, expressed seeing that propositions, glimpse neither of them legitimate none untrue to help current logicians—unreadable propositions of which glimpse substantial towards linguistically trusting.

  38. Avatar Cheap Nike Air Max said 2090 days later:

    Once we look at the obscene reviews, any voluptuous debaucheries, any bad together with tortuous executions, any unwavering vindictiveness utilizing which unfortunately more than half any Holy book is certainly brimming, it may be even more continuous that many of us name it all the expression associated with a demon ın comparison to the word of mouth for Jesus. It can be a story for wickedness having made that will infect together with brutalize mankind; together with, meant for my best piece, That i regards don’t like it all, as i don’t like whatever is certainly bad.

  39. Avatar Emergency Sandbags said 2112 days later:

    Hey Paolo Dona, I am Master in Computer Application.I am learning many computer languages,specially Ajax Jquery,Jsp. Here in this blog I knew different thing about java.

    - Emergency Sandbags Selling

  40. Avatar cheap jordans said 2117 days later:

    Fashion publications frequently exhibit commercials for well known vogue and popular. This sort of fashion exhibits are often all those that happen to be held in great metropolitan areas like New york, but not continuously. The one disadvantage to attend a style clearly show awesome is always that they’re extremely popular, for this reason, could have to make reservations or buy your tickets in advance style. Moreover to figuring out about vogue through journals in print, you can also utilize the Word wide web to do similar. If you are searching for famous and popular option to visit demonstrates, the online world is a fantastic useful resource tool to suit your needs. You might want to get internet websites on the internet trend publications, because they typically have material on approaching vogue displays. Also, for everybody who is curious about attending a vogue exhibit held on a usual foundation, like every year, you may want to think about how you can execute a standard world wide web search.

  41. Avatar Hancy said 2136 days later:

    Wow!!It’s beautiful!When I get the Hermes handbag I was so Excitement!It’s my first time shopping online,and I am so lucky get the beautiful bag,now let me tell you the website I bought the bag,It’s from http://www.dunkpage.com , and I find here have many kind of goods,like whatch,Fashion Shoes ,football t-shirt,Brand Belt and so on,If you want to buy some goods I advise you go this store.

  42. Avatar portable generators said 2138 days later:

    Your blog is so informative ?keep up the good work!!!!portable generators

  43. Avatar Research paper help said 2167 days later:

    This great blog is very interesting and enjoyable to read. I am a big fan of the subjects discussed. I also enjoy reading the comments, but notice that a lot of people should stay on topic to try and add value to the original blog post. I would also encourage everyone to bookmark this page to your favorite service to help spread the word

  44. Avatar Maroochydore accommodation said 2199 days later:

    Chateau Royale Beach Resort offers 4 star self catering Maroochydore accommodation in Cotton Tree, Maroochydore. Chateau Royale Beach Resort perfectly positioned in the heart of Queensland’s beautiful Sunshine Coast. Visit www.chateauroyale.com.au for more details.

  45. Avatar PSD to HTML said 2210 days later:

    Thank you for your good website.

  46. Avatar PSD to HTML said 2210 days later:

    nice

  47. Avatar PSD to HTML said 2210 days later:

    nice

  48. Avatar PSD to Wordpres said 2210 days later:

    nice

  49. Avatar PSD to Wordpres said 2210 days later:

    nice

  50. Avatar PSD to Wordpres said 2210 days later:

    nice

  51. Avatar PSD to HTML said 2210 days later:

    nice

  52. Avatar PSD to HTML said 2210 days later:

    nice

  53. Avatar PSD to HTML said 2210 days later:

    nice

  54. Avatar PSD to HTML said 2210 days later:

    nice

  55. Avatar SEO Services India said 2280 days later:

    SEO Services in India are known for its quality and result oriented nature. If you are looking for best SEO Services in India,then contact Cyber Flavors as it is one of the best SEO Company in India.

  56. Avatar SEO Services India said 2280 days later:

    Nice i am confuse always in java but thanks to explain us about this

  57. Avatar online excel 2010 course said 2307 days later:

    yeah of course. I don’t think this is going to be something like that. That would be cool.

  58. Avatar newfreeshipping said 2320 days later:

    nice post,thanks for sharing! BTW,check out my new android 4.0 tablet

  59. Avatar Sbobet said 3311 days later:

    I am very happy to read this. This is the kind of manual that needs to be given and not the random misinformation t hat’s at the other blogs. Appreciate your sharing this best posting. Sbobet

(leave url/email »)

   Comment Markup Help Preview comment