Loading Jar classes dynamically - 10 Duke points

How can I load a jar class dynamically if it relies on say other interface? Example is, if I have three classes read from the jar file, Test.class, Test1.class and Testable.class
and "class Test implements Testable..."
If I load the Test.class, how do I tell my own class loader that Testable class is along the way, instead of getting a java.lang.NoClassDefFoundError: Testable
Need example source that works for this type of problem.
Cheers
Abraham Khalil

protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {     
name = name.replace('/', '.').replace('\\', '.');
try { 
// check if system class
return findSystemClass(name);
catch (ClassNotFoundException e) {}
catch (NoClassDefFoundError e) {}
// check if class already loaded
Class cl = null;
JarClassEntry jarEntry = (JarClassEntry) classes.get(name);
if (jarEntry != null) { // new class not loaded
// load class bytes--details depend on class loader
byte[] classBytes = loadClassBytes(name);
if (classBytes == null) {
throw new ClassNotFoundException(name);
String className = name;
if (className.endsWith(".class")) {
className = className.substring(0, className.indexOf(".class"));

Similar Messages

  • How to load a Class Dynamically?

    hi,
    I have the following problem.I am trying to load a class dynamically.For this I am using ClassLoader and its Loadclass method.My code is like this,
    File file = filechooser.getSelectedFile();
    ClassLoader Cload = this.getClass().getClassLoader();
    String tempClsname= file.getName();
    Class cd =Cload.loadClass(tempClsname);
    Object ob =(Object)cd.newInstance();
    showMethods(ob);
    In showMethods what i am doing is getting the public methods of the dynamically loaded class,
    void showMethods(Object o){
    Class c = o.getClass();
    System.out.println(c.getName());
    vecList = new Vector();
    Method theMethods[] = c.getDeclaredMethods();
    for (int i = 0; i < theMethods.length; i++) {
    if(theMethods.getModifiers()==java.lang.reflect.Modifier.PUBLIC)
    String methodString = theMethods.getName();
    System.out.println(methodString);
    vecList.addElement(methodString);
    allmthdlst.setListData(vecList);
    Now whenever i work with this i m getting a runtime error of CLASS NOT FOUND Exception..I know its because of Classpath..But i don't know how to resolve it??pls help me in this regard...
    Also previously this code was working with java files in the directory in which this java file was present..How to make it work for java file in some other directory..pls help me in this regard...
    Thanks in advance..

    You sure didn't need to post this twice.
    http://forum.java.sun.com/thread.jsp?thread=522234&forum=31&message=2498659
    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read and prevents accidental markup from array indices like [i].
    You resolve this problem by ensuring the class is in the classpath and you refer to it by its full name.
    &#167;

  • How to load a class dynamically and then a call a method?

    Hi
    I want to call a method from a class,which class is loaded dynamically.
    Consider a classA and ClassB..
    ClassB contains a method showvalue() which returns a String value.
    I want to load a ClassB dynamically in ClassA,and call the method showvalue() and print the returned value of that method (showvalue).
    How to do this?
    Thanks

    Since you found your way to Reflections and Reference Objects, I can only assume you know that reflection is the answer. Since the reflection tutorial on this site, and indeed, the many others on the web, can explain this a whole lot better and more consisely than can be done in a forum, I'll point you in that direction instead. As a starting point, and to show I'm not just fobbing you off, you're interested in the classes java.lang.Class, java.lang.reflect.Method, and the method Class.getMethod(String, Class[])

  • Trying to load jar file dynamically

    I'm trying to load the jar file dynamically and making the new instance of an objet present in it.
    mu source code -
    import java.net.*;
    import java.util.*;
    import java.io.*;
    import java.lang.reflect.Method;
    class A
    /** The class loader to use for loading JMeter classes. */
    private static URLClassLoader loader;
         static {
              System.out.println("classpath : " + System.getProperty("java.class.path"));
    URL[] urls = new URL[1];
    StringBuffer classpath = new StringBuffer();
    File f = new File("E:\\try\\lib\\dom4j.jar");
              String s = f.getPath();
    try
                   urls[0] = new URL("file", "", s);
              catch (MalformedURLException e)
                   e.printStackTrace();
    System.setProperty(
    "java.class.path",
    System.getProperty("java.class.path") + System.getProperty("path.separator") + s);
    loader = new URLClassLoader(urls);
    * Prevent instantiation.
    private A()
    * The main program which actually runs JMeter.
    * @param args the command line arguments
    public static void main(String[] args) throws Exception
              System.out.println("java,class.path : " + System.getProperty("java.class.path"));
    Thread.currentThread().setContextClassLoader(loader);
              System.out.println("loader : " + loader);
              System.out.println("java.class.path : " + System.getProperty("java.class.path"));
              System.out.println("classpath : " + System.getenv("classpath"));
    try
    Class B = loader.loadClass("B");
    Object instance = B.newInstance();
    Method startup =
    B.getMethod("print");
    startup.invoke(instance);
    catch (Exception e)
    e.printStackTrace();
    import org.dom4j.*;
    import org.dom4j.dom.*;
    import java.lang.reflect.*;
    class B
         public void print () throws Exception
              //Element e = DocumentHelper.createElement("hello");     
              //e.addText("sachin");     
              //System.out.println(e.asXML());
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
              System.out.println("loader : " + loader);
    Class c = loader.loadClass("org.dom4j.dom.DOMElement");
              //Class c = Class.forName("org.dom4j.dom.DOMElement");
              Constructor con = c.getConstructor(new String().getClass());
              DOMElement el = (DOMElement)con.newInstance(new String("asd"));
              //DOMElement dm = new DOMElement("ADD");
              System.out.println(el);
    the class org.dom4j.dom.DOMElement is present in the jar file .
    basically i'm getting an exception, given below--
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorI
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at A.main(A.java:59)
    Caused by: java.lang.NoClassDefFoundError: org/dom4j/dom/DOMElement
    at B.print(B.java:18)
    ... 5 more
    thanks alot..
    Regards,
    Sachin

    Alright let me tell you guys what I am doing. I am using reflection to load the class from a jar file. Then, I am accessing a method defined in the class.
    This piece of code will load and start the class;
    Class c = loadClass(name);
    System.out.println("name:" + name);
    System.out.println("c:" + c);
    Method m = c.getMethod("ServiceStarted", new Class[0]);
    d1 = c.newInstance();
    System.out.println("d1:" + d1);
    m.setAccessible(true);
    try {
    m.invoke(d1, new Object[0] );
    } catch (IllegalAccessException e) {
    This piece of code will invoke a preloaded class;
    String s = d1.getClass().getName();
    Class c = Class.forName(s);
    System.out.println(c);
    Object ret = null;
    Method m = c.getMethod("Hello", new Class[] { String.class });
    Object d = c.newInstance();
    m.setAccessible(true);
    try {
    ret = m.invoke(d, new Object[] { smsg });
    } catch (IllegalAccessException e) {
    and I have define d1 as;
    private static Object d1 = new Object();
    Any ideas why I am getting the exception.
    Thanks,
    MS

  • How to load a class dynamically (via reflection) in a jsf-component

    Hi all,
    I am writing my own jsf component and I would like to do it generically. Therefore I have an attribute, where the developer can pass a fully qualified classname, which I want to use to instantiate. But I have a Problem with the classloaders, everytime I get a ClassNotFound-Exception during debugging.
    Does anybody know how it is possible, to to get the most parent classloader?
    Currently I am even not able to load a class, which is in the same package like all other compontent-classes.
    Thank you very much in advance
    Thomas

    Within web applications, I believe it is recommended to use Thread.getContextClassLoader(). Keep in mind that web applications require different classloader semantics than regular Java applications. The class loader which gets resources from the WAR is favored over others, even when this violates the normal class loading conventions.

  • How to load a class dynamically in the current/system class loader

    I need to dynamically load a new jdbc driver jar to the current/system class loader... Please note that creating a new classloader will not help since the DriverManager refers to the systemclassloader itself.
    Restarting the application by appending the jar to its classpath will solve the problem but I want to avoid doing this.

    Did you then create a ClassLoader to load the JDBC
    driver and then install it into the system as
    directed by the JDBC specification (ie
    Class.forName(someClassName))?
    And then try to use it from a class loaded fromsome
    other ClassLoader (i.e. the system class loader)?
    If you did not try this please explain why not.O.K. I just looked at the source to
    java.sql.DriverManager. I did not know what I was
    talking about, as what I suggested above will not
    work.
    This is my new Idea:
    Create a URLClassLoader to load the JDBC driver also
    in this ClassLoader you need to place a helper class
    that does the following:
    public class Helper {
    public Driver getJDBCDriver(String driverClassName,
    String url) {
    try {
    Class.forName(driverClassName);
    Driver d = DriverManager.getDriver(url);
    return d;
    catch(Exception ex) {
    ex.printStackTrace();
    return null;
    }Now create an instance of the Helper class in the new
    ClassLoader, and call its getJDBCDriver method to get
    an instance of the driver (you will probably have to
    create an interface in the root class loader that the
    Helper implements so that you can easily call it).
    Now from the root classloader you can make calls
    directly to the returned Driver and bypass the
    DriverManager and its restrictions on cross
    ClassLoader access.
    The only catch here is that you would have to call to
    the returned Driver directly and not use the Driver
    Manager.This sounds like will work but I did not want to load DriverManager in a new classloader.. I did a hack
    I unzip the jar dynamically in a previously known location (which I included in my classpath when launching the app). The classLoader finds the class now though it did not exist when the app was launched !
    A hack of-course but works eh ..

  • Loading updated classes dynamically

    Hi,
    I have some classes in the classpath which I am modifying and using them in the
    weblogic. I have to restart the weblogic if those updated classes are to be loaded.
    Is there any way by which weblogic can automatically take those classes whenever
    they are accessed .
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TIA
    Ashwani Kalra
    http://www.geocities.com/ashwani_kalra/
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I believe the same is true for 5.1. Just include all supporting
    classes to your ejb-jar. What's the problem?
    Regards,
    Slava Imeshev
    "Kiran Nalamk" <[email protected]> wrote in message
    news:3c4e2e0d$[email protected]..
    >
    Hai,
    I am also facing same problem with Wl5.1 can you help me on Wl5.1also what
    we need to do. Thanx in advance.
    Kiran Nallam
    "Slava Imeshev" <[email protected]> wrote:
    Hi Ashwani,
    All classes that are in the system class path are loaded by the
    system classloader and, as the result, can not be reloaded by
    weblogic. You need to compose your deployment properly.
    Remove classes you want to be reloaded from the classpath
    and include them into your deployments instead.
    Regards,
    Slava Imeshev
    "Ashwani" <[email protected]> wrote in message
    news:3c47d920$[email protected]..
    Hi,
    I have some classes in the classpath which I am modifying and usingthem
    in the
    weblogic. I have to restart the weblogic if those updated classes areto
    be loaded.
    Is there any way by which weblogic can automatically take those classeswhenever
    they are accessed .
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TIA
    Ashwani Kalra
    http://www.geocities.com/ashwani_kalra/
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • Loading a class dynamically to classpath

    I have a class object for my .class file. It thougth it would be loaded to the classpath dynamcially by resolveClass(Class c), but still i am not able to add my class to the VM's classpath.
    Can anybody help,
    Thanks in advance
    Amir

    how do you get that Class object?
    If you use Class.forName(java.lang.String), the class loads itself, if found in classpath.
    If the class is dynamicaly generated, and you have the the file, or the bytes that form the class, you may invoke
    ClassLoader.defineClass(String name, byte[] b, int off, int len)
    I have no idea if my answer is anywhere near what you expect...

  • How to load a class in lib/file.jar

    Hi,
    I use jboss 4.0.2. and i have a jar-file from a third party in my server/default/lib that calls Thread.currentThread().getContextClassLoader().loadClass("foo"); My problem is that foo.class is never found and i dont know where i have to place this class. I would like to have a seperate folder for my classes, but i dont know how i should configure the classloader to find my classes. i dont want to package them in a jar.
    Thanks a lot!

    i tried this but the class was not found
    my simple question is:
    if a class in a jar that is placed in my jboss/server/default/lib-directory tries to load a class dynamic, where is it(classloader) looking? please tell me...
    thanks

  • How to load class from jar file dynamically?

    After I run my Java applicatoin, I need configuring the classpath of jvm to load some classess inside a jar file into the same jvm.How can I achive that?
    I mean, when I run my Java application, I don't know where the jar file is, what the jar file name is. All depends on the user to tell the jvm the details through some UI. I've tried to write: System.setProperty("java.class.path", "c:\myClass.jar");Class.forName("MyClass"); but failed.
    Can you tell my why and how?
    Thx

    After I run my Java applicatoin, I need configuring
    the classpath of jvm to load some classess inside a
    jar file into the same jvm.How can I achive that?
    I mean, when I run my Java application, I don't know
    where the jar file is, what the jar file name is. All
    depends on the user to tell the jvm the details
    through some UI. I've tried to write:
    System.setProperty("java.class.path",
    "c:\myClass.jar");Class.forName("MyClass"); but
    failed.That won't work. By the time it gets to your code it already has a copy of the original. You can't change it (short of modifying the JVM.)
    Can you tell my why and how?The usual way is to use a custom classloader.
    You can start by looking at java.net.URLClassLoader.

  • How to load a .class file dynamically?

    Hello World ;)
    Does anyone know, how I can create an object of a class, that was compiled during the runtime?
    The facts:
    - The user puts a grammar in. Saved to file. ANTLR generates Scanner and Parser (Java Code .java)
    - I compile these file, so XYScanner.class and XYParser.class are available.
    - Now I want to create an object of XYScanner (the classnames are not fixed, but I know the filename). I tried to call the constructor of XYScanner (using reflection) but nothing works and now I am really despaired!
    Isn't there any way to instantiate the class in a way like
    Class c = Class.forName("/home/mark/XYScanner");
    c scan = new c("input.txt");
    The normal call would be:
    XYLexer lex = new XYLexer(new ANTLRFileStream("input.txt"));The problem using reflection is now that the parameter is a ANTLRFileStream, not only an Integer, as in this example shown:
    Class cls = Class.forName("method2");
    Class partypes[] = new Class[2];
    partypes[0] = Integer.TYPE;
    partypes[1] = Integer.TYPE;
    Method meth = cls.getMethod("add", partypes);
    method2 methobj = new method2();
    Object arglist[] = new Object[2];
    arglist[0] = new Integer(37);
    arglist[1] = new Integer(47);
    Object retobj = meth.invoke(methobj, arglist);
    Integer retval = (Integer)retobj;
    System.out.println(retval.intValue());Has anyone an idea? Thanks for each comment in advance!!!

    Dump all of your class files into a directory.
    Use the File class to list all files and iterateover
    the files.NastyNot really, when you are dynamically creating code, I would expect the output to be centralized, not spread out all over the place.
    >
    Use a URLClassloader to load the URL that isobtained
    for each file with file.toURI().toURL()(file.toURL()
    is depricated in 1.6)Wrong, the URL you give it must be that of the
    directory, not the class file.No, I did this quite recently, you can give it a specific class file to load.
    >
    Load all of the classes in this directory, thatway
    any anonymous classes are loaded as well.Anonymous classes automatically loaded when the real
    one isIt can't load it if it doesn't know where the code is. Since you haven't used a URL classloader to load once class file at a time, you would never encounter this. But if you loaded a class file that had an anonymous classfile it needed, would it know where to look for it?
    >
    From this point you should be able to just get a
    class with Class.forName(name)No. Class.forName uses the classloader of the class
    it's called in, which will be the system classloader.
    It won't find classes loaded by a URLClassLoader.got me there.

  • 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()
        }

  • 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

  • Unable to load a class specified in your ejb-jar.xml

    I was trying an example on entity bean CMP, i created the bean and tried to deploy it.I got the following error :-
    Exception:weblogic.management.ApplicationException: prepare failed for CMP Module: CMP Error: Exception preparing module: EJBModule(CMP,status=NEW) Unable to deploy EJB: C:\bea\user_projects\domains\Testdomain\applications\CMP.jar from CMP.jar: weblogic.ejb20.deployer.DeploymentDescriptorException: Unable to load a class specified in your ejb-jar.xml: pack.sams.ItemBean at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.initializeBeanInfos(Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Lweblogic.utils.classloaders.GenericClassLoader;)V(MBeanDeploymentInfoImpl.java:550) at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.<init>(Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Lweblogic.utils.classloaders.GenericClassLoader;Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.utils.jars.VirtualJarFile;)V(MBeanDeploymentInfoImpl.java:232) at weblogic.ejb20.deployer.EJBDeployer.prepare(Lweblogic.utils.jars.VirtualJarFile;Ljava.lang.ClassLoader;Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Ljavax.naming.Context;Ljava.util.Map;)V(EJBDeployer.java:1302) at weblogic.ejb20.deployer.EJBModule.prepare(Ljava.lang.ClassLoader;)V(EJBModule.java:498) at weblogic.j2ee.J2EEApplicationContainer.prepareModule(Lweblogic.utils.classloaders.GenericClassLoader;Lweblogic.j2ee.J2EEApplicationContainer$Component;Z)V(J2EEApplicationContainer.java:3101) at weblogic.j2ee.J2EEApplicationContainer.prepareModules([Lweblogic.j2ee.J2EEApplicationContainer$Component;Ljava.lang.String;Z)V(J2EEApplicationContainer.java:1560) at weblogic.j2ee.J2EEApplicationContainer.prepare([Lweblogic.j2ee.J2EEApplicationContainer$Component;[Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)V(J2EEApplicationContainer.java:1208) at weblogic.j2ee.J2EEApplicationContainer.prepare(Ljava.lang.String;[Lweblogic.management.configuration.ComponentMBean;[Ljava.lang.String;)V(J2EEApplicationContainer.java:1051) at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareContainer()V(SlaveDeployer.java:2444) at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer()Z(SlaveDeployer.java:2394) at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare()V(SlaveDeployer.java:2310) at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(Lweblogic.management.deploy.OamVersion;Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;Z)V(SlaveDeployer.java:866) at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(Lweblogic.management.deploy.OamDelta;Lweblogic.management.deploy.OamVersion;ZLjava.lang.StringBuffer;)Z(SlaveDeployer.java:594) at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(Ljava.util.ArrayList;Z)V(SlaveDeployer.java:508) at weblogic.drs.internal.SlaveCallbackHandler$1.execute(Lweblogic.kernel.ExecuteThread;)V(SlaveCallbackHandler.java:25) at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178) at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)
    [Deployer:149033]preparing application CMP on ejb
    [Deployer:149033]failed application CMP on ejb
    [Deployer:149034]An exception occurred for task [Deployer:149026]Deploy application CMP on ejb.: Exception:weblogic.management.ApplicationException: prepare failed for CMP Module: CMP Error: Exception preparing module: EJBModule(CMP,status=NEW) Unable to deploy EJB: C:\bea\user_projects\domains\Testdomain\applications\CMP.jar from CMP.jar: weblogic.ejb20.deployer.DeploymentDescriptorException: Unable to load a class specified in your ejb-jar.xml: pack.sams.ItemBean at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.initializeBeanInfos(Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Lweblogic.utils.classloaders.GenericClassLoader;)V(MBeanDeploymentInfoImpl.java:550) at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.<init>(Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Lweblogic.utils.classloaders.GenericClassLoader;Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;Lweblogic.utils.jars.VirtualJarFile;)V(MBeanDeploymentInfoImpl.java:232) at weblogic.ejb20.deployer.EJBDeployer.prepare(Lweblogic.utils.jars.VirtualJarFile;Ljava.lang.ClassLoader;Lweblogic.management.descriptors.toplevel.EJBDescriptorMBean;Ljavax.naming.Context;Ljava.util.Map;)V(EJBDeployer.java:1302) at weblogic.ejb20.deployer.EJBModule.prepare(Ljava.lang.ClassLoader;)V(EJBModule.java:498) at weblogic.j2ee.J2EEApplicationContainer.prepareModule(Lweblogic.utils.classloaders.GenericClassLoader;Lweblogic.j2ee.J2EEApplicationContainer$Component;Z)V(J2EEApplicationContainer.java:3101) at weblogic.j2ee.J2EEApplicationContainer.prepareModules([Lweblogic.j2ee.J2EEApplicationContainer$Component;Ljava.lang.String;Z)V(J2EEApplicationContainer.java:1560) at weblogic.j2ee.J2EEApplicationContainer.prepare([Lweblogic.j2ee.J2EEApplicationContainer$Component;[Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)V(J2EEApplicationContainer.java:1208) at weblogic.j2ee.J2EEApplicationContainer.prepare(Ljava.lang.String;[Lweblogic.management.configuration.ComponentMBean;[Ljava.lang.String;)V(J2EEApplicationContainer.java:1051) at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareContainer()V(SlaveDeployer.java:2444) at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer()Z(SlaveDeployer.java:2394) at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare()V(SlaveDeployer.java:2310) at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(Lweblogic.management.deploy.OamVersion;Lweblogic.management.runtime.DeploymentTaskRuntimeMBean;Z)V(SlaveDeployer.java:866) at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(Lweblogic.management.deploy.OamDelta;Lweblogic.management.deploy.OamVersion;ZLjava.lang.StringBuffer;)Z(SlaveDeployer.java:594) at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(Ljava.util.ArrayList;Z)V(SlaveDeployer.java:508) at weblogic.drs.internal.SlaveCallbackHandler$1.execute(Lweblogic.kernel.ExecuteThread;)V(SlaveCallbackHandler.java:25) at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178) at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source) .
    Please suggest a solution to this error.
    Note that the class specified in the error is in its package. So this doesn't seems to be exact error. Please suggest.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    I have faced same problem most of time and resolved ot by recompileing my all the classes and new deployment descriptors. First you should make new java files for all clases(copy contents fron old java files ) and make anew package same as old and then do all the required process and re deploy it. I think because of some problem in class generation.

  • 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?

Maybe you are looking for

  • Unable to Access Company LAN via VPN

    Hello, I have a ASA 5505 that I have been using to test run the IPSec VPN connection after studying the different configs and running through the ASDM I keep getting the same issue that I can't receive any traffic. The company LAN is on a 10.8.0.0 25

  • I got this error report but when I try to submit it says submission failed

    Interval Since Last Panic Report:  71086 sec Panics Since Last Report:          1 Anonymous UUID:                    69709F90-8F7B-4EC1-82EA-4E93A5E722BE Tue Feb 28 14:01:27 2012 panic(cpu 1 caller 0x001AB0FE): Kernel trap at 0x00000000, type 14=page

  • Final Cut Studio 2 on Final Cut Server 1.5

    A few months back when I was looking at getting Final Cut Server 1.5, I asked a few people (including a mac employee), if FInal Cut Server 1.5 will work with Final Cut Studio 2 and they said yes. I have now purchased final cut server 1.5 and I'm now

  • Getting 2 errors in bash script

    /Users/Myname/Desktop/Printer Install 2: line 115: unexpected EOF while looking for matching `"' /Users/myname/Desktop/Printer Install 2: line 119: syntax error: unexpected end of file logout Please help I have no idea what is causing it. If I do a f

  • Copy from column  to another column in same table

    Hi, Working on EBS Version : 11.5.10.2 Table Name : ASO_QUOTE_HEADERS_ALL COLUMNS : QUOTE_STATUS_ID NUMBER ATTRIBUTE6 VARCHAR2(240 BYTE); Need to copy from quote_status_id to attribute6 for that quote_header_id example if quote_status_id = 10 then it