Resolving Conflicting Jar Files in Informatica Platform using Jar Jar Links

Resolving Conflicting Jar Files in Informatica Platform using Jar Jar Links


Resolving Conflicting Jar Files in Informatica Platform using Jar Jar Links

If you use different versions of the same Java libraries as Informatica, you may get an exception NoSuchMethodError . This happens when method signatures do not match between different library versions.

This video shows how to use a tool to manipulate and re-package your jar files so they can be loaded into Informatica’s JVM without error.

Example files can be found on the Informatica Communities site.
Jar Jar Links can be found here: https://code.google.com/p/jarjar/


Content

0.7 -> Hi, this Tim Smith and this another video in the "10 Minute Expert" series.
4.65 -> Today I'm going to talk with you about how to resolve conflicts
8.04 -> in jar files when you're doing Java development work inside Informatica.
12.19 -> Now whether you're developing
18.13 -> Java code inside the Java transformation in
21.24 -> PowerCenter, data services or data quality...
24.869 -> The way that gets executed is inside the environment there's a
29.38 -> Java Virtual Machine or JVM.
32.649 -> And inside of it is a classloader. When you request
36.579 -> a class, the class loader is responsible for finding
41.07 -> it and it looks down the classpath. It looks in jar files and in class files.
44.59 -> These files are organized not just
49.92 -> within jar files to group them together but also
53.46 -> in package names in this example you see a job a transformation that's importing
57.89 -> from the package
58.84 -> org.example. When a request is made
62.899 -> to create an object of this type the class loader goes out
66.68 -> and searches the disk for the file that contains that class
71.97 -> and it will load that class. All the definitions
76.369 -> and executable code and allowed it to be executed. This works fine until
81.11 -> you are using different versions.
84.68 -> When you're not able to maintain compatibility. For example,
88.35 -> the method might get deprecated. And another example,
92.549 -> I might have a case where the first example
95.97 -> here we have a findData()
99.22 -> that's being passed a long, now
102.78 -> I a need to pass a string. Because I'm using a new version
106.29 -> of the method and it only expects a string. Well the class loader can go out and
111.93 -> find that as long as you've got the jar file.
114.509 -> And again this works fine.
118.219 -> But what happens if you need to use
122.28 -> the old and the new version of the jar file?
125.43 -> So in that case your first execution might work (or may not depending on
131.459 ->
132.69 -> which classes it finds first. But if we find the
136.93 -> classname and that's loaded, and we try to use the
140.92 -> other version then the class loader will get a conflict
145.3 -> with the two different versions. And will not allow
148.87 -> a duplicate class being loaded. And the request will fail.
152.75 -> because you can't find something to fulfil the method signatures
156.04 -> so the core problem is that
159.09 -> job does not like the same class name being loaded twice
163.41 -> arm so their couple of ways you can
166.819 -> met deal with is the first is if you have access to the source code you can
170.59 -> change the source code
172.349 -> for your library's so in this example will change
176.459 -> or sample to work example B-two's
179.73 -> Pakistan guess change in there won't be a conflict anymore there's another
184.06 -> little utility that I found called George or links in this is very useful
188.14 -> when you're using libraries like apache commons or
191.7 -> lot for J or other
195.03 -> library such as that if you're using those libraries and Informatica uses
200.239 -> those libraries
201.22 -> then it's very possible to hit a conflict if one is using a new were
206.459 -> package than the other newer version library
210.299 -> so what George Arliss does is it allows you to change
215.62 -> the packaging
218.79 -> for a package and for example
223.18 -> I can then have a jar file that contains
226.319 -> workday example and my first job transformation work
230.18 -> then my second job from transformation will
233.68 -> import or did not example underscore be too
236.989 -> so I've renamed it to be too in inside the jar file
240.409 -> in my appropriate folder are
243.59 -> have org example: v2 so even though the original class file
249.799 -> referred to org example: this is able to go
253.269 -> into the jar file just rename the
257.06 -> the different class packages
262.25 -> let me give you a quick example quick demonstration
267.639 -> I've created an example to show how this works I have
271.11 -> a class called shared class that's in the package
274.46 -> or that bogus it has two different methods the first is version
279.31 -> and every turns a strain that is the version so v1
283.18 -> the second is say something and say something accepts
286.57 -> two parameters to strings and all it does is can't make those together
291.35 -> I have another java file called share class and this is my second version so
296.9 -> this is my new version
298.6 -> and when I ask for version I should get the two
301.759 -> but now instead hard-wired two strains I now take an array of strings
307.449 -> and these get concatenate together in return and it also has a space in
312.32 -> between
312.94 -> the different parts so to
316.25 -> classes with the same name and Tom
319.33 -> now above that I have a test harness
322.34 -> the test harness is just test one
326.03 -> contest to you both assume different versions of shared classed s1
330.539 -> has run test and you specify
333.85 -> or that is yet it calls the shared class
337.389 -> concatenate virgin with
342.44 -> a concatenated string first and second so-called say something
345.66 -> with first and second the second
348.93 -> does the same thing but accepts expects a different method signature
353.58 -> it is passing the string array
356.759 -> now I can't compile these and Ryan test line with this shared class and it's
361.47 -> going to XQ
362.36 -> fine I can run test to do with the share classes going to execute fine
366.509 -> and if thou that's all I need to do inside have
369.96 -> you for Mac I was call one of these then I would be fine as long as
373.86 -> nothing else was referring to the the a different version
379.22 -> but I want to force the failure so that's the way I did that
383.699 -> the I have to Java transformations inside the mapping
387.59 -> in a logical object: and these are
391.49 -> Pauline the two different s you'll see here I'm calling test one
396.639 -> in here I'm calling test to and it takes those values whatever those return and
402.36 -> help but
403.759 -> so I can preview
409.46 -> and the here I'm getting version B one
412.88 -> with the result first and second so those go got cagney
416.169 -> concatenated together now let's call this one
419.77 -> and you'll see a very got the error message there
422.789 -> it says no such method air so it loaded
426.849 -> the class in it went ahead and loaded this
431.169 -> class and now
434.46 -> that it's loaded can't see the other class
438.94 -> the location the jar files is found in the services shared jars third-party
444.289 -> that's where you can add your own jar files
447.3 -> and I have compiled those four different files into four different jars
453.389 -> and those are the B-one B-two test harness the want src to you
459.27 -> so we have a conflict with the B-one and B-two you that we need to resolve
465.27 -> the whale resolve that is by combining
468.669 -> the test harness the two with might be to GR
471.879 -> and then changing the contents of that so that the package is different for the
475.789 -> BT joke
477.15 -> you can see what is inside the jar
480.58 -> what the packages are by
483.9 -> ok using jar
487.729 -> and see have got or bogus share class there
491.65 -> and the inside my test harness the two
496.37 -> I have worked as hard as test to
499.43 -> so I'm going to change and want to combine these two together
503.099 -> into one jar file and then I'm going to you
507.53 -> change or bogus to another
510.919 -> path or another package let's go ahead and get ready have
515.76 -> v2 jar
520.719 -> in the test harness the two
528.49 -> and I'll copy the the to you acts dot jar so
533.029 -> the v2 axe
538.55 -> I have renamed or bogus to be
541.92 -> organics or bogus so I've added another layer on top a bit
548.06 -> the test to class was inside the same folder
552.08 -> and that when I win I
555.18 -> ran the the utility on this JAR file yet
558.62 -> change the test to class to look at
561.83 -> this path instead of the previous path for package
565.42 -> so everything's combined together now got one
568.519 -> jar file that has everything that I need I should be able
572.97 -> have done something very wrong should now be able to preview this
578.76 -> and you'll see that my version one is working
583.29 -> and my version two is working be
586.97 -> note that the first and second has a space in between and BTU
590.839 -> got return now how did it work
594.339 -> how does this magic work going to you show you a
597.63 -> batch file that I created and
602.04 -> in this what I'm doing is I compiled the various
605.67 -> files the shared class is compiled
609.149 -> the test harness version 1 /version to you
612.3 -> are compiled and they are then jarred so I jar to b1 b2
618.24 -> night src want SRC to use the class files each going their own separate
622.459 -> files
624 -> then I test to make sure that my test harness is working
627.97 -> I XQ test1 test2 and that does
632.589 -> now they're that that got me too those four jar files that I started out with
637.42 -> when I'm show you
638.14 -> now and going to combine
641.98 -> the jar files for the Virgin to so the test harness version to you and Tess
646.589 -> harsh version 1 the way that I do that
649.3 -> is I have a folder called combine and I
652.47 -> extract all the information and v2 Jr
656.24 -> in the test car sweetie jar and I combine it all back together
660.66 -> into you a temporary
664.089 -> file called pre test harness the 2x
667.8 -> and %ah the final stab
673.209 -> is to you run the Jar Jar to
677.149 -> so under the tools folder I have the Jar Jar
681.16 -> application this execute it I say process
685.32 -> in roles that txt which tells it how to manipulate the
689.2 -> jar file I give it my pre filed
692.519 -> input file and the output file
695.709 -> there's my test times the 2x jar
698.769 -> last step is to copy the file which I didn't wanna do you
702.44 -> indiscriminately so I've got this comment
705.73 -> next thing I want to show you is what the input here
709.12 -> the input rules for charger and lynx is
712.26 -> that is this last file very simple I said
715.839 -> here's the rule I want you look for anything that's in the
719.529 -> org not bogus and I want you to prefix it
722.99 -> with organics that's it
726.339 -> so Jar Jar links reads this text file
731.37 -> executes the all the rules that you can specify there and there's different
735.1 -> types of roles you can create but I only need a simple
737.6 -> your and yet takes the input jar
741.089 -> writes the output jar with modifications
744.94 -> so finally weekend look one more time
749.079 -> and I can say jar he have
752.769 -> you will like it the free
756.37 -> so that's before
763.29 -> and that's after so before everything was under
766.51 -> or bogus now it's under organics were bogus
770.67 -> and that's the way it works some final notes for you
775.079 -> this is this will not work the example using charger links will not work yes
780.779 -> classes are being mainly loaded
783.339 -> the classloader so if that is the case
787.029 -> there's a static string bean used and charger links does not
791.72 -> identify or do anything with that you might be able to use a class file
796.36 -> editor I've seen some out there I didn't need to do that so I haven't tried it
800.97 -> I'm I imagine it would work by that's up to you to you
805.38 -> experiment with that the URL for the judge Orleans
809.06 -> project is on the Google Code site
812.57 -> and if you have any questions about this feel free to post questions from
815.79 -> to the Informatica community by I remember I didn't write this so
820.55 -> I don't support it if you
823.769 -> arm are having problems P please post to the site
827.24 -> I may be able to respond others might respond but
831.769 -> as a community if everyone contributes then
834.93 -> we all benefit from that
838.29 -> and I'll last night lease please let me know if you found this
841.62 -> recording useful the 10 min expert series take some time and I
846.089 -> appreciate any feedback so thanks for your time I hope this was helpful
850.72 -> and until next time

Source: https://www.youtube.com/watch?v=o_9q1Xmld2I