URLClassLoader loading class from jarB, which uses classes from jarC

Hi, here's my problem:
I have a classA in executable jarA.
This uses URLClassLoader to load classB from jarB. So far so good.
But classB uses classC, which lives in jarC. jarC is specified in the Class-Path of the manifest in jarB. But classB gets a ClassNotFound exception when it tries to use classC.
The situation I want to achieve looks like this (sorry for the bad art; it's almost impossible to make it look better because sun strips out extra spaces):
jarA:
classA-----> URLClassLoader(jarB).loadClass(classB)
jarB:
Class-Path jarC
classB------> new classC
jarC:
classC
My expectation was that URLClassLoader would automatically be used to load all the classes that classB uses, and that it would extend its classpath by the classpath specified in the manifest of jarB, just like the default classloader does. Anyone know what I'm doing wrong?
When I do the following, i.e. use only the default classloader, everything works fine. Unfortunately I won't know where jarB is until runtime, so I can't actually do this:
jarA:
Class-Path jarC
classA-----> new classB
jarB:
Class-Path jarC
classB------> new classC
jarC:
classC
thanks alot
j

Actually, there is definitely a way to make this work. A plugin engine has to handle this in order for plugins loaded by separate loaders to be able to share class instances with one another (dependency). My engine does static runtime plugin dependency resolution, which means it parsers every plugin's config file, then after all plugins are in the "registry" it goes back and resolves all dependencies. How it does this is that each PluginClassLoader keeps a list of "dependent" classloaders. So, if the engine finds plugin A, B, and C, and B depends on C (declares this in its config file), the engine creates 3 class loaders (custom loader called PluginClassLoader), one for each plugin. This is done so that the plugin can be unloaded or reloaded at runtime without having to shut the application down. Now, since B depends on C, when plugin B code requests a class found in C, the JVM first asks B's loader to find the class. The "normal" delegation model of Java is for B's loader to first look in the parent hierarchy, then in its own classpath. The problem with this approach is that in order to support reloadable and unloadable plugins, you do NOT want your plugin .jar file at any location within the main application classpath. The plugin .jar file should be able to be at any URL location outside of any other classpath, even perhaps at another web site.
So, the JVM asks B to find the class in C. But B's loader isn't able to find it because it is not in B's classpath. The trick is to do one of a couple things. First, remember that each loader keeps a list of dependent loaders. Second, in order to avoid any tie-in to the main classpath, we break the normal classloader delegation model by overriding the loadClass() method. In here we want to first check our local cache of loaded classes. The built-in method findLoadedClass() handles this for us. If that doesn't return a Class, then we want to look in our own classpath. In this case, we only want to look for any classes in B's plugin .jar file. C's class of course wont be found here. So the next step is to delegate to our "dependent" list of loaders. Aha, you say? This is the trick (credit goes to the Eclipse IDE team where a few members taught me this and was able to help me solve my very same problem). By delegating to a dependent loader, B's loader effectively asks C's loader to find C's class. The same thing happens, only this time it is now C's loader doing the work. The very first time the calls is made, no classes are loaded yet, so the finding of the C class in the local cache of C's loader wont yet work. The next step though, looking in C's classpath (C's .jar file) WILL find the class. It is loaded, put in C's loader cache and the Class is returned. Now, at this point B now has a Class from C's classpath that it can use.
Now, my first foray into this made me think that if B asks C to find it, and C finds it and loads the bytecode, doesn't B's loader also need the bytecode in order to properly "see" the C class. Apparently, this is not needed. I am guessing the JVM keeps a repository of bytecode, so that so long as you have the C ref (location in the JVM's memory where C's bytecode is), you don't need to re-load the bytecode of C into B's loader. Thus, B's loader now can "see" the C class without actually having to have loaded the bytecode of C. Now, B's code can typecast C, use it, etc. Beautiful aint it?
Let me know if you have any further questions.

Similar Messages

  • I pay to get music from Kazaa which uses a WMA format, when I try to add it to my Itunes it says that the songs is from a WMA format and Itunes uses AAC format, how can I get this music to my Itunes to put on my I-pod/

    I pay to get music from Kazaa which uses a WMA format, when I try to add it to my Itunes it says that the songs is from a WMA format and Itunes uses AAC format, how can I get this music to my Itunes to put on my I-pod/

    By converting the WMA files to AAC formatted files. 

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • I downloaded a song (Matt Corby Winter) from itunes which has disapeared from my computer.  I have followed the instructions to locate it but haven't been able to.  I need to download it again from itunes.  How do I do this?

    I downloaded a song (Matt Corby Winter) from itunes which has disapeared from my computer.  I have followed the instructions to locate it but haven't been able to.  I need to download it again from itunes.  How do I do this?

    A simple search finds this article:
    Download past purchases - Apple Support

  • HT201272 lost songs from ipod (which I purshased from Itunes from the IPOD) didn't back up to PC itunes and my wife restaged my sons ipod and the songs gone-Apple itunes gave me a link to relaod however they are showing light grey on the ipod (marked in l

    lost songs from ipod (which I purshased from Itunes from the IPOD) didn't back up to PC itunes and my wife restaged my sons ipod and the songs gone-Apple itunes gave me a link to relaod however they are showing light grey on the ipod (marked in lt grey)

    I have the same problem!! only thing is that i have the ipod touch 5th generation and a mac. I've been trying to find a way to get all my music to play cuz it will only play on itunes but when i try to play it on my ipod it'll just show a circle with a red square in the middle next to the songs i cant play.

  • Can i get my iPhone replaced from Singapore which was bought from USA ?

    I bought an Iphone 4 from US which has an extended applecare coverage.... I believe that there is a hardware problem in my iphone....
    Can it be replaced in singapore ?
    As i will be visiting singapore this week......
    If NO then what are the options for me...
    And if YES then where can i get it done ??

    Dr.Adil wrote:
    Can you please ask this on my behalf... ??? coz i am in pakistan.... and this would be a difficult job for me to do :S
    You're just as capable as anyone else here of asking and finding out the answer yourself.
    Contact Apple in your country, or whomever provides support.

  • I get a message saying "Firefox has prevented this page from reloading" when I am trying to load video to Facebook which stops it from loading. I click "allow" and the message just reappears. How do I allow this function?

    Message reads "Firefox prevented this page from automatically reloading".

    See:
    * Firefox/Tools > Options > Advanced > General : Accessibility : [ ] "Warn me when web sites try to redirect or reload the page"
    The setting in "Tools > Options > Advanced > General" is meant as an accessibility feature, as you can see by the label of that section, so that people with disabilities or people who use screen readers do not get confused and is not meant as a safety protection to stop redirecting.
    See also:
    * https://support.mozilla.com/kb/Options+window+-+Advanced+panel#General_tab
    * http://kb.mozillazine.org/accessibility.blockautorefresh
    * http://kb.mozillazine.org/Accessibility_features_of_Firefox

  • URGENT!!! How to call Webservice which uses JKS from BusinessService

    Hi
    One of our webservice require a client certificate (.JKS) to stablish the connection
    How/where to add the the following details to call business service?
    org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
    org.apache.ws.security.crypto.merlin.keystore.type=JKS
    org.apache.ws.security.crypto.merlin.keystore.password=password
    org.apache.ws.security.crypto.merlin.file=product-services-client.jks
    Thank you
    Edited by: user11310683 on 21/09/2011 17:18

    Hi Anju
    Thanks for your reply.
    I have to use outbound security. My BussinesService --> product.jks -->ThirdPartyWebService. ThirdParty has provided product.jks to connect their webservice and its one way security.
    In the following post you have mentioned to use Ploicy. Could you please let me know how to use product.jks in the Policy file?
    OSB - outbound message level security (digital signature + security token)
    No need of Service Key provider for using policy in Business Service. Only proxy services can use Service Key provider. Policies written to be used with Business Service has the certificate embedded in it.
    How add product.jks to policy file?
    I have to sign the message with providers public key (the certificate I am using is the self-signed certificate).
    This is only for one-way(outbound) communication.
    Any good sample project to play around on the security_
    Thank you
    Edited by: user11310683 on 25/09/2011 16:56
    Edited by: user11310683 on 28/09/2011 17:59

  • No sound from TV when using HDMI from HP Envy Ultrabook4 despite downloading drivers

    Problem: When using an HDMI cord from my HP Envy Touchsmart Ultrabook 4 (4-1105dx)to connect to my TV to view movies, the video appears on my TV screen, but there is NO sound from the TV. Instead the sound comes from my lap top.
    Troubleshooting: I have looked under Sounds in the Control Panel, but the only choice listed is Speakers & Headphones IDT High Definition (which is the default) and does not allow sound from the TV when using the HDMI. I have also tried to download Driver and Audio Graphics, but wasn't sure which one & the ones which were downloaded have not solved the problem.
    Can you assist me? Which is the correct Audio/Graphic Driver to download? Or is there another possible reason why I cannot hear sound from my TV when using the HDMI to connect to my lap top?

    Hi,
    Please try this first to enable Speakers in Playback devices as follows:
    1. Right click speaker icon (bottom right hand corner)
    2. Select Playback devices
    3. Right click HDMI sound
    4. Enable it
    5. Click Apply/Ok
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Can not insert/update data from table which is created from view

    Hi all
    I'm using Oracle database 11g
    I've created table from view as the following command:
    Create table table_new as select * from View_Old
    I can insert/update data into table_new by command line.
    But I can not Insert/update data of table_new by SI Oject Browser tool or Oracle SQL Developer tool .(read only)
    Anybody tell me, what's happend? cause?
    Thankyou
    thiensu
    Edited by: user8248216 on May 5, 2011 8:54 PM
    Edited by: user8248216 on May 5, 2011 8:55 PM

    I can insert/update data into table_new by command line.
    But I can not Insert/update data of table_new by SI Oject Browser tool or Oracle SQL Developer tool .(read only)so what is wrong with the GUI tools & why posting to DATABASE forum when that works OK?

  • Generating a report from RTF template using WSDL from ADF

    Hi,
    I am a newbie to ADF-BIP integration.
    I am using the wsdl http://<<ip>>:<<port>>/xmlpserver/services/PublicReportService?WSDL for generating a report from RTF Template in ADF.
    We are using Oracle Business Intelligence Publisher Release 11g (11.1.1) and JDeveloper 11g (11.1.1.5.0).
    I have a couple of merge variables in my RTF template and I am passing these variable using Report Request parameters.
    below is code I added for creating the report request.
    First I created publicReportService using webservice proxy.
        public static ReportRequest getReportRequestFromBIPWithTemplate(String reportFolderOnBIP,
                                                            String reportName,
                                                            String outputFileFormat,
                                                            String template,
                                                            HashMap params) {
          String reportAbsolutePath = reportFolderOnBIP + "/" + reportName + ".xdo";
          ReportRequest repRequest = new ReportRequest();
          System.out.println("report path:  " + reportAbsolutePath);
          repRequest.setReportAbsolutePath(reportAbsolutePath);
          repRequest.setAttributeTemplate(template);
          repRequest.setAttributeFormat(outputFileFormat);
          repRequest.setAttributeLocale("en-US");
          repRequest.setSizeOfDataChunkDownload(-1);
          System.out.println(params.size());
          ParamNameValue[] paramNameValue = new ParamNameValue[params.size()];
          ArrayOfParamNameValue arrayOfparamNameValue = new ArrayOfParamNameValue();
          Set set = params.entrySet();
          Iterator iter = set.iterator();
          int i = 0;
          while (iter.hasNext()) {
            Map.Entry me = (Map.Entry)iter.next();
            System.out.println(i + "--->>>" + me.getKey() + " : " + me.getValue());
            paramNameValue[i] = new ParamNameValue();
            paramNameValue.setMultiValuesAllowed(false);
    ArrayOfString values = new ArrayOfString();
    if (me.getValue() == null) {
    values.getItem().add("");
    } else {
    values.getItem().add((me.getValue()).toString());
    paramNameValue[i].setValues(values);
    paramNameValue[i].setName((me.getKey()).toString());
    arrayOfparamNameValue.getItem().add(paramNameValue[i]);
    i++;
    repRequest.setParameterNameValues(arrayOfparamNameValue);
    return repRequest;
    I generated report response bytes using below code
    {code:java}
    repRes = publicReportService.runReport(repReq,userID,password);
    reportStream = repRes.getReportBytes();I could see the generated PDF but the supplied variables are NOT reflected in place of merge variables.
    Ex: In template
    Welcome, <<merge variable, userName>>
    {code}
    Generated PDF should have
    {code:java}
    Welcome, Hello World
    {code}
    Instead of the above I am getting
    {code:java}
    Welcome,
    {code}
    I am looking for a suggestion, Please help me in this regard.
    Thanks,
    Satya
    Edited by: 921138 on May 30, 2012 11:11 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Please let me know if any one has update for this.
    Thanks in advance,
    Satya

  • Been a bit stupid and deleted my calendar from ipad which deleted it from my iphone via icloud.  Is it gone forever?

    Once you delete something and then iCloud takes it off another device is that it gone?

    If you also synced to your computer, then try restoring from a backup.  Or try restoring from an itunes or icloud backup.

  • How to load a Jar file in the class path?

    How to load a Jar file which contains class files, images, etc.. in the classpath without using URLClassLoader.

    You don't "load" jars. If it's on the classpath, you can obtain individual resources from it using various methods on either Class or ClassLoader. Do you mean "how to add a jar to the classpath at runtime"? Can't be done without using a classloader, typically URLClassLoader or a subclass thereof. Why you want to not use the proven method is beyond me. Presumably because you don't understand classloading. In which case, forget it.

  • How to use classes in Actions tab

    Hello guys!
    I'm just a beginner so i'm sorry for my stupid question.I'm developing a game in which movie clips in our case people have their own schedule.I have multiple screens and so i want to be able to set their locations and make them invisible on other screens(rooms)they're not currently at.The trouble is i can't use variables from Actions in my class,neither can i use classes in my Actions.Can anyone tell me how to export classes into Actions code?
    Here is my code:
    var currentlocation;
    var currentscreen;
    if (person.currentlocation!==currentscreen){
    person.visible=false;
    btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
    function fl_MouseClickHandler(event:MouseEvent):void
              currentscreen = "classroom";
              classroom.visible = true;
              playroom.visible = false;
    btn_2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
              currentroom = "playroom";
              classroom.visible = false;
              playroom.visible = true;

    Your problem/question is not clear to me.  If you are getting errors you should include the error messages in your posting.
    Could the problem arise from using a variable that is not defined?
    currentroom = "playroom";
    I do not see currentroom defined as a variable anywhere.  There is a currentscene variable though.

  • Error When Using Class :(

    Hey,
    Class:
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        public class Main extends MovieClip
            public var enemyA:Array = [];
            public var birdA:Array = [];
            public var rowNum:int = 2;
            private var gap:int = 100;
            private var obj_no = 2;
            public var enemy1:mychar = new mychar();
            public var TheBird:BirdChar = new BirdChar();
            public function Main()
                // constructor code
                createEnemyF();
                createBirdF();
                this.addEventListener(Event.ENTER_FRAME,loopF);
            public function createEnemyF()
                for (var i:int = 0; i < rowNum; i++)
                    for (var j:int = 0; j < obj_no; j++)
                        enemy1.x = Math.random() * stage.stageWidth - enemy1.width;
                        enemy1.y = - i * (gap + enemy1.height) - 30.65;
                        enemyA.push(enemy1);
                        addChild(enemy1);
            public function createBirdF() {
                TheBird.x = 270.95;
                TheBird.y = 350.95;
                birdA.push(TheBird);
                addChild(TheBird);
            public function loopF(event:Event) {
                updateEnemyPositionsF();
                updateBirdPositionsF();
                hitTestF();
            public function updateEnemyPositionsF() {
                enemy1.y +=  2;
            public function updateBirdPositionsF() {
                TheBird.x = mouseX;
            public function hitTestF() {
                if(TheBird.hitTestObject(enemy1))
                    gotoAndPlay(5);
                    trace('The Bird Hit Enemy 1');
    This conflicts and causes this error:
    1046: Type was not found or was not a compile-time constant: MouseEvent
    ^ ^ Code repeats to all of my event listeners
    Thanks for your time.

    Thanks, i thought it might be this because of previous problems but i seen i already had : import flash.events.Event; so i thought that would be OK!
    Second Error:
    1180: Call to an undefined method Timer.
    I think this is the same sort of thing but what to import to fix this?
    So far these are my imports:
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.TimerEvent;
    Thanks for helping.
    Date: Thu, 3 Nov 2011 05:36:22 -0600
    From: [email protected]
    To: [email protected]
    Subject: Error When Using Class
        Re: Error When Using Class
        created by markerline in Flash Pro - General - View the full discussion
    Looks like you imported events.Event but not events.MouseEvent (or some similar syntax) basically you must import MouseEvents separately from other Events.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4005227#4005227
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4005227#4005227. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Flash Pro - General by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

Maybe you are looking for

  • Error 1003 when building executable

    Hi, I'm using Labview 2010 on Windows 7 and I'm getting an error when I try to build an executable: Error 1003 occurred at Open VI Reference in AB_Engine_EXE_Call_Write_Icons.vi->AB_EXE.lvclass:​Build.vi->AB_Build.lvclass:Build_from_Wizard.vi->A​B_UI

  • Thin grid lines in PDF export

    I am using the current version of Numbers (3.2). The problem I am facing is that it seems to be impossible to export a spreadsheet with invisible grid lines to a PDF. Every time I do so, thin (I guess 1px) grid lines appear in the PDF where the shoul

  • How to backup and Restore in 8.1.7 Database

    Hi, I wanted to have complete backup and restore of 8.1.7 database. how can i achieve this. The steps in Oracle Management Server and scripts for the same. Also, how can i backup and restore contents of an user of database which has tablespaces and s

  • Imac G3 233 starts up a few seconds  then power goes down

    Hello I have an imac G3 233 It has been working and i have just plugged it out for 6 months. Now i plugged it in today and it boots up . startup sounds comes ok and hd spins up. Power button is light up. After a few second the power goes down. And i

  • ADF BuessServices Layer With Toplink In Jdeveloper 11.1.1.3.0

    hi, i want to use Toplink / EJB as my BuessServices Layer, I can't get userfull help from google and orecle , Can you give me some sample /Demo or advice? thank you very much~