Help accessing methods in classes load with forName()

Hi all,
I am dynamically loading classes at runtime by using Class.forName() and .newInstance(). Is there any way I can access the methods of those classes after they are dynamically loaded? It doesnt seem that they are available for use.
Any help would be appreciated.
Ryan

To clarify, are you asking how to invoke a method on an Object without knowing its class? In any case you should use the reflection api that are avaliable.
Ex: cl = Class.forName(); Method[] methods = cl.getMethods(); for(int i = methods.length; i-- > 0;) System.out.println(methods[i-1].getName());
or
methods[i-1].invoke(cl.newInstance(), new Object[]{});

Similar Messages

  • Dynamic class loading with Webstart

    Hello !
    //within the jar-file at the webstart-directory
    public interface MyFrame{
    public void createFrame();
    //within the jar-file dynamically downloaded
    public class MyExtFrame extends JFrame implements MyFrame{
    String className = "MyExtFrame";
    ClassLoader cl = ClassLoader.getSystemClassLoader();
    JarClassLoader jarLoader = new JarClassLoader (cl, jarFile));
    /* Load the class from the jar file and resolve it. */
    Class c = jarLoader.loadClass (className, true);
    /* Create an instance of the class.
    Object o = c.newInstance();
    /* Are we using a class we specifically know about? */
    if (o instanceof MyFrame){
    // Yep, lets call a method we know about. */
    MyFrame client=(MyFrame) o;
    //call a class-method (here creates the whole gui-object at once)
    client.createFrame();
    This is the code i'm using and i've encountered following problem, if i put this code into an application without webstart, anything works fine, but with webstart i'll get a: java.lang.NoClassDefFoundError
    Then i've put the MyFrame-classes into the downloaded jar-file, but this won't work either, i'll get a ClassCastException.
    What do i have to do, to become it working ?
    Thanks for any conclusions and help.
    Michael

    Finally i've found out myself, i've read some postings in this forum and put them all together, so that my webstart-application finally works the way i want...
    That was the topic:
    Downloading a jar-file and starting a class from this jar-file within a webstart application (dynamic class loading).
    I'll post my final solution for this problem, may be it would be useful in future for anyone else.
    //grant all permissions on the clientside
    Policy.setPolicy( new Policy() {
    public PermissionCollection getPermissions(CodeSource codesource) {
    Permissions perms = new Permissions();
    perms.add(new AllPermission());
    return(perms);
    public void refresh(){
    //get the current classloader
    ClassLoader cl = MyLoadedClass.class.getClassLoader();
    //create a new url-classloader while using the current classloader
    URL[] urls = new URL[1];
    File f = new File(new String(jarName));
    urls[0] = f.toURL();
    URLClassLoader ul = new URLClassLoader(urls, cl);
    //load a class from jarfile
    Class c = ul.loadClass(new String(className));
    //get an object from loaded class
    Object o = c.newInstance();
    /* Are we using a class we specifically know about? */
    if (o instanceof KnownInterface){
    // Yep, lets call a method we know about. */
    KnownInterface client = (KnownInterface) o;
    client.doAnything();

  • How to recover from an exception on a class loaded with a classloader?

    I have created a classloader for the purpose of dynamically loading "modules" . The whole application is multithreaded and the separate modules may also run as separate threads. The problem that I am facing is that if one of the modules crashes (does not handle an exception), then the class loader object which loaded the required classes and started the module's thread, cannot be accessed. The thread which attempts to access this class loader freezes. Is there any way to recover from this situation?
    Thanks in advance

    Ok, let me provide a bit more information. Each "module" is handled by specific class (let's call it ModuleDescriptor), which subclasses the URLClassLoader class. The ModuleDescriptor class is responsible for describing each module, maintain module state information (loaded, unloaded, started, stopped, etc) and also executing some method calls on a specific object of the module, which in essence acts as a means to start or stop the module. Each module is a separate thread and is packaged in a JAR file, which is first downloaded locally. If one of these module threads crashes, then I cannot even call a method of the ModuleDescriptor to perform the necessary unloading bit. Basically, when I can the method that thread of execution halts without an exception or an error or anything. The rest of the application continues working properly (other threads). I find this situation bizarre, because the ModuleDescriptor object and the actual module with the thread that crashed execute on separate threads. If there is any more specific information that I have to provide, please let me know.

  • Dynamic Class Loading with interface

    Hello
    I would appreciate any help on the following problem.
    I need to load all classes in a particular directory and its subdirectories (top directory is known but not in the classpath) which implement a predefined interface. At the moment I am using a lot of reflection to accomplish this and believe it can be avoided somehow using the fact that I know these classes have to implement a predefined interface.
    At the moment, I am searching through the directory and subdirectory, loading all names of classes into a vector using a custom URLClassloader, and then load all classes in the vector into modulecontainers to populate a defaultmutabletree which is displayed on the gui.
    I'm sure that knowing the interface means there's a more straightforward way.
    Thanks in advance.

    Finally i've found out myself, i've read some postings in this forum and put them all together, so that my webstart-application finally works the way i want...
    That was the topic:
    Downloading a jar-file and starting a class from this jar-file within a webstart application (dynamic class loading).
    I'll post my final solution for this problem, may be it would be useful in future for anyone else.
    //grant all permissions on the clientside
    Policy.setPolicy( new Policy() {
    public PermissionCollection getPermissions(CodeSource codesource) {
    Permissions perms = new Permissions();
    perms.add(new AllPermission());
    return(perms);
    public void refresh(){
    //get the current classloader
    ClassLoader cl = MyLoadedClass.class.getClassLoader();
    //create a new url-classloader while using the current classloader
    URL[] urls = new URL[1];
    File f = new File(new String(jarName));
    urls[0] = f.toURL();
    URLClassLoader ul = new URLClassLoader(urls, cl);
    //load a class from jarfile
    Class c = ul.loadClass(new String(className));
    //get an object from loaded class
    Object o = c.newInstance();
    /* Are we using a class we specifically know about? */
    if (o instanceof KnownInterface){
    // Yep, lets call a method we know about. */
    KnownInterface client = (KnownInterface) o;
    client.doAnything();

  • Question  about dynamic class loading with thread built in

    Hi ,
    I am trying to load a class with a thread built in from the network.
    I write my network classloader, convert the class to a byte array and transmit over the network using socket. This step seems fine but when I tried to load the class at the receiver, some exception happens,"
    the reported exception is that :
    Exception in thread "Thread-2" java.lang.NoClassDefFoundError: SampleProject/Application$1
    my class name is "SampleProject . Application", the $1 I think it may refers to the thread built in the "Application".
    Could any one give me some hint for how to dynamic load such class file with thread built in over the network?
    Thank you!
    Best Regards,
    Song Guo

    Exception in thread "Thread-2"
    java.lang.NoClassDefFoundError:
    SampleProject/Application$1That means that the receiving end can't find an anonymous inner class which you have in the Application class. (The anonymous clas is given the synthetic name 1). Check your bin/classes folder you will have a class there with the name Application$1.class
    Kaj

  • Debug classes loaded with reflexion by a JVM launched normally

    Hi,
    I would like to debug some classes that are loaded with reflexion by an Eclipse plugin without starting the whole eclipse environnement in debug mode.
    Therefore is it possible to turn a JVM or a specific JVM thread in debug mode at excution time?
    or to load a class by reflexion in a debug mode?

    Sounds like you want to debug Eclipse - simply start it with the debugging switches, then use jdb to attach to it, and add some breakpoints to the classes that you are interested in. Alternatively, you can use some other lightweight debugger.
    This really isn't a JVM issue, and there should be a more suitable forum that deals with debugging.

  • Help accessing field inside class

    Hello,
    I got a problem when trying to access my textfields in my field class, here is what I'm doing:
    Fields.class
    public class Fields extends JFrame {
       public Fields() {}
       public Component emploField() {
       JTextField f_Name;
       JPanel f_Panel, main_Panel;
       f_Panel.setLayout( new GridLayout(8, 2 );
       main_Panel.setLayout( new GridLayout( 2, 1 ) );
       f_Name = new JTextField(20);
       f_Panel.add(f_Name);
       main_Panel.add( f_Panel );
       return main_Panel;
    }my main class
    displayGUI.class
    public class DisplayGui extends JFrame {
      protected Fields fild;
      protected JPanel panel;
      public DisplayGui() {
       fild = new Fields();
       panel = new JPanel();
       panel.add( field.emploField() );
       add(panel);
       setSize(300, 300 );
       show();
    }It's working perfect to display my fields, but if i try
    fild.emploField().f_Name.setText("Type Your Name Here");
    //In my DisplayGui classI got a error
    Cannot Resolve Symbol
    Variable f_Name
    java.awt.Component
    fild.emploField().f_Name.setText("Type your name here");
    ^
    What I'm doing wrong?
    Thank You

    no, that wont work, and if it did the newly created component will not be displayed. you shoud instantiate an EmployeeField object with the traits you like, then you will be able to tweek it.
    class EmployeeField extends JPanel{
       public JTextArea textArea
       public EmployeeField(){
          // create and add whatever you want
          textArea = new JTextArea("area");
          this.add(textArea);
    }then in your main
    empField = new EmpField();
    and later
    empField.textArea.setTet("newText");

  • I NEED HELP: accessing 2 forms in secuence, with 2 different users

    I have this problem:
    I run a FORM call MENU-PPAL, with the user PAUL.
    While in MENU-PPAL, I click on the option CUSTOMERS, that runs the form CUSTOMERS,
    but ...
    BEFORE running the form CUSTOMERS, I need to re-connect to the database with the user ADMIN and then run the form CUSTOMERS.
    And also, after the execution of CUSTOMERS, I need to re-connect again with PAUL while returning to the form MENU-PPAL.
    Any ideas how to do it?
    Sample code:
    In form MENU_PPAL
    CONNECT admin/admin;
    OPEN_FORM('CUSTOMERS');
    CONNECT paul/paul;
    RETURN TRUE;
    Thanks,
    Gonzalo

    All this thing to have 2 users and reconnect is because I don't want any users to connect to same tables on my database using ODBC, with and Excel Spreadsheet.
    So, the user Paul only sees same tables, a few, that aren't important. But when Paul try to access the important data, I need to reconnect with a secret user (that no one knows), ADMIN, to do all the transactions.
    And when Paul decides to exit the program, I need to reconnect him with his normal user.
    That's all!

  • Plz help me out with class loader problem

    hai forum members,
    I have a code which loads class files from local disk.
    It works fine with some classes ,
    But i get this exception when i am selecting certain other class files
    I am using jdeveloper.
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Filter (wrong name: project1/Filter)
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at com.jutframe.JavaUnitTester.selectClass_actionPerformed(JavaUnitTester.java:449)
         at com.jutframe.JavaUnitTester$7.actionPerformed(JavaUnitTester.java:338)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
         at java.awt.Component.processMouseEvent(Component.java:5488)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
         at java.awt.Component.processEvent(Component.java:5253)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3955)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1766)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
                        JFileChooser jfilechooser=new JFileChooser();
                        Filterclass filter=new Filterclass();
                        //Set selection mode for file chooser
                        jfilechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                        //set file filter
                        jfilechooser.setFileFilter(filter);
                        int returnVal = jfilechooser.showOpenDialog(this);
                        if(returnVal == JFileChooser.APPROVE_OPTION)
                            try
                                    String str = jfilechooser.getSelectedFile().getName();
                                    String parent=jfilechooser.getSelectedFile().getParent();
                                     // Create a File object on the root of the directory containing the class file
                                     File file = new File(parent);
                                     // Convert File to a URL
                                     URL url = file.toURL();         
                                     URL[] urls = new URL[]{url};
                                     // Create a new class loader with the directory
                                     ClassLoader cl = new URLClassLoader(urls);
                                     StringTokenizer st = new StringTokenizer(str,".");
                                     String s = st.nextToken ();
                                     Class c = cl.loadClass(s);  //ERROR IS SHOWN IN THIS PARTICULAR LINE
                                     Object instance=c.newInstance();
    --------------------------------------------please help me trace my mistake.
    thank you all.

    i think the problem that i have set a particular class path for my class files and my application loads files from that alone.
    So plz tell me if theres any way to access the class path of a particular file dynamically?
    regards

  • Dynamic class loading over a network

    hi,
    Im tryin to run a simple little "Hello World" type app using RMI. What i want to know is what permissions i need to grant inorder to dynamically load (client side) the stubs and skeletons from my server. Currently i get an UnmarshalException with a nested ClassNotFoundException and the helpful message "access denied to class loader". Any help is appreciated.
    Thanks in advance,
    Alex

    It is hard to tell what the problem is with out a stack trace from the exception. Perhaps in the future you would be kind enough to supply one.

  • Apparent EJB Class Loader Issue

    I am having a problem loading narrowing an EJB. It appears to be a class loader
    problem. I am getting a ClassCastException with the following message: Cannot
    narrow remote object to com.dte.ejb.facade.AccessoryServiceHome.
    Here is my code that looks up the EJB (I've ommitted the 'catch' clauses):
    EJBHome ejbHome = (EJBHome) cache.get(homeClass);
    try {
    Object temp = ctx.lookup("ejb/" + homeClass.getName());
    if (ejbHome == null) {
    ejbHome = (EJBHome) PortableRemoteObject.narrow(temp, homeClass);
    cache.put(homeClass, ejbHome);
    Here is the output of some debugging information from the above method. Here I've
    displayed the class.getName and the class.getClassLoader for the Class object
    passed to this method and the remote object being cast by the narrow method:
    homeClass : com.dte.ejb.facade.AccessoryServiceHome
    homeClass : weblogic.utils.classloaders.ChangeAwareClassLoader@29164c finder:
    weblogic.utils.classloaders.MultiClassFinder@300ec4
    From Lookup: com.dte.ejb.facade.AccessoryServiceBean_krx5el_HomeImpl
    From Lookup: weblogic.utils.classloaders.GenericClassLoader@1ea02f finder: weblogic.utils.classloaders.MultiClassFinder@6fca08
    As you can see, the Class passed into this method has been loaded with the ChangeAwareClassLoader
    but the HomeImpl class was loaded with the GenericClassLoader. I think that is
    the problem (please correct me if I am wrong).
    The application in question is an .ear with 2 .war modules and a ejb.jar file.
    It was my understanding that all classes needed by any module in a .ear were all
    loaded with the same class loader. Is this true? If so, then why am I having this
    problem?
    Thank you in advance for your help.

    I just want to add few comments hoping the iPlanet engineer will be able to help me.
    I mange to get one deployment of a war file with the client weblogic EJB to work; only if I add the Installation Directory path of the war file plus “web-inf/classes” to the classpath of the JVM configuration.
    This tells me that the class loader looks for the JVM classpath to load the EJB home class at run time. I think; if I can make iPlanet class loader to look for the application classpath instead of the JVM my problem will go away.
    Thank you in advance,
    Nad

  • Design patterns for Dynamic Class Loading

    Hi,
    I have to develop a program for uni that dynamically loads classes based on names in a text file. All the classes subclass an abstract class with a constructor that takes one argument. This means I can't use the Class.forName(className).newInstance() method of class loading. I have researched some design patterns I could use and have come up with the following 3:
    Factory pattern; "Robocode" pattern (not it's real name, but Robocode uses it); and, the "one I made up myself" pattern.
    The robocode pattern instantiates a class using the default no-argument constructor then immediately sets all properties that shoud have been provided in the constructor:
    Object o = Class.forName(myClass).newInstance();
    o.setProperty(property);Personally I think this is ugly and a cheap fix instead of doing it properly.
    My own pattern finds the constructor that takes the arguments I need then calls it to create the object:
    Class c = Class.forName(myClass);
    Constructor cons = c.getConstructor(new Class[]{Class.forName("java.lang.String")});
    Object o = cons.newInstance(new Object[]{"hello"});What's the best to use? Are there any other patterns I should consider?

    My own pattern finds the constructor that takes the
    arguments I need then calls it to create the object:
    Class c = Class.forName(myClass);
    Constructor cons = c.getConstructor(new
    Class[]{Class.forName("java.lang.String")});
    Object o = cons.newInstance(new Object[]{"hello"});
    I have followed this basic 'pattern' several times though I would use
    Constructor cons = c.getConstructor(new Class[]{String.class});
    It works great.

  • Class loader: saaj-api conflict

    I need to load saaj-api from my application which is newer than the one that comes w/ith oc4j 10.1.3 which is loaded by the system class loader with name api from webservices/lib/saaj-api.jar.
    remove-inherited doesn't seem to do the trick.
    Any suggestions would be appreciated.
    Thanks,
    Jindong.

    While I understand where you're coming from, it sounded to me that oc4j lacks the flexibility to allow application to use newer version of certain component.
    For example, certain JDK level supports certain JAXP, but there is indeed an extension mechnism to allow application plug in newer JAXP?
    I believe other j2ee contains are a lot flexbile in terms of this...I don't think J2EE spec says that applications running in its container can not use newer software components?
    I think it only makes sense that the minimum supported level is j2ee 1.4, but nothing should stop applications from having their own version of any thing.
    I strongly suggest that this to be considered for what ever release you guys are working on or a work around can be provided for the current version we're using.
    Jindong.

  • Access of undefined method/property through reference with a static type Class

    I get the following error: (it's not word for word but you get the idea)
    Error: Access of undefined method getStatus through reference with a static type Class.
    Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
    so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function User()
                trace("User Created!");
                mainStatus = 0;
            public function setStatus(status:int):void
             mainStatus = status;
        public function getStatus():int
            return mainStatus;
    Ok, so far so good.
    now I created a new .fla file under the root of /flash_working/. The class file is in /com/mypackage/User.as
    in my .fla file I have:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = User.getStatus();
    trace(i);
    That's all the code I have. Could someone please explain why it's giving me that error?
    If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
    Error: Access of undefined property mainStatus through reference with a static type Class.
    Thanks for any help!
    jef3189

    the public getStatus() function that you created needs to be referred to through an instance of the class.
    So:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = myUser.getStatus();
    trace(i);
    Also, an aside. You can create a getter/setter for status, to avoid having to do the function as such.
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function get status():int
                return mainStatus;
            public function set status(value:int):void
                 mainStatus = value as int;
              public function User()
                trace("User Created!");
                mainStatus = 0;
    And then, you can call it as:
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.status);
    EDIT
    I just noticed that you made the variable public as well, which means you can access it without getter/setter or function.
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.mainStatus);

  • When I update to the latest version I cannot access the add-ons page or request help because neither page will load. My Weather channel add-on was NOT piced up when updating to the latest version. Why problems with improved latest version?

    I have twice downloaded the latest version in the last month. Each time I encountered the same problems. the Weather Channel add-on I have did NOT appear in the latest version. When I tried to access the Add-Ons page under the Tools header it would not load. When I tried to contact Mozilla from the Help header it would not load
    When I open a web page from Bookmarks it is painfully slow to load.
    This is NOT an improved version. I have been using Firefox for years without problems; I prefer it to Internet Explorer. However the latest 'improved' version may change my mind.

    The problem is that the Add-ons Manager tab when opened the first time, is on "Get Add-ons" section and that must be downloaded from the Add-ons server which might be overburdened.
    * If you need to look for new Add-ons, go directly to the Add-ons site -> https://addons.mozilla.org/en-US/firefox/
    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Add-ons are disabled after updating Firefox#w_check-for-new-versions-of-your-add-ons|Check for New versions of your Add-ons]]
    Check and tell if its working.
    Not related to your problem but some of your Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

Maybe you are looking for

  • Mini-DVI DVI to DVI VGA adaptor issues

    So, I just bought a snazzy new black MacBook, and am wanting to connect it to my old 20" NEC monitor, which uses VGA. Since I already have a DVIVGA cable that I used with my old tower (and I figure I'll someday upgrade to a DVI monitor), I thought it

  • Not able to transmit Video

    Hi, I m new to JMF.We are using MjSIP and i want to transmit video through JMF to other machine.The problem is the implementation which is given in MjSIP isnt working . I mean whenever i execute the implementation given in mjSIP like JVisualReceiver

  • Problem with connecting to free wifi after upgrading to Windows 8.1 from Windows 8

    Hi I had problems with connecting to free Wifi after upgrading my PC(Notebook) to Windows 8.1 from Windows 8. As I travel a lot within europe, I am used to being able to connect to Free Wifi(those that dont need a key or password to enter) but soon a

  • How to return more than one value from a  function

    hello everybody, Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points, 2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these val

  • C mon nokia give an option to enroll back to 8.0

    I am tired that i have downloaded 8.1 dev preview and i cant go back to 8.0 now whats wrong with this now i am facing alot of problems in 8.1 sometimes my phone is taking around 5 minutes to unlock specially when transferring files from pc to sd card