Dynamically Loading .jar into the AppletClassLoader of Signed Applet

First of all, I thank you for reading this post. I will do everything I can to be concise, as I know you have things to do. If you're really busy, I summarize my question at the bottom of this post.
My goal:
1.) User opens applet page. As quickly as possible, he sees the "accept certificate" dialog.
2.) Applet gets OS vendor, and downloads native libraries (.dll for windows, etc.) and saves them in user.home/ my new dir: .taifDDR
3.) Calls are made to System.load(the downloaded .dlls) to get the natives available.
4.) Applet downloads the .jar files that we stripped so that the applet was smaller, one by one
5.) For each .jar downloaded, it goes through the entries, decodes the .class files, and shoves them onto the AppletClassLoader.
6.) Finally, the looping drawmation of the applet is linked to a subclass, that now has everything it needs to do what it wants.
I have gotten all the way to step 5!!! It was amazing!
But now I'm stuck on step 5. I can download the .jar files, read them, even decode the classes!
As evidence, I had it print out random Methods using reflection on the created classes:
public net.java.games.input.Component$Identifier net.java.games.input.AbstractComponent.getIdentifier()
public final void net.java.games.input.AbstractController.setEventQueueSize(int)
public java.lang.String net.java.games.input.Component$Identifier.toString()
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
... many many more So, its frustrating! I have the Class objects! But, whenever the applet begins to try to, say instantiate a new ControllerEnvironment (jinput library), it says ClassNotFoundException, because even though I made those Classes, they aren't linked to the system classLoader!
Here is how I am loading the classes from the jar and attempting to shove them on the appletclassloader:
ClassLoader load = null;
try {
     load = new AllPermissionsClassLoader(new URL[]{new File(url).toURL()});
} catch (MalformedURLException e2) {
     e2.printStackTrace();
final JarFile ajar = new JarFile(url);
... we iterate over the elements (trust me, this part works)
String name = entry.getName();
if (name.endsWith(".class")) {
     name = name.substring(0, name.length() - 6);
     name = name.replace('/', '.');
          Class g = load.loadClass(name);
public class AllPermissionsClassLoader extends URLClassLoader {
    public AllPermissionsClassLoader (URL[] urls) {
        super(urls);
    public AllPermissionsClassLoader (URL[] urls, ClassLoader parent) {
        super(urls, parent);
        System.out.println(parent);
    public AllPermissionsClassLoader (URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
        super(urls, parent, factory);
    protected PermissionCollection getPermissions (CodeSource codesource) {
        Permissions permissions = new Permissions();
        permissions.add(new AllPermission());
        return permissions;
}so, my assumption here is that if I create a new AllPermissionsClassLoader and then call loadClass, the loaded class (because it does return a valid Class object) is usable globally across my applet. If this is not true, how should I else be doing this? Thank you for Any advice you could offer!

I know it's two years ago but the OP's approach seems pointless to me.
4.) Applet downloads the .jar files that we stripped so that the applet was smaller, one by oneWhy? Just name the JAR files in the CLASSPATH attribute of the <applet> tag. Then what you describe in (5) and (6) happens automatically on demand.
protected PermissionCollection getPermissions (CodeSource codesource) {Who does he think is going to call that?

Similar Messages

  • How to dynamically load jar files - limiting scope to that thread

    Dynamically loading jar files has been discussed a lot. I have read a quite a few posts, articles, and demo code for doing just that. However, I have yet to find a solution to my problem. Most people modify their system class loader and are happy. I have done that and was happy for a time. Occasionally, you will see reference to an application server or tomcat or some other large project that have successfully been able to load and unload jar files, allow for dynamic deployment of code, etc. However, I have not been able to achieve similar success; And my problem is much less complicated.
    I have an application that executes a thread to send a given file/message to a standard JMS Server Queue. Depending on the parameters selected by the user, this thread may need to communicate with one of a number of JMS Servers, ie. JBoss, WebLogic, EAServer, Glassfish, etc. All of which can be done with the same code, but each needs to load their own flavor of JMS Client Jar files. In this instance, spawning a separate JVM for each communication would work from a classloader perspective. However, I need to keep it in the family and run under the same JVM, albeit each JMS Server Connection will be created and maintained in separate Threads.
    I am close, I am doing the following...
    1. Creating a new URLClassLoader in the run() method of each thread.
    2. Set this threads contextClassLoader to the new URLClassLoader.
    3. Load the javax.jms.JMSException class with the URLClassLoader.loadClass() method.
    4. Create an initialContext object within this thread.
    Note: I read that the initialContext and subsequent conext lookup calls would use the Thread�s
    contextClassLoader for finding/loading classes.
    5. Perform context.lookup calls for a connectionFactory and Queue name.
    6. Create JMS Connection, etc. Send Message.
    Most of this seems to work. However, I am still getting a NoClassDefFoundError exception for the javax.jms.JMSException class ( Note step #3 - tried to cure unsuccessfully).
    If I include one of the JMS Client jar files ( ie wljmsclient.jar for weblogic ) in the classpath then it works for all the different JMS Servers, but I do not have confidence that each of the providers implemented these classes that now resolve the same way. It may work for now, but, I believe I am just lucky.
    Can anyone shine some light on this for me and all the others who have wanted to dynamically load classes/jar files on a per Thread basis?

    Thanks to everyone - I got it working!
    First, BenSchulz' s dumpClassLoader() method helped me to visualize the classLoader hierarchy. I am still not completely sure I understand why my initial class was always found by the systemClassLoader, but knowning that - was the step I needed to find the solution.
    Second, kdgregory suggested that I use a "glue class". I thought that I already was using a "glue class" because I did not have any JMSClient specific classes exposed to the rest of the application. They were all handled by my QueueAdmin class. However...
    The real problem turned out to be that my two isolating classes (the parent "MessageSender", and the child "QueueAdmin") were contained within the same jar file that was included in the classpath. This meant that no matter what I did the classes were loaded by the systemClassLoader. Isolating them in classes was just the first step. I had to remove them from my jar file and create another jar file just for those JMSClient specific classes. Then this jar file was only included int custom classLoader that I created when I wanted to instantiate a JMSClient session.
    I had to create an interface in the primary jar file that could be loaded by the systemClassLoader to provide the stubs for the individual methods that I needed to call in the MessageSender/QueueAdmin Classes. These JMSClient specific classes had to implement the interface so as to provide a relationship between the systemClassLoader classes and the custom classLoader classes.
    Finally, when I loaded and instantiated the JMSClient specific classes with the custom classLoader I had to cast them to the interface class in order to make the method calls necessary to send the messages to the individual JMS Servers.
    psuedu code/concept ....
    Primary Jar File   -  Included in ClassPath                                                      
    Class<?> cls = ClassLoader.loadClass( "JMSClient.MessageSender" )
    JMSClientInterface jmsClient = (JMSClientInterface) cls.newInstance()                            
    jmsClient.sendMessage()                                                                      
    JMSClient Jar File  -  Loaded by Custom ClassLoader Only
    MessageSender impliments Primary.JMSClientInterface{
        sendMessage() {
            Class<?> cls=ClassLoader.loadClass( "JMSClient.QueueAdmin" )
            QueueAdmin queueAdmin=(QueueAdmin) cls.newInstance()
            queueAdmin.JMSClientSpecificMethod()
        }

  • How to dynamically load images into Flash

    I have a movie clip on the stage that I want to dynamically
    load images into (that constantly change), how would I go about
    doing this? Thanks.

    Use the Loader class to load in images.
    Then use addChild to add the Loader class into your MovieClip
    on the stage.
    As far as &amp;quot;constantly change&amp;quot; what
    do you mean by that? You could use setInterval, ther enterFrame
    event, or any other means to trigger a new image to be loaded into
    the Loader instance.
    Finally, you can use the Tween class to create some nice
    effects for the images (fade it, blur in, photo blend, masks,
    etc)

  • Dynamically loading jar files

    Hi
    In my application I need to dynamically create objects of types specified by string which is passed as parameter. I am able to do this if the class is inside the same jar. But I need to load the class from any jar name specified. How do i go about doing this? Is there a way to dynamically loading jar files?

    It's easy. You use [url http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLClassLoader.html]URLClassLoader:String jarPath = ...;
    String className = ...;
    URLClassLoader ucl = new URLClassLoader(new URL[] { new File(jarPath).toURL() });
    Class cls = Class.forName(className, true, ucl);
    ...Regards

  • Dynamically adding jars to the classpath at runtime

    Hi All,
    I have a query regarding dynamically loading jars at runtime. I am developing an application that uses third party jars and there are a number of different versions that the utility is to support so I want to be able to load the jars relating to that specific version through selection on the gui. The jar files are the same name for all versions e.g.
    v1 has app1.jar
    and v2 has app2.jar
    I have these in separate folders called app1jars and app2jars. I have tried a number of classloader examples but always get a classnotfoundException. Any ideas? Thanks in advance for replies

    Hi,
    Sorry for being a bit vague. I have attached the code below that I was trying. Im confused about how to load the classes within each of the jars and use them do i have to use defineclass? AppSession is an interface.
    import java.util.*;
    import java.net.*;
    import java.sql.*;
    import com.app.AppSession;
    import com.app.AppWorker;
    import java.io.*;
    import java.lang.reflect.Method;
    public class JarTest {
        public static File[] getExternalJars()
        { String jarDirectory = "C:\\JarLoaderTest\\1.1jars";
          File jardir = new File(jarDirectory);
          File[] jarFiles = jardir.listFiles();
          return jarFiles;
        public static void main(String[] args) throws Exception {
         Method addURL = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] {URL.class});
            addURL.setAccessible(true);
         File[] files = getExternalJars();
            ClassLoader cl = ClassLoader.getSystemClassLoader();
         for (int i = 0; i < files.length; i++) {
         URL url = files.toURL();
    System.out.println(url.toString());
         addURL.invoke(cl, new Object[] { url });
    cl.loadClass("AppSession").newInstance();
    cl.loadClass("AppWorker").newInstance();
    try
    { AppSession session = AppWorker.getConnection(username,password,port,server); // these are filled in with the actual details in my program
    catch(Exception e)

  • [svn:fx-trunk] 7796: get the correct locales of batik and xerces jars into the build

    Revision: 7796
    Author:   [email protected]
    Date:     2009-06-12 13:01:48 -0700 (Fri, 12 Jun 2009)
    Log Message:
    get the correct locales of batik and xerces jars into the build
    bug: https://bugs.adobe.com/jira/browse/SDK-21565
    qa: i18n team (make sure they're all there)
    checkintests: pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-21565
    Modified Paths:
        flex/sdk/trunk/build.xml

    Originally posted by: rosec.messagingdirect.com
    I'll look into it; I'm a bit under the gun here and can't easily upend
    my development environment at this time, but hopefully I can look into
    it early next week. Thanks for the pointer.
    Daniel Megert wrote:
    > Chris Rose wrote:
    >> I don't know if this has been asked before (and you'd be amazed at how
    >> hard it is to find specific information when your search query is
    >> "eclipse 100% cpu usage opening class files in a jar"!) but, well,
    >> that's what I'm getting:
    >>
    >> When I open a class file in the editor that is contained in a jar file
    >> anywhere on a Java project's classpath, one of my processor pegs at
    >> 100% usage for anywhere from 15-120 seconds and eclipse becomes
    >> non-responsive for that period of time, not even redrawing the UI.
    >>
    >> This occurs for jars as large as the jboss client jar and the weblogic
    >> 80Mb uber-jar and for jars as small as a 241kb library jar.
    >>
    >> Is there anything I can do to track down WHY this is happening? I end
    >> up having to trace into third party code a lot while debugging
    >> container behaviour and this plays merry havoc with the timeouts for
    >> remote calls, so I'm quite motivated to suss out why it's happening.
    >>
    >> Eclipse details are attached.
    > There was a bug regarding big JARs on the build path. Can you try
    > whether this still happens using 3.4 M7. If so, please file a bug report
    > with steps to reproduce. Also, please create some stack dumps while
    > waiting and attach them to the bug report.
    >
    > Dani
    Chris Rose
    Developer Planet Consulting Group
    (780) 577-8433
    [email protected]

  • How do you load products into the catalog?

    Instead of using the automatic or manual load processes by hand for the product catalog, we would like to have a batch program written where it will automatically load products into the specific levels of the catalog.  Does anyone know if there is a standard program in CRM to accomplish this?
    Thanks,
    Darcie

    Hi Darcie,
    No, as far as I know there's no load standard load program for CRM product catalog data. We're on v4.0, so I can't say what's been added in later releases.
    Anyway, if you write your own, have a look at package COM_PRDCAT_WEB_API which contains lots of goodie function modules you can use to manipulate product catalog data.
    Dont forget
    CALL FUNCTION 'COM_PRDCAT_TRANSACTION_BEGIN'
    at the start and
    CALL FUNCTION 'COM_PRDCAT_TRANSACTION_COMMIT'
    at the end.
    There's also package COM_PRDCAT, but when we tried to do stuff with FMs in this package we ran into errors since some global variables were undefined.
    Hope this helps.
    Regards,
    Rasmus

  • Javascript Question - How to Insert a Dynamic/Current Date into the Footer of a Scanned Document

    Hi!
    I am looking for help in finding a Javascript that would allow the insertion of a dynamic/current date into the footer of a scanned document at the time the document is printed.
    I am currently using Adobe Acrobat Professional 8.0 at my work and there has arisen a need to have a dynamic/current date in the footer on scanned documents when they are printed out on different days by different people.
    I am new to the Forum and I am also very new to Javascript and what this entails.
    Thank you in advance for your help and input!
    Tracy

    this.addWatermarkFromText({
    cText: util.printd("mmmm dd, yyyy", new Date()),
    nTextAlign: app.constants.align.right,
    nHorizAlign: app.constants.align.right,
    nVertAlign: app.constants.align.bottom,
    nHorizValue: -72, nVertValue: 72
    Will insert the current Monday/Day/Year as a text watermark at the bottom of every page of a document, 1 inch up and 1 inch in from the right corner.

  • Errors "Load tModels into the registry" option & publishing proxy services

    Hi,
    I'm making a study with BEA Aqualogic Service Bus and BEA Aqualogic Service Registry.
    Reading official documentation (Console Help), I added with the BEA ALSB Console two registries. But during the configuration it doesn't allow me to set the *"Load tModels into the registry"* option, in fact when I click "Save" I get this error:
    *"Permission to generate key uddi:bea.com:servicebus:servicetype denied".*
    However I added two registries without setting this option.
    Now, when I want to publish a proxy service (in any registry), following the official procedure, I get this error:
    *"The publish completed with error. One or more services can't be published correctly, please see the detailed error messages in the summary table".*
    *"CannotCreate The key uddi:bea.com:servicebus:properties does not represent a valid taxonomy!"*
    I don't think it's all right! :)
    Someone can help me?

    Thank you for your help (even though you didn't know you were helping). I am also studying ALSB and ALSR, and I had the same problem when I tried to publish a proxy service ("... does not represent a valid taxonomy"). Based on your experience, I updated my registry in ALSB and checked "Load tModels". This was successful. I then published my proxy service and this too was successful.
    So the help you've given me was to suggest that publishing proxy services cannot be done unless the BEA tModels are first loaded into the registry.
    This means that your real problem is that you can't load the tModels. To do this, I suggest that the user ID you give when you're setting up the registry in ALSB must be an administrative user. When you installed the ALSR, an administrative account was created. Try giving this account information to the ALSB.
    If you don't want to give the administrative ID and password, you must set up an account in ALSR that has the ability to create tModels. In the ALSR's console page (probably at http://localhost:7001/registry/uddi/web), look at the administrative account's permissions (you'll find it on the "Manage" tab, under "Permissions"--you won't see the "Manage" tab unless you log in as an administrator). In my system, the administrator account has four permissions; I would guess that the one you need is "org.systinet.uddi.security.permission.ConfigurationManagerPermission".

  • What can I do to get back to a point that I can directly purchase Apps from my itouch via wi-fi. I was able to before I purchased an app on my PC and loaded it into the device via the sync cable.

    What can I do to get back to a point that I can directly purchase Apps from my itouch via wi-fi. I was able to before I purchased an app on my PC and loaded it into the device via the sync cable. My itouch 2G was bought 2nd hand, so when trying to get Apple support I was unable to register my device because I didn't know it's original purchase date. Note: I am still able to download the apps to my computer and load/sync them into the device.

    Why can you not buy from the ipod?
    What happens when you try?
    Error message?
    What does it say?
    Any info?

  • Limitations of trial version 13? I cannot load pictures into the photomerge panorama window either from' browse' or 'add open files'.

    On Adobe's web site it states the trial version has all functionality.  FAQ, common questions & answers | Adobe Photoshop Elements 13 "These trial versions are fully functional, so every feature and aspect of the product is available for you to test-drive. Product trials can easily be converted for unrestricted use without the necessity to reinstall the software in most cases."
    However, I cannot load pictures into the photomerge panorama window either from' browse' or 'add open files'. When I select either way nothing happens.This happens if I enter panorama from photo editor and/or organizer.
    Can anybody enlighten me about this?
    Thanks,
    Barry

    It seems your Samba is denying access to these files & dirs. My best guess would be that either the Samba user is not allowed to write (and read) those (in which case you'd have to modify the permissions accordingly) or Samba sets, when the share is mounted, the permissions such that your user is not allowed to read and write (you may in this case try to just set permissions for you to allow you what you want to do; or use "create mask" or "directory mask" or "writable" in your samba config. ).
    Also, what do the logs say about this? According to your samba conf they are in /var/log/samba/%m.log where %m is the hostname or IP.

  • How to convert trailing minus sign into the leading minus sign

    Hi
    Can any plz tell me How to convert trailing minus sign into the leading minus sign? I mean in PI the amount filed shows like 150.00- i want to convert that into -150.00.
    Thanks
    Govinda

    Hi Shabarish,
    The code works but what if the input is something like [   10.000-] i.e. with some spaces before 10.000- and the output as per your code comes as [-     10.000]. How do we tackle such cases if there is inconsistency in data i.e. some values come as [    10.000-] i.e. spaces before the number and some values as [12.000-].
    The output of this will come as
    [-    10.000]
    [-12.000]
    How to make it as
    [-10.000]
    [-12.000]
    Regards,
    Shaibayan

  • Steps for loading data into the infocube in BI7, with dso in between

    Dear All,
    I am loading data into the infocube in BI7, with dso in between. By data flow looks like....
    Top to bottom:
    InfoCube (Customized)
    Transformation
    DSO (Customized)
    Transformation
    DataSource (Customized).
    The mapping and everything else looks fine and data is also seen in the cube on the FULL Load.
    But due to some minor error (i guess), i am unable to see the DELTA data in DSO, although it is loaded in DataSource through process chains.
    Kindly advise me, where did i miss.
    OR .. Step by step instructions for loading data into the infocube in BI7, with dso in between would be really helpful.
    Regards,

    Hi,
    my first impulse would be to check if the DSO is set to "direct update". In this case there is no Delta possible, because the Change log is not maintained.
    My second thought would be to check the DTP moving data between the DSO and the target cube. If this is set to full, you will not get a delta. It is only possible to create one DTP. So if you created one in FULL mode you can't switch to Delta. Just create the DTP in Delta mode.
    Hope this helps.
    Kind regards,
    Jürgen

  • My ipod nano 6th gen. is connected to my MacBook.  I have an audio book on the MacBook in Itunes, and cannot load it into the Ipod.  What am I doing wrong?

    My ipod nano 6th gen. is connected to my MacBook.  I have an audio book on the MacBook in Itunes, and cannot load it into the Ipod.  What am I doing wrong?

    Is this audiobook configured to sync to your iPod via it's Books configuration pane in iTunes?  Click on your iPod's device name under Devices in the left hand pane of iTunes.  This will bring you to the Summary tab.  Look for the Books tab along the top and click on it.
    B-rock

  • Dynamically load jar file

    Hi,
    I've got an applet (used in a website) which must internally load a jar (the jarname and mainclassname are stored in the database).
    with a lot of jars (more than 10) and slow-internet users of my applet, it is not an option to add all the jars to the archive-parameter within the applet:
    <APPLET
         CODE="my.mainClass.class"
         width="800"
         height="600"
         archive = "MyMainJar.jar,someOther.jar, another.jar, andAgain.jar, lastExample.jar"
         codebase="/javaclasses"
    >
    So, adding all the jars is not an option, because if a class of the last jar (in this example: lastExample.jar) is needed, all the other jars must be loaded first.
    I have tried it with a classloader, to load the jar, but i've got an AccessControlException:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkCreateClassLoader(Unknown Source)
         at java.lang.ClassLoader.<init>(Unknown Source)
    The question is: how can I dynamically (in an applet) open a jar, and create an instance of a class in that jar?
    I searched the internet, but google can't help me out.
    Regards,
    Thijs

    It shouldn't be that difficult; all the stuff you need to build jars is in java.util.jar.*.
    Essentially it's back to combining the jars you need into one big one, give a different name to each of the different combinations you might need. You'd probably have the composite jars stored, but when one was requested it would check the dates of the component jars and rebuild if needed.

Maybe you are looking for

  • Can't get networkmanager working with openvpn (using static key)

    I'm trying to configure networkmanager to open up my VPN connection - using the static/preshared key method - but no dice.  (Although I'm able to connect just fine using openvpn from the command line)  Anyone been able to get this to work and/or have

  • Unable to open documents in body of email-

    Hello- I recently had my hard drive swipped and re-installed. I have had no problems in the past being able to open any microsoft products in the body of an email. (ie word, excel and ppt. I have the Office: MAC 2004 student/teacher edition. When I o

  • Assigning plant to controlling area

    Dear Gurus, Got this error message while doing Individual Purchase Order. " Your Plant is not assigned to controlling area" Here I have created controlling area and assigned to the company code but could not find where i have to assign it to a Plant?

  • Automator Script - How to Batch Convert PDF files to max 200x200px JPG Files

    I have tried several different Automator scripts and can't seem to get it right. Each day I have 25 different PDF files. I need to convert the first page of each PDF file to a max width and height of 200x200px jpg file (not jpeg). In automator, how d

  • Need example codes

    Hi, I cannot find any discussion forums on Forte C except here. Where can I get help? Is there any site has some example codes for Forte C/C++?