About different ClassLoader in Applet

I have made an application which can reload updated class dynamically..
for reloading class dynamically from file system, I can't help using URLClassLoader which is different from original ClassLoader.
When the application works in local JVM, the diffrenent class loaders didn't make any problem .. but, when the application works as Applet in web, class loaders make some problems....
for example,
Class A {
protected String name;
public String getName(Class B) { return name; }
Class B {
URLClassLoader classLoader;
public void showName(){
A aClass = classLoader.loadClass("A");
Method method = aClass.getClass().getMethod("getName", this.getClass()); ----> 1
String name = (String)Method.invoke(aClass, this);
the part of 1 generates error :: NoMethodError.
that is the reasion that Class A is loaded from default system class loader,
and Class B is loaded dynamically from URLClassLoader.
but, above code works well in local JVM, but when I execute as Applet in Web,
it generates NoMethodError...
Is there any persion telling me the answer?

This is just a guess, but maybe it's a security issue in the browser ?
Try changing the settings in IE: tools, internetoptions, security, custom level, java permissions: custom
Then, enable 'run unsigned content' and enable 'access to all networkaddresses'

Similar Messages

  • Loading an object using a different classloader

    I have 2 web-apps which share a common object. I want to store that
    common object in a common cache accessible to both web-apps. The problem
    is the 2 web-apps have a different classloader, so how do I return an
    object that was stored by web-app1 to be used with web-app2 without getting a ClassCastException
    -

    First question is whether the Web-Apps are on the same JVM - if you're using Tomcat, it is likely that they are. The next question is whether the Web-Apps' classloaders descend from a common parent classloader - again in Tomcat this is the case. If they do, then you should use the common parent classloader to instantiate the classes that need to be shared.
    To do this, you need to add the common classes to either the system classpath or to the classpath configured for your servlet/jsp engine. If the Web-Apps' classloaders are standard they will defer any requests initially to their parent classloader which will provide them with the same class definition and make it so that these classes can be shared between the Web-Apps.
    Now comes the nitty-gritty of implementation. The best way to share a common object is via a static instance in one of the classes loaded by the parent classloader, using the singleton pattern or the like.
    A trivial example would be if you wanted to hold a map of common (thread-safe) objects:public class Shared{
        private static java.util.HashMap sharedMap;
        static{
            // Thread safe, assuming all shared objects are initialised
            // in this static block.
            // If objects are to be created and placed in the
            // sharedMap later, use the synchronized map wrapping
            // methods from the Collections utility class.
            sharedMap = new java.util.HashMap();
            ... //instantiate and store the shared objecs here.
        public static Object getCommonObject(String key){
            return sharedMap.get(key);
    }As long as the Shared class comes from an ancestral classloader, both Web-Apps will see the same map of the same objects.
    Hope this helps,
    Bob B.

  • Plz tell me about  different types of derived classes used in Java program

    i wan't to learn about different types of derived classes used in Java programming

    cool down bro i am new here i don't how it works
    here.well i will try to be specific frm now on. thank
    anywaysIt's not about "how things work here". The same is true for anything in life. How do you expect anyone to give you an answer when you cannot give a clear description.
    You: "My car sorta ya know don't work. Canya sorta ya know fix it"
    Mechanic:"WTF?"

  • Alert Notification should be sent to each supervisor about different employ

    Hi Guys,
    i have develop Summary alert . Now i have created summary alert .
    This alert giving results empno, empname, supervisor, supervisor email .
    but Notification should be sent to each supervisor about different employee reporting to them.
    how can this requirement is possible. Please help any one.
    thanks,
    Ramu

    Dear Ramu,
    If you are using Message type Action, try keeping the Supervisor email in 'To' and Supervisor name variable out side the Summary template , and remaining all inside summary template. Then it will work in the way you wanted.
    Thanks
    Raj

  • Digital clock which randomly selects different colors from Applet

    Hi,
    I relatively new to java, what I'm trying to do is list about five colours in my Applet and pass the colours into my java code, and maybe the font.....
    I want to be able to Display a digital clock which randomly selects different colours which were passed from my Applet
    Thanks for any help
    Zip
    Clock Code:
    import java.awt.*;
    import java.applet.*;
    import java.util.*;
    import java.text.*;
    public class dclock extends Applet implements Runnable{
    Thread animThread = null;
    int delay = 1000;
    public void init(){}
    public void paint (Graphics g){
    // get the time
    Calendar cal = Calendar.getInstance();
    Date date = cal.getTime();
    // format it and display it
    DateFormat dateFormatter =DateFormat.getTimeInstance();
    g.drawString(dateFormatter.format(date), 5, 10);
    public void start(){
    if(animThread == null){
    animThread = new Thread(this,"Animation");
    animThread.start();
    public void stop(){animThread = null;}
    public void run(){
    while(animThread !=null){
    try{ Thread.sleep(delay);}
    catch(InterruptedException e){};
    repaint();
    //sec++;
    }

    Why doesn't the clock just decide what colour it is going to be? If you need to pass the colour choices in, just let the clock accept a collection of colours in its constructor or something. I don't understand what bit of this you are having problems with as you haven't really explained. Please also use code tags.

  • Casting to an abstract class from a different classloader

    I have a class Special that extends an abstract class Base. In my code I use a URLClassLoader to load the class Special and I then want to cast Special to Base. If I do this I get a ClassCastException because the classes are loaded from different classloaders. I can't have the URLClassLoader and the class that performs the cast extend a parent ClassLoader that knows about the Base class. What I want to be able to do is something like this:
    URLClassLoader loader = new URLClassLoader(codebase, null);
    Class baseClass = loader.loadClass(className);
    Base baseObj = (Base)baseClass.newInstance();
    I have seen some post that suggest I can achieve this using Reflection but I am not sure how to go about this. Any help would be appreciated.
    Thanks
    Jim.

    Thanks for your help so far but I still can't do the casting, consider this example:
    //Base.java
    package classTest;
    public interface Base
         public abstract void execute();
    //ConcBase.java
    package classTest;
    public class ConcBase implements Base
         public void execute()
              System.out.println("execute in ConcBase called");
    I compile these files and jar them into work.jar
    I now have my application:
    //Test.java
    import java.net.*;
    import java.io.*;
    import classTest.*;
    public class Test
    public static void main(String[] args)
              Test t = new Test();
              t.test();
         public void test()
              try
                   File file = new File("D:/Projects/classloadTest/work.jar");
                   URL[] codebase = {file.toURL()};
                   ClassLoader ccl = getClass().getClassLoader();
                   ccl.loadClass("classTest.Base");
                   URLClassLoader ucl = new URLClassLoader(codebase,ccl);
                   Class conClass = ucl.loadClass("classTest.ConcBase");
                   classTest.Base b = (classTest.Base)conClass.newInstance();
                   b.execute();
              catch(Exception t)
                   System.out.println("thowable caught");
                   t.printStackTrace(System.out);
    I compile this and run it with this command:
    java -classpath D:\Projects\classloadTest\work.jar;. Test
    This runs as I would expect, however I have set the parent class loader of my custom URLClassLoader to the one that does the cast, this means that Base and ConcBase are both being picked up by the application class loader as my custom class loader delegates to its parent. This is the current behaviour I have in my proper application and it is causing problems, I don't want the class that implements Base to delegate to any class on the main applications classpath. If I change the line:
    URLClassLoader ucl = new URLClassLoader(codebase,ccl);
    In Test.java to:
    URLClassLoader ucl = new URLClassLoader(codebase,null);
    I get a ClassCastException, this is because the class that does the cast (Test) loads Base from it's classpath and ConcBase is loaded from the URLClassLoader. After spending more time looking at this problem I don't think there is anyway to resolve but if anyone thinks there is please tell me.
    Many thanks
    Jim.

  • I need info about Oracle classloading

    Please tell me where I can find out about Oracle app server classloading. I have done document searches on the Oracle and Orion sites. Thanks.

    repost

  • OSD: different pxe, question about different wim-files

    Hi,
    Please see this question, I'm somewhat confused about the different
    wim files.
    I can see the default winpe.wim and a different wim next to it which has name winpe then environment then number (winpe.sccm0022.wim), what is this file.
    And, like in my post, why can't I use this image to import into a pxe and boot from that?
    Please advise.
    J.
    Jan Hoedt

    Hi,
    What is your goal with this? boot to SCCM and do OS deployment or what is your purpose? when dowloading the boot .wim file from a DP parameters are passed along like MP and so on. So you cannot use that .WIM file and pxe-boot from another PXE solution and
    do OSD from ConfigMgr.
    That is why Johan's unsupported solution would be the way to try it.
    http://www.deployvista.com/Blog/JohanArwidmark/tabid/78/EntryID/54/language/en-US/Default.aspx
    regards,
    Jörgen
    -- My System Center blog ccmexec.com -- Twitter
    @ccmexec

  • Basic Question about Different Platforms & their Versions

    Hi Experts!!
    Can any one help me to understand.
    Q 1 : What all are the Different Platforms to design apps for SAP?
    Q 2 : What make them different with each other?
    Q 3 : What are the Different version available in market?
    Q 4 : What is the best among all to start with for a New Learner?
    Regards
    Devraj

    I am assuming you are talking about MOBILITY platform? right ?
    You must check this discussion Where to start for Developing Mobile Apps

  • Custom classloader in Applet?

    Hi
    I have for some time tried to load an Applet from within an Applet by means of custom classloader.
    However when reading various specifications for classloader they state it is not possible for an Applet to do so.
    Does anyone know otherwise?

    Hi
    To be more specific.. I have 2 Applets yes. In the first signed Applet I run as a jar I have created a custom classloader that extends ClassLoader hence the java bytecode I wish to load (also an Applet) must be (a) class file(s). As far as I know the ClassLoader is not able to define classes from jars right?
    It is only the loading Applet that is packed as a jar and there is no nested jars. However the loaded Applet is now loaded as a class file but I would like to load is a jar for speeding up loading time.
    Quote from http://www.javaworld.com/javaworld/jw-10-1996/jw-10-indepth.html:
    There is a cost, however, because the class loader is so powerful (for example, it can replace java.lang.Object with its own version), Java classes like applets are not allowed to instantiate their own loaders. (This is enforced by the class loader, by the way.) This column will not be useful if you are trying to do this stuff with an applet, only with an application running from the trusted class repository (such as local files).

  • Different things on Applets and Servlets

    I use Eclipse. I create two projects: applet and servlet (deploy on Tomcat). One is with the function main, the other has doGet. In these functions I write the same string:
    Mac.getInstance("HmacSHA1");
    But when I run applet - it's ok, when I deploy servlet and run on Tomcat - there are exception: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
    How to make it availible at servlet?
    Message was edited by:
    AntonVatchenko

    The 2 apps (applet versus servlet) are likely using different versions of the Java runtime (and / or security extensions to them). And on one version that security algorithm exists (is built-in, or added as an extension in your JRE's lib/ext folder or something like that); while on the other the algorithm does not exist.
    Make the J2EE container (the one running the servlet) use the same version of Java as the applet is. I suppose that's just a hint though, that your next question will be something like "Ok, how do I do that?". My job was just to point you in the right direction. Hopefully I've done that.

  • Confused about different calendars

    I have a Macbook Pro, an iPhone 5, and an original iPad.
    I am confused about the purpose of the different Calendars: Home, Calendar, iCloud, and Calendar([email protected]).
    Also listings on my iPad "Show Calendars" : From My Mac, cal.me.com, and [email protected]
    I am retired and have no work commitments so I just need one calendar that I can access and put events in from all 3 devices and can see them on all 3 devices.
    I find that if I put events in from my Macbook, they show up on both ioS devices, but if I put an event in on my iPad, it does not show up on my Macbook regardless on which Calendar I enter it on.
    Is there somewhere I can find in simple terms which calendar I can use on all 3 devices and delete the others?
    Thank you.

    Hi,
    Macworld has a great article on multiple apple ID's and imatch.   Here's the link: hope it helps.
    http://www.macworld.com/article/163013/2011/10/all_about_icloud_common_signup_sc enarios.html
    It runs through a whole bunch of multiple ID's & set-up scenarios.
    Cheers,

  • Confused about different glitches on different players

    I am making a bunch of DVDs to go out to festivals and friends and I have been really confused with the way the dvds I have made act differently on different players.
    I just played the dvd on my mac through Mac's DVD player and I had to press menu in order for the dvd to begin while when I played it on a regular dvd player it started up right away. On the other hand, on the regular player, my first menu freezes up after a few seconds and I have to restart the dvd every time. It doesn't do this on any of the other menus, just the main one. When I played the dvd on my computer, there is no problem with the first menu freezing.
    Can anyone help? I need these dvds to play without confusion when I am submitting them to festivals and programmers who don't have the time or patience to deal with little glitches like this and will just skip over my film if something weird happens. Thanks.

    Forget about what I was writing - I got an old version of the program which did not write a UTF-8-File. Doing so
    solved the problem as expected.

  • Another one question about how to download applet (not using external tool)

    Hi
    i write tool for downloading applet on card. I use apdu trace from NXP eclipse plugin as source of information and i read also about cap-file format in Java Card Virtual Machine specification. And i have questions about data transferred by LOAD command.
    As example - from apdu trace i see that transferred data are "C4820E33 DATA1 DATA2". Full length of transferred data is 0x2EE2.
    C4 - OK, this is "Load File Data Block" tag as specified in Global Platform
    820E33 - OK, this length of tag, =0x0E33
    DATA1 - sequence of cap-file components: Header.cap, Directory.cap, Import.cap, Applet.cap, Class.cap, Method.cap, StaticField.cap, ConstantPool.cap, RefLocation.cap. Length of DATA1 is 0x0E33, i.e. DATA1 = 'C4'-tag value.
    DATA2 - sequence of two cap-file components: Descriptor.cap and Debug.cap. These components are out of 'C4'-tag.
    the questions mentioned above... here they are:
    1. Global Platform does not define any data in LOAD command except 'E2' and 'C4' tag. Why DATA2 is transferred out of any tags?
    2. Whether the sequence of cap-file components is important? i.e. Can i load Header.cap, Directory.cap etc. in other order than i see in DATA1 field from apdu-trace?
    3. Debug.cap seems to be optional component. And what about Descriptor.cap component? Need i load it on card?

    666 wrote:
    1. Global Platform does not define any data in LOAD command except 'E2' and 'C4' tag. Why DATA2 is transferred out of any tags?Because the components are either optional or only required when communicating with a JCRE that has debugging capabilities. I assume you ran the project in JCOP Tools in debug mode against the simulator? If you did this against a real card it would fail as it does not have an instrumented JCRE capable of debugging code. You could try running the project as opposed to debugging to see the difference.
    2. Whether the sequence of cap-file components is important? i.e. Can i load Header.cap, Directory.cap etc. in other order than i see in DATA1 field from apdu-trace?Yes it is. It is defined in the JCVM specification available from the Oracle website.
    3. Debug.cap seems to be optional component. And what about Descriptor.cap component? Need i load it on card?No, it is optional and is not referenced by any other CAP file component.
    Cheers,
    Shane

  • Any ideas about paraneters in 2 Applets

    Have somebody idea about this.....
    I have two applets in browser. But another applet should start when I do something in the first one. I'm using jsp.
    Is it possible just to get parameter from the first applet and just use <% if param....start next applet %> ?
    Maybe somebody knows better idea ?
    Thanks!

    First,
    write a javascript function able to launch an applet on your page.
    something like:
    <script>
    function myfunction{
    write "<applet code=myclass></applet>" ;
    </script>
    next,
    in your main applet, use the package netscape.javascript
    import netscape.javascript.*;
    class myclass{
    public static void executeJS( Applet applet, String command, String argument){
              JSObject javaScript = new JSObject() ;
              try { javaScript = JSObject.getWindow( applet); }
              catch(JSException e){}
              try {
                   javaScript.eval( command + "( \"" + argument + "\");");
              catch (Exception e) { }
    The parameter Applet applet can be given by "this" or by an "getAppletContext()".
    String command is the name of your JAVASCRIPT function (here myfunction)
    Let me know...
    By the way, if you are working on Visual J++ no problem, otherwise, you'll have to download the package:
    you'll find it in the netscape or sun site...

Maybe you are looking for