Classloader in weblogic12c

I develop a spring+hibernate+struts web application and need to deploy it from a folder to weblogic12c.
However, after deployment, in Classloader Analysis Tool, 2 jars: WEB-INF/lib/hibernate-core-3.3.2.GA.jar, WEB-INF/lib/freemarker-2.3.15.jar show: The filtering classloader acts as a barrier between the application classloaders and the system classloaders. By configuring the filtering classloader correctly, the application can choose to load certain classes locally rather than from the system classpath.
Below is my weblogic-application.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
     <application-param>
          <param-name>webapp.encoding.default</param-name>
          <param-value>UTF-8</param-value>
     </application-param>
     <prefer-application-packages>
          <package-name>javax.jws.*</package-name>
     </prefer-application-packages>
</weblogic-application>
What should I do next?
Thanks

Have a look at
http://www.onjava.com/pub/a/onjava/2001/07/25/ejb.html
Instantiating objects of a same class in different subunits will not cause errors, but it is true that, according to the classloading policy (configurable in application server), the behaviors of creational mecanisms such as singleton for example, can vary.
Bruno
http://www.practicalsoftwarearchitect.com

Similar Messages

  • How to enable web-app "parent-last" classloading in WLS 10.3?

    Hello,
    We are having some issues when using Groovy to execute ant tasks in a webapp. They are due to the classloading order in WLS.
    The problem is this :
    - Our webapp is using Groovy 1.5.6.
    - Groovy 1.5.6 uses ant 1.7. When groovy calls ant tasks such as <untar>, <unjar>, etc, it is passing the <mapper> element, which is supported in ant 1.7.
    - When this webapp is deployed in WLS 10.3, Groovy tries to call these ant tasks, but WLS has ant 1.6 which does not support the nested <mapper> element groovy is trying to pass.
    - The groovy script blows up with an ant error because of the unsupported element.
    - We are packaging ant 1.7 jars in the WEB-INF/lib dir of our WAR file, but WLS is loading the classes from it's own classpath first, so we do not get the 1.7 impl loaded.
    The solution is to enable "parent-last" classloading for this webapp, but I can not find any documentation on how to do this.
    In Websphere you can set a checkbox for it in the console.
    In Orion, you add to the orion-web.xml file this tag <web-app-class-loader search-local-classes-first="true"/>
    ** In WebLogic, how do you do this?
    I have been searching the documentation and asking around, and I can not find an answer yet. Thanks in advance for your help!

    Try either a filtering classloader as described here:
    http://edocs.bea.com/wls/docs103/programming/classloading.html#wp1097187
    Or prefer-web-inf-classes in weblogic.xml:
    http://edocs.bea.com/wls/docs103/programming/classloading.html#wp1082452

  • Classloader Again

    Sorry to bring up the classloader questions again and again. I am a bit confused by the language used in the documentation when it says things like each application has its own universe etc. And also, the following statement in the docs,
    "The exception is the Web Classloader, which follows the delegation model in the Servlet specification. The Web Classloader looks in the local classloader before delegating to its parent. You can make the Web Classloader delegate to its parent first by setting delegate="true" in the class-loader element of the sun-web.xml file. For details, see the Developer's Guide to Web Applications."
    I wanted to see if some one could answer the following. (These are very easy for me to test. But, at this point I have a very "rich" system classpath that includes a lot of classes/jars etc. Makes it harder to see a clear picture. And I want to see if what I am observing the correct behavior))
    I have a com.xyz.myClass packaged in utils.jar. I also have a test servlet and jsp page. The test servlet makes a call to com.xyz.myClass
    A) If I individually deploy my test servlet/jsp as a .WAR, where should I place utils.jar?
    (If I had utils.jar in the system classpath, is the WAR supposed to see it?)
    B) What if the a

    I have a com.xyz.myClass packaged in utils.jar. I also have > a test servlet and jsp page. The test servlet makes a call to > com.xyz.myClass
    A) If I individually deploy my test servlet/jsp as a .WAR,
    where should I place utils.jar?You can place it in any one of a number of locations:
    - within the WAR under WEB-INF/lib/. This location would be the most conventional, self-contained approach.
    - under $INSTANCE_ROOT/lib/. This location would mean that the same "version" the library would be shared by all apps (assuming that the other apps did not include their own copy).
    - under classpath-suffix setting for the instance. Similar to using $INSTANCE_ROOT/lib/, but you have to specify the JAR file name explicitly.
    (If I had utils.jar in the system classpath, is the WAR
    supposed to see it?)Yes.
    B) What if the above .WAR was part of a larger .EAR and I > deploy the .EAR instead of the .WAR? (Should utils.jar
    be in system class path or the web-inf/lib of the .WAR ?)Either.
    C) What if the .EAR above also had a few EJBs that
    accessed com.xyx.myClass ?- Self-contained approach would be to package the JAR file in the EAR and use the manifest classpath approach to denote its location for both the EJB JAR module and the WAR module.
    - Alternatively, you could either place the library either under $INSTANCE_ROOT/lib/ or specify the library in the classpath-suffix setting in the instance configuration.
    A good example of when it makes sense for the web classloader to look in the local classloader before delegating upward to the system classloader is the case in which your web application depends on a particular JAXP compatible XML parser that is different from that which is being used by the application server infrastructure. In this case, you would want the XML parser embedded in your web app or EAR to take precedence over the other XML parser packaged in the system classpath for use by the app server.
    Chris

  • 64-bit JNI C++ to JAVA invocation multiple threads classloader problem

    Hi ALL,
    I have a C++ app that invokes Java classes on 64-bit Solaris 10 with 64-bit JVM.
    Here is the problem:
    The native non-main (not the thread that initializes the JVM) threads would not be able to find any user-define class.
    Here are the symptoms and observations:
    1. JNIEnv::ExceptionDescribe() showed the following StackOverflowError:
    Exception in thread "Thread-0" java.lang.StackOverflowError
            at java.util.Arrays.copyOf(Arrays.java:2734)
            at java.util.Vector.ensureCapacityHelper(Vector.java:226)
            at java.util.Vector.addElement(Vector.java:573)
            at java.lang.ClassLoader.addClass(ClassLoader.java:173)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(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:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)2. The "main thread" that instantiates the JVM has no problem finding and loading any class or method
    3. But the other threads (non-main threads) would not be able to find the user-defined classes unless the classes were already loaded by the main thread.
    4. The non-main threads can find the "standard" java classes with no problem
    5. The same app ran fine on 32-bit system.
    6. Except for the JVM reference is global, each thread acquired JNIEnv by either GetEnv() or AttachCurrentThread().
    Any idea why it is a problem with 64-bit?
    I have the sample program to reproduce this issue in this thread: http://forums.sun.com/thread.jspa?messageID=10885363&#10885363. That was the original thread I raised but I have narrowed it down to a more concrete scenario. That's why I am creating this new thread. I hope this does not break any rule on this forum. If it does, I apologize.
    I really appreciate it if anyone can provide any help/suggestion.
    Regards,
    - Triet

    Here is the sample program. Again, this works on 32-bit but not 64-bit.
    #include <string>
    #include "jni.h"
    #include "TestThread.h"
    static JavaVM *g_pjvm = NULL;  /* denotes a Java VM */
    static JNIEnv *g_penv = NULL;  /* pointer to native method interface */
    void initJVM(char** jvmOptions) {
        printf("RJniTest init starts...\n");
        JavaVMInitArgs vm_args; /* JDK/JRE 6 VM initialization arguments */
        JavaVMOption* poptions;
        int optionLen = 0;
        while (jvmOptions[optionLen]) {
            optionLen++;
        printf("RJniTest::init len=%d\n", optionLen);
        if (optionLen > 0) {
            printf("RJniWrapper::init jvmOptions\n");
            poptions = new JavaVMOption[optionLen];
            //poptions[0].optionString = "-Djava.class.path=/usr/lib/java";
            int idx = 0;
            while (jvmOptions[idx]) {
                poptions[idx].optionString = jvmOptions[idx];
                idx++;
        printf("RJniTest::init vm_args: version(%x), nOptions(%d)\n",
                JNI_VERSION_1_6, optionLen);
        vm_args.version = JNI_VERSION_1_6;
        vm_args.nOptions = optionLen;
        vm_args.options = poptions;
        vm_args.ignoreUnrecognized = JNI_FALSE;
        // load and initialize a Java VM, return a JNI interface
        // pointer in env
        printf("RJniTest::init creates JVM\n");
        JNI_CreateJavaVM(&g_pjvm, (void**)&g_penv, &vm_args);
        printf("RJniTest init ends\n");
    void findClass(const char* classname) {
        static const char* fname = "justFindClasses";
        printf("%s: findClass: %s\n", fname, classname);
        JNIEnv* jenv;
        jint ret = g_pjvm->GetEnv((void**)&jenv, JNI_VERSION_1_6);
        if (ret == JNI_EDETACHED) {
            ret = g_pjvm->AttachCurrentThread((void**)&jenv, NULL);
            if (ret != JNI_OK || jenv == NULL) {
                printf("%s: get env error: ret=%d\n", ret, fname);
            } else {
                printf("%s: got new env\n", fname);
        } else if (ret == JNI_OK) {
            printf("%s: env already there\n");
        jclass classref;
        classref = jenv->FindClass(classname);
        if (classref == NULL) {
            printf("%s: %s class not found!\n", fname, classname);
            if (jenv->ExceptionOccurred()) {
                jenv->ExceptionDescribe();
                jenv->ExceptionClear();
        printf("%s: found class: %s\n", fname, classname);
    class RJniTestThread : public TestThread {
    public:
        void threadmain();
    void RJniTestThread::threadmain() {
        printf("RJniTestThread::threadmain: Starting testing\n");
        findClass("org/apache/commons/logging/Log");
        findClass("java/util/List");
        printf("RJniTestThread::threadmain: done.\n");
    int main(int argc, char** argv) {
        char **jvmOptions = NULL;
        printf("RJniTestDriver starts...\n");
        if (argc > 1) {
            jvmOptions = new char*[argc];
            for (int i = 0; i < argc ; i ++) {
                jvmOptions[i] = argv[i + 1];
            jvmOptions[argc - 1] = NULL;
        } else {
            int size = 8;
            int i = 0;
            jvmOptions = new char*[size];
            jvmOptions[i++] = (char*) "-Djava.class.path=<list of jar files and path here>";
            jvmOptions[i++] = (char*) "-Djava.library.path=/sandbox/mxdev/3rdparty/java/unix/jdk1.6.0_14/jre/lib/sparc";
            jvmOptions[i++] = (char*) "-Djava.compiler=NONE";
            jvmOptions[i++] = (char*) "-verbose:jni";
            jvmOptions[i++] = (char*) "-Xcheck:jni";
            jvmOptions[i++] = NULL;
        printf("init JVM\n");
        initJVM(jvmOptions);
        // UNCOMMENT HERE
        // findClass("org/apache/commons/logging/Log");
        // findClass("java/util/List");
        // UNCOMMENT END
        printf("start test thread\n");
        RJniTestThread testThread;
        ThreadId tid = testThread.launch();
        printf("wait for test thread\n");
        int ret = pthread_join(tid, NULL);
        printf("RJniTestDriver ends\n");
    }

  • Seam on Weblogic 10.3.2: Possible classloader problem?

    Hi all,
    I have a problem deploying a Seam 2.2.0.GA application on WebLogic 10.3.2. I use JRockit 1.6.0_14, Richfaces 3.2.0.GA and Facelets 1.1.14 and the Server is deployed on Windoes XP 32bit. The application has the following structure:
    application.ear
    |--> APP-INF
    | |--> classes
    | |--> lib (all jar dependencies go here, including the WAR dependencies, EJB module dependencies)
    |-->META_INF
    | |--> application.xml
    | |--> data-sources.xml
    | |--> MANIFEST.MF
    | |--> weblogic.xml
    | |--> weblogic-application.xml
    |--> jboss-seam-2.2.0.GA.jar (is an EJB module)
    |--> myEjbModule1.jar
    |--> myEjbModule2.jar
    |--> myEjbModule3.jar
    |--> myEjbModule4.jar
    |--> myWar.war (NO libraries in WEB-INF/lib, finds everything in EAR/lib)
    JBoss Seam is an EJB module. and is declared as such in application.xml. Everything is OK, since the application loads correctly. The jar contains a faces.config registering the SeamPhaseListener on JSF, so that Seam actually works.
    Problems start when I try to enable the debug page of Seam. In order to do this, one must include in the classpath the jboss-seam-debug.jar (in APP-INF/lib or EAR/lib, here I am using the first). This jar has its own faces.config, which registers the Seam*Debug*PhaseListener on JSF, so that it catches debug requests.
    When deploying WITH jboss-seam-debug.jar, the application does not appear, but ONLY the debug page with the following exception (stacktrace at the end):
    Exception during request processing:
    Caused by java.lang.IllegalStateException with message: "No phase id bound to current thread (*make sure you do not have two SeamPhaseListener instances installed*)"
    This probably signifies a classloader issue. So, I have two questions:
    1. Has anyone deployed JBoss Seam on WenLogic WITH the debug page? If yes, is the structure of my project correct?
    2. Is there a way to debug the classloading of WebLogic? What I would find helpful would be to see what happens that registers the SeamPhaseListener more than one times.
    Note: When "JBoss-izing" the same EAR (remove hibernate jars, which are provided by JBoss, and move all libraries from EAR/lib to EAR root), the application loads correctly. BOTH the application AND the debug page appear correctly.
    Edited by: user6410241 on Mar 24, 2010 8:14 AM
    Edited by: user6410241 on Mar 24, 2010 8:26 AM

    The problem was the name of the Seam EJB module. Changing the jar to jboss-seam.jar, everything worked. This issue does not appear on JBoss 4.2.3.GA, where I also tested.
    Edited by: deadlock_gr on Jun 10, 2010 9:55 AM
    Edited by: deadlock_gr on Jun 10, 2010 9:56 AM

  • Classloader won't let me delete jar file!

    Hi-
    I am writing a classloader that runs main from a class called MyMain. MyMain loads classes from a jar file called MattTable.jar. I need to be able to delete the jar file once the classes are loaded from it, or even just delete it at the end of the program. Either way, the classloader will not release it so I cannot delete the jar file until after my program finishes. I want to be able to delete it from with in my code after the method is invoked.
    URL urls[] = new URL[] { new File(".").toURL() };
    URLClassLoader loader = new URLClassLoader( urls );
    Class c = loader.loadClass(mainClass);
    Method m1 = c.getMethod("main", new Class[] { args.getClass() });
    //main loads classes from an outside jar file
    m1.invoke( null, new Object[] {args} );
    //Here is where I want to delete the jar file
    //I would even accept file.deleteOnExit() but this won't work either
    If anyone can help me figure out how to delete this file, it would be a great help!
    Thanks,
    Matt

    Hi,
    I've created a small classloader for jar files which releases the handle every time a class is loaded. It might still need some optimization, but at least it works:import java.util.zip.*;
    import java.util.*;
    import java.io.*;
    public class ZipClassLoader extends ClassLoader {
         private Hashtable classes = new Hashtable();
         private File f;
         public ZipClassLoader(String zipFileName) {
              this (new File(zipFileName));
         public ZipClassLoader(File zipFile) {
              f = zipFile;
         public Class loadClass(String className) throws ClassNotFoundException {
              return (loadClass(className, true));
         public synchronized Class loadClass(String className, boolean resolve) throws ClassNotFoundException {
              if (classes.containsKey(className)) return (Class)classes.get(className);
              ZipFile zipFile = null;
              BufferedInputStream bis = null;
              byte[] res = null;
              try {
                   zipFile = new ZipFile(f);
                   ZipEntry zipEntry = zipFile.getEntry(className.replace('.', '/')+".class");
                   res = new byte[(int)zipEntry.getSize()];
                   bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
                   bis.read(res, 0, res.length);
              } catch (Exception ex) {
              } finally {
                   if (bis!=null) {
                        try {
                             bis.close();
                        } catch (IOException ioex) {}
                   if (zipFile!=null) {
                        try {
                             zipFile.close();
                        } catch (IOException ioex) {}
              if (res == null) return super.findSystemClass(className);
              Class clazz = defineClass(className, res, 0, res.length);
              if (clazz == null) throw new ClassFormatError();
              if (resolve) resolveClass(clazz);
              classes.put(className, clazz);
              return(clazz);
    }This is the test program I've created. It loads a class from the Apache log4j jar file, and deletes the file when the class is loaded:import java.io.File;
    public class Test {
         public static void main(String[] args) throws Exception {
              File f = new File("C:\\jartest\\log4j-1.2.6.jar");
              ZipClassLoader zl = new ZipClassLoader (f);
              Class c = zl.loadClass ("org.apache.log4j.ConsoleAppender", true);
              Object o = c.newInstance();
              System.out.println (o.getClass().getName());
              f.delete();
    }

  • Problem with XMLDecoder and a custom ClassLoader

    NOTE: Posted over in Serialization forum as more appropriate there, sorry for the crosspost but didn't notice that forum at first. Please direct any replies there.
    I am implementing an application based around Java Plugin Framework (jpf.sourceforge.net). In short one consequence of this framework is that each plugin uses its own classloader with scope of that plugins classes.
    One plugin I am using requires the ability to deserialize objects from a javabean xml file. I am using XMLDecoder to do this, and I used the constructor to pass the current plugin ClassLoader to it.
    This however only partially seems to work, this is a shortened extract from an example xml
    <java version="1.5.0" class="java.beans.XMLDecoder">
    <object class="usermanager.javabeans.BeanUser">
      <string>drftpd</string>
      <void property="downloadedBytes">
       <long>737132544</long>
      </void>
      <void property="hostMaskCollection">
       <void method="add">
        <object class="usermanager.HostMask">
         <string>*@*</string>
        </object>
       </void>
      </void>
       <void property="keyedMap">
       <void method="put">
        <object class="dynamicdata.Key">
         <class>commands.UserManagement</class>
         <string>slots</string>
         <class>java.lang.Integer</class>
        </object>
        <int>0</int>
       </void>
    etc...Now without passing XMLDecoder a ClassLoader as would be expected I get a ClassNotFoundException for the first <object>.
    However if I pass XMLDecoder the correct ClassLoader it reads the xml fine until it reaches <class>commands.UserManagement</class> at which point again I get a ClassNotFoundException.
    Here is the stacktrace from that exception:
    java.lang.ClassNotFoundException: commands.UserManagement
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:242)
         at com.sun.beans.ObjectHandler.classForName(ObjectHandler.java:67)
         at com.sun.beans.ObjectHandler.classForName(ObjectHandler.java:54)
         at java.beans.Statement.invoke(Statement.java:140)
         at java.beans.Expression.getValue(Expression.java:98)
         at com.sun.beans.MutableExpression.getValue(ObjectHandler.java:400)
         at com.sun.beans.ObjectHandler.getValue(ObjectHandler.java:106)
         at com.sun.beans.ObjectHandler.endElement(ObjectHandler.java:327)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:625)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1241)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
         at javax.xml.parsers.SAXParser.parse(SAXParser.java:344)
         at javax.xml.parsers.SAXParser.parse(SAXParser.java:120)
         at java.beans.XMLDecoder.readObject(XMLDecoder.java:205)
         at usermanager.javabeans.BeanUserManager.loadUser(BeanUserManager.java:128)
    Now after looking through some of the source it appears to me at least that XMLDecoder when processing an <object> uses an ObjectHandler with the ClassLoader as a parameter, however a class contained within a <class> element gets handled by Statement.invoke() which uses an ObjectHandler without a ClassLoader specified thus using the standard ClassLoader.
    I've managed to work around it for now by setting the contextClassLoader to the correct one before calling readObject() in XMLDecoder and then reverting it back immediately after, but this feels like somewhat of a hack to me.
    I would've expected it to have been properly handled when passing the ClassLoader to XMLDecoder rather than like it is.
    Anyone know if this is intended behaviour or a bug? and if the former is there any recommended way to deal with this other than the one I'm currently using.
    NOTE: Posted over in Serialization forum as more appropriate there, sorry for the crosspost but didn't notice that forum at first. Please direct any replies there.
    Message was edited by:
    djb61
    NOTE: Reposting to Serialization

    You can provide a cell renderer to the JTree to paint the checkBox.
    The following code checks or unchecks the box with each click also:
    _tree.setCellRenderer(new DefaultTreeCellRenderer()
      private JCheckBox checkBox = null;
      public Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus)
        // Each node will be drawn as a check box
        if (checkBox == null)
          checkBox  = new JCheckBox();
          checkBox .setBackground(tree.getBackground());
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
        checkBox.setText(node.getUserObject().toString());
        checkBox.setSelected(selected);
        return checkBox;
    });

  • Problem with classloader (for shared-lib's) on oc4j 10.0.3.4 under jdk 1.5

    I have a project that runs great on oc4j 10.0.3.4 under jdk 1.6. (everything worked great)
    I recently tried to run it under jdk 1.5 and i've run into a little problem with the shared-lib's:
    The classloader's debug file reports the following: (i have translated some of it)
    Class error: oracle.classloader.util.AnnotatedNoClassDefFoundError:
         Missing class: javax.xml.bind.JAXBContext
    Dependant class: nl.comp.util.XmlUtil
         Classloader: comp:0.1
         Code-source: /C:/programs/oc4j/j2ee/home/shared-lib/comp/0.1/comp.jar
         Configuration: <code-source> in /c:/programs/oc4j/j2ee/home/config/server.xml
    The missing class is available from the following location:
         1. Code-source: /C:/programs/oc4j/lib/xml.jar (from <code-source> (ignore manifest Class-Path) in META-INF/boot.xml in C:\programs\oc4j\j2ee\home\oc4j.jar)
    This code-source is available from classloader oracle.xml:10.1.0_2
         2. Code-source: /C:/programs/oc4j/j2ee/home/shared-lib/jaxb/2.1.6/jaxb-api.jar (from <code-source> in /c:/programs/oc4j/j2ee/home/config/server.xml)
    This code-source is available from classloader jaxb:2.1.6.
    So the classloader knows where to find the necessary lib, but it isn't loading it? If i run the exact same code (with same descriptors and everything) under jdk 1.6, it works, under 1.5 i get the above error.
    What is different on the class loader level between the two jdk versions that might affect the program in such a way?
    Need i update a descriptor or do something else?

    Jack,
    Not a definitive answer for you (sorry), just a few suggestions (that I assume you are unaware of).
    1. Try unsetting your "ClassPath" variable. Open a "command" window and type the following:
    set ClassPath=2. Launch OC4J from the directory where the "oc4j.jar" file is located, for example:
    D:
    cd oc4j\j2ee\home
    java -jar oc4j.jar3. I'm just guessing, but if your drive "D:" is a mapped, network drive, this may be causing the problem. Perhaps try installing OC4J on a local drive?
    Hope this helps.
    Good Luck,
    Avi.

  • Servicegen:  unable to load type library from classloader weblogic.utils.cl

    Hi,
    I am new to weblogic. I am encountering an error on trying to run the 'servicegen' command from my ant build scripts, on weblogic 9.2.
    Please find the build.xml snapshot, and the stack trace given below.
    Please help me out with this.
    Points to be noted are:-
    1) The ejb-jar.xml specifies the bean class, which is very much present in the classpath. The ejb-jar.xml is generated by xdoclet. Snapshot is given below:-
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar >
    <description><![CDATA[No Description.]]></description>
    <display-name>Generated by XDoclet</display-name>
    <enterprise-beans>
    <!-- Session Beans -->
    <session >
    <description><![CDATA[NorthBound Interface]]></description>
    <ejb-name>ArcorNBIService</ejb-name>
    <home>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceHome</home>
    <remote>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIService</remote>
    <local-home>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceLocalHome</local-home>
    <local>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceLocal</local>
    <ejb-class>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    2) When I replace the "ejbJar" attribute in the 'service' command with "javaClassComponents" attribute, I am able to run the servicegen command successfully. Not sure why the ejbJar is creating problems.
    3) Build.xml snapshot:-
         <target name="gen-webservice" depends="init">
              <copy todir="${work.dir}" file="${export.dir}/lib/arcor-il-service-ejb.jar"/>
              <autotype javatypes="${javatypes}" targetNamespace="${targetNamespace}" destDir="${work.dir}/classes" keepGenerated="${keepGenerated}" classpathref="webservice.client.classpath"/>
              <autotype javaComponents="com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIService" targetNamespace="com.alcatel.hdm.service.nbi.dto.holders" destDir="${work.dir}/classes" keepGenerated="true" classpathref="webservice.client.classpath"/>
              <servicegen destEar="${earfile}" warName="${warname}" contextURI="${contextURI}" keepGenerated="${keepGenerated}" classpathref="webservice.client.classpath">
                   <service ejbJar="${ejbLocation}" targetNamespace="${targetNamespace}" serviceName="${serviceName}" serviceURI="/${serviceName}" generateTypes="false" expandMethods="${expandMethods}" ignoreAuthHeader="false" protocol="https" style="rpc" useSOAP12="${useSOAP12}" typeMappingFile="${work.dir}/classes/types.xml">
                        <security enablePasswordAuth="true"/>
                   </service>
              </servicegen>
         </target>
    4) Exception stacktrace:-
    --- Nested Exception ---
    java.lang.AssertionError: java.io.IOException
    at weblogic.descriptor.DescriptorManager$DefaultMarshallerFactorySingleton.<clinit>(DescriptorManager.java:42)
    at weblogic.descriptor.DescriptorManager.getDefaultMF(DescriptorManager.java:116)
    at weblogic.descriptor.DescriptorManager.getMarshallerFactory(DescriptorManager.java:125)
    at weblogic.descriptor.DescriptorManager.getDescriptorFactory(DescriptorManager.java:153)
    at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:277)
    at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:248)
    at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:309)
    at weblogic.descriptor.EditableDescriptorManager.createDescriptor(EditableDescriptorManager.java:99)
    at weblogic.application.descriptor.AbstractDescriptorLoader.createDescriptor(AbstractDescriptorLoader.java:344)
    at weblogic.application.descriptor.CachingDescriptorLoader.createDescriptor(CachingDescriptorLoader.java:188)
    at weblogic.application.descriptor.AbstractDescriptorLoader.createDescriptor(AbstractDescriptorLoader.java:328)
    at weblogic.application.descriptor.AbstractDescriptorLoader.getDescriptor(AbstractDescriptorLoader.java:237)
    at weblogic.application.descriptor.AbstractDescriptorLoader.getRootDescriptorBean(AbstractDescriptorLoader.java:217)
    at weblogic.ejb.spi.EjbJarDescriptor.getEjbJarBean(EjbJarDescriptor.java:141)
    at weblogic.ejb.spi.EjbJarDescriptor.getEditableEjbJarBean(EjbJarDescriptor.java:182)
    at weblogic.ejb.container.dd.xml.DDUtils.processEjbJarXMLWithSchema(DDUtils.java:519)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:182)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:126)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:154)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:147)
    at weblogic.ejb.spi.DDUtils.createDescriptorFromJarFile(DDUtils.java:30)
    at weblogic.webservice.dd.EJBJarIntrospector.<init>(EJBJarIntrospector.java:52)
    at weblogic.ant.taskdefs.webservices.autotype.EJBAutoTyper.<init>(EJBAutoTyper.java:68)
    at weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.runAutoTyper(ServiceGenTask.java:339)
    at weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.generateService(ServiceGenTask.java:313)
    at weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.execute(ServiceGenTask.java:181)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    at org.apache.tools.ant.Main.runBuild(Main.java:668)
    at org.apache.tools.ant.Main.startAnt(Main.java:187)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
    Caused by: java.io.IOException
    at weblogic.descriptor.internal.MarshallerFactory.<init>(MarshallerFactory.java:50)
    at weblogic.descriptor.DescriptorManager$DefaultMarshallerFactorySingleton.<clinit>(DescriptorManager.java:40)
    ... 37 more
    Caused by: com.bea.xml.XmlException: unable to load type library from classloader weblogic.utils.classloaders.ClasspathClassLoader@1cc0a7f f
    inder: weblogic.utils.classloaders.CodeGenClassFinder@c52200 annotation:
    at com.bea.staxb.runtime.internal.BindingContextFactoryImpl.createBindingContext(BindingContextFactoryImpl.java:50)
    at weblogic.descriptor.internal.MarshallerFactory.<init>(MarshallerFactory.java:48)
    ... 38 more
    Total time: 5 seconds

    Hi,
    I am new to weblogic. I am encountering an error on trying to run the 'servicegen' command from my ant build scripts, on weblogic 9.2.
    Please find the build.xml snapshot, and the stack trace given below.
    Please help me out with this.
    Points to be noted are:-
    1) The ejb-jar.xml specifies the bean class, which is very much present in the classpath. The ejb-jar.xml is generated by xdoclet. Snapshot is given below:-
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar >
    <description><![CDATA[No Description.]]></description>
    <display-name>Generated by XDoclet</display-name>
    <enterprise-beans>
    <!-- Session Beans -->
    <session >
    <description><![CDATA[NorthBound Interface]]></description>
    <ejb-name>ArcorNBIService</ejb-name>
    <home>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceHome</home>
    <remote>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIService</remote>
    <local-home>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceLocalHome</local-home>
    <local>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceLocal</local>
    <ejb-class>com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    2) When I replace the "ejbJar" attribute in the 'service' command with "javaClassComponents" attribute, I am able to run the servicegen command successfully. Not sure why the ejbJar is creating problems.
    3) Build.xml snapshot:-
         <target name="gen-webservice" depends="init">
              <copy todir="${work.dir}" file="${export.dir}/lib/arcor-il-service-ejb.jar"/>
              <autotype javatypes="${javatypes}" targetNamespace="${targetNamespace}" destDir="${work.dir}/classes" keepGenerated="${keepGenerated}" classpathref="webservice.client.classpath"/>
              <autotype javaComponents="com.alcatel.hdm.arcoril.webservice.ejb.ArcorNBIService" targetNamespace="com.alcatel.hdm.service.nbi.dto.holders" destDir="${work.dir}/classes" keepGenerated="true" classpathref="webservice.client.classpath"/>
              <servicegen destEar="${earfile}" warName="${warname}" contextURI="${contextURI}" keepGenerated="${keepGenerated}" classpathref="webservice.client.classpath">
                   <service ejbJar="${ejbLocation}" targetNamespace="${targetNamespace}" serviceName="${serviceName}" serviceURI="/${serviceName}" generateTypes="false" expandMethods="${expandMethods}" ignoreAuthHeader="false" protocol="https" style="rpc" useSOAP12="${useSOAP12}" typeMappingFile="${work.dir}/classes/types.xml">
                        <security enablePasswordAuth="true"/>
                   </service>
              </servicegen>
         </target>
    4) Exception stacktrace:-
    --- Nested Exception ---
    java.lang.AssertionError: java.io.IOException
    at weblogic.descriptor.DescriptorManager$DefaultMarshallerFactorySingleton.<clinit>(DescriptorManager.java:42)
    at weblogic.descriptor.DescriptorManager.getDefaultMF(DescriptorManager.java:116)
    at weblogic.descriptor.DescriptorManager.getMarshallerFactory(DescriptorManager.java:125)
    at weblogic.descriptor.DescriptorManager.getDescriptorFactory(DescriptorManager.java:153)
    at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:277)
    at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:248)
    at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:309)
    at weblogic.descriptor.EditableDescriptorManager.createDescriptor(EditableDescriptorManager.java:99)
    at weblogic.application.descriptor.AbstractDescriptorLoader.createDescriptor(AbstractDescriptorLoader.java:344)
    at weblogic.application.descriptor.CachingDescriptorLoader.createDescriptor(CachingDescriptorLoader.java:188)
    at weblogic.application.descriptor.AbstractDescriptorLoader.createDescriptor(AbstractDescriptorLoader.java:328)
    at weblogic.application.descriptor.AbstractDescriptorLoader.getDescriptor(AbstractDescriptorLoader.java:237)
    at weblogic.application.descriptor.AbstractDescriptorLoader.getRootDescriptorBean(AbstractDescriptorLoader.java:217)
    at weblogic.ejb.spi.EjbJarDescriptor.getEjbJarBean(EjbJarDescriptor.java:141)
    at weblogic.ejb.spi.EjbJarDescriptor.getEditableEjbJarBean(EjbJarDescriptor.java:182)
    at weblogic.ejb.container.dd.xml.DDUtils.processEjbJarXMLWithSchema(DDUtils.java:519)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:182)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:126)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:154)
    at weblogic.ejb.container.dd.xml.DDUtils.createDescriptorFromJarFile(DDUtils.java:147)
    at weblogic.ejb.spi.DDUtils.createDescriptorFromJarFile(DDUtils.java:30)
    at weblogic.webservice.dd.EJBJarIntrospector.<init>(EJBJarIntrospector.java:52)
    at weblogic.ant.taskdefs.webservices.autotype.EJBAutoTyper.<init>(EJBAutoTyper.java:68)
    at weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.runAutoTyper(ServiceGenTask.java:339)
    at weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.generateService(ServiceGenTask.java:313)
    at weblogic.ant.taskdefs.webservices.servicegen.ServiceGenTask.execute(ServiceGenTask.java:181)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    at org.apache.tools.ant.Main.runBuild(Main.java:668)
    at org.apache.tools.ant.Main.startAnt(Main.java:187)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
    Caused by: java.io.IOException
    at weblogic.descriptor.internal.MarshallerFactory.<init>(MarshallerFactory.java:50)
    at weblogic.descriptor.DescriptorManager$DefaultMarshallerFactorySingleton.<clinit>(DescriptorManager.java:40)
    ... 37 more
    Caused by: com.bea.xml.XmlException: unable to load type library from classloader weblogic.utils.classloaders.ClasspathClassLoader@1cc0a7f f
    inder: weblogic.utils.classloaders.CodeGenClassFinder@c52200 annotation:
    at com.bea.staxb.runtime.internal.BindingContextFactoryImpl.createBindingContext(BindingContextFactoryImpl.java:50)
    at weblogic.descriptor.internal.MarshallerFactory.<init>(MarshallerFactory.java:48)
    ... 38 more
    Total time: 5 seconds

  • HOT Redeployment of EAR fails with Classloader error

    App Server: WLS 10.3
    OS: Solaris 9
    I have installed WLS installed with a domain, admin and a managed server. Everything is working fine.
    I have WAR and EAR deployed successfully on the Managed Server.
    HOT deployment of WAR files works perfectly fine.
    There is this EAR "IIA.ear" with @ 8 WAR files and 1 jar "Manager.jar". The EAR has been deployed in the "nostage" mode.
    I do not have any separate "Deployment" plan.
    In order to "redeploy" the EAR I go to the Admin console >> Deployments >> Select the EAR >> update >> Source Path remains the same >> Finish
    I get the following error :
    +#####################+
    weblogic.application.CannotRedeployException: Module 'Manager.jar' has the same ClassLoader as the Application 'IIA'. Consider redeploying the entire application.
    Update operation failed - no deployments changed.
    +#####################+
    The log files shows below error
    +#####################+
    +<Sep 15, 2009 9:18:52 AM MEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with+
    ID '1252999132033' for task '8'. Error is: 'weblogic.application.CannotRedeployException: Module 'Manager.jar' has the
    same ClassLoader as the Application 'IIA'. Consider redeploying the entire application.'
    weblogic.application.CannotRedeployException: Module 'Manager.jar' has the same ClassLoader as the Application 'IIA'. Consider redeploying the entire application.
    at weblogic.application.internal.AppClassLoaderManagerImpl.updatePartialDeploySet(AppClassLoaderManagerImpl.java:299)
    at weblogic.application.internal.flow.TailModuleRedeployFlow.validateClassLoaderStructure(TailModuleRedeployFlow.java
    +:135)+
    at weblogic.application.internal.flow.TailModuleRedeployFlow.validateRedeploy(TailModuleRedeployFlow.java:97)
    at weblogic.application.internal.BaseDeployment$ValidateRedeployStateChange.next(BaseDeployment.java:801)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
    Truncated. see log file for complete stacktrace
    +>+
    +#####################+
    does WLS 10 supports HOT deployment of EAR files? Is it any issue with "Class Loading"? Anything to be changed to make this HOT redeployment successful?

    App Server: WLS 10.3
    OS: Solaris 9
    I have installed WLS installed with a domain, admin and a managed server. Everything is working fine.
    I have WAR and EAR deployed successfully on the Managed Server.
    HOT deployment of WAR files works perfectly fine.
    There is this EAR "IIA.ear" with @ 8 WAR files and 1 jar "Manager.jar". The EAR has been deployed in the "nostage" mode.
    I do not have any separate "Deployment" plan.
    In order to "redeploy" the EAR I go to the Admin console >> Deployments >> Select the EAR >> update >> Source Path remains the same >> Finish
    I get the following error :
    +#####################+
    weblogic.application.CannotRedeployException: Module 'Manager.jar' has the same ClassLoader as the Application 'IIA'. Consider redeploying the entire application.
    Update operation failed - no deployments changed.
    +#####################+
    The log files shows below error
    +#####################+
    +<Sep 15, 2009 9:18:52 AM MEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with+
    ID '1252999132033' for task '8'. Error is: 'weblogic.application.CannotRedeployException: Module 'Manager.jar' has the
    same ClassLoader as the Application 'IIA'. Consider redeploying the entire application.'
    weblogic.application.CannotRedeployException: Module 'Manager.jar' has the same ClassLoader as the Application 'IIA'. Consider redeploying the entire application.
    at weblogic.application.internal.AppClassLoaderManagerImpl.updatePartialDeploySet(AppClassLoaderManagerImpl.java:299)
    at weblogic.application.internal.flow.TailModuleRedeployFlow.validateClassLoaderStructure(TailModuleRedeployFlow.java
    +:135)+
    at weblogic.application.internal.flow.TailModuleRedeployFlow.validateRedeploy(TailModuleRedeployFlow.java:97)
    at weblogic.application.internal.BaseDeployment$ValidateRedeployStateChange.next(BaseDeployment.java:801)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
    Truncated. see log file for complete stacktrace
    +>+
    +#####################+
    does WLS 10 supports HOT deployment of EAR files? Is it any issue with "Class Loading"? Anything to be changed to make this HOT redeployment successful?

  • Loading an entire JAR via a classloader

    Hi how would I load an entire JAR file via a classloader. Currently I'm able to load one file at a time (in this case org.w3c.dom.Node) as shown below:
    import java.net.*;
    public class MyJarLoader {
       public static void main(String [] args) throws Exception {
         URL[] urlsToLoadFrom = new URL[]{new URL("file:subdir3/xml-apis.jar")};
         URLClassLoader loader1 = new URLClassLoader(urlsToLoadFrom);
         Class cls1 = Class.forName("org.w3c.dom.Node", true, loader1);
         System.out.println("Loaded '"+cls1.getName()+"'");
         org.w3c.dom.Node Node = (org.w3c.dom.Node) cls1.newInstance();
    Thanks

    Figured this one out as below. Note this is the simplistic solution since it requires that the jar files be present in the classpath. If not, you will have to write your own loadClass method to read the data from the zip (& then can't use the method 'Class.forName()').
    Regards
    //Load Apache JAR files
    URL[] urlArrToLoadFrom = new URL[]{new URL("file:xalan-j_2_5_0/xml-apis.jar"),
                new URL("file:xalan-j_2_5_0/xercesImpl.jar"), new URL("file:xalan-j_2_5_0/xalan.jar")};
    //Create a URLClassLoader to access jar files
    URLClassLoader urlLoaderGeneric = new URLClassLoader(urlArrToLoadFrom);
    //Foreach jar file, open, load class files & close
    for(int i=0; i<urlArrToLoadFrom.length; i++) {
    //Debug
       System.out.println(urlArrToLoadFrom.toString());
       //Open zip file
       ZipFile zf = new ZipFile(urlArrToLoadFrom[i].getFile());
       for (Enumeration enum = zf.entries(); enum.hasMoreElements();) {
         //Get entry
         ZipEntry ze = (ZipEntry) enum.nextElement();
         //Only load if it's not a directory and it's a class file
         int iIndexClass = -1;
         if (!ze.isDirectory() && ((iIndexClass = ze.getName().indexOf(".class")) != -1)) {
             //Remove .class & replace / with .
             String strApacheClassName = (ze.getName().substring(0,iIndexClass)).replace('/','.');
             //Load class file
             Class classApache = Class.forName(strApacheClassName, true, urlLoaderGeneric);
             System.out.println("Loaded '"+classApache.getName()+"'");
       //Close zip
       zf.close();

  • Loading a jar via a custom classloader

    Hi,
    I have written a custom class loader that allows me to load a compiled java program as a collection of class files at runtime.
    This is nice however I now need to consider the runtime execution of more complex java programs that have custom library dependencies.
    This means loading a .jar library into the classloader. I can get the contents of a jar and load specific classes by name via reflection but I want to load the entire jar into the classloader so that its contents can be used 'as needed' much like a jar on the system classpath.
    Is this possible? If so I would like to know how as I have been struggling with this problem and cannot see a solution.
    Regards,
    Stephen

    However I still don't understand why you need to
    actually load all those classes initially. Afterall,
    URLClassLoader (which sounds a lot like what youare
    describing) only loads classes as needed.i have just built a swing app that accesses an oracle
    database, i jared together all the classes, and i did
    something in the manfest file so that you can just
    double clisk the jar and it fires up like an exe.
    doing it this way everything is fine except it cannot
    access the database, the reason is those oracle
    classes are not loaded, even they are on the path - i
    can run the app using a batch file but i dont like it
    as it opens up a dos window. this is an example, as i
    was told, where it is necessary to load all thoses
    oracle database classes initially. Dear, daFei.
    I believe that you are getting confused between the way the system will ignore that CLASPPATH environment variable when you run a java application packaged as a jar file with the -jar switch (the classpath for the jar can be set in the manifest) and what I am attempting to-do which is to run a compiled java program at runtime and dynamically load any dependant libraries.
    Stephen

  • Replacing JAR files loaded by custom ClassLoader

    Hi all,
    I am trying to create an auto-updater for a stand alone application, which can look for new versions of relevant jar files on the internet and download them. I have code which will look for newly downloaded versions and can replace the old jar file with the new one (using simple File methods). This works fine for when the application is started initially, but as the application is a server and may not manually be started for a long time, I am trying to force the server to restart and reload with the new code.
    if(newCode.exists()) {
         System.out.println("new code!");
         if(oldCode.exists()) {
              oldCode.delete();
         if(code.exists()) {
              if(! code.renameTo(oldCode)) {
                        throw new IOException("Error backing up code file");
         if(! newCode.renameTo(code)) {
              throw new IOException("Error installing new code file");
    }I have looked around the forums a bit, and have come up with using a ClassLoader based on URLClassLoader:
    class ProxyLoader extends URLClassLoader
         public ProxyLoader(String jarFile) throws MalformedURLException {
              super(new URL[] { (new File(jarFile)).toURL() });
         public Class findClass(String name) throws ClassNotFoundException {
              System.out.println("Finding: " + name);
              return super.findClass(name);
    }This seems to work OK, as all the classes from the jar file are loaded by this classloader.
    I have a method which can create an instance of the class loader, and load the server application.
    private boolean startProxy(int port) {
         try {
              pl = new ProxyLoader("proxy.jar");
              Class ptClass = pl.loadClass("proxy.POPThread");
              pt = ptClass.newInstance();
              Method ptStart = ptClass.getMethod("start", new Class[0]);
              ptStart.invoke(pt, new Object[0]);
              return true;
         } catch(Exception e) {
              return false;
    }I also have a method to shut down the server:
    private boolean stopProxy() {
         try {
              Class ptClass = pl.loadClass("proxy.POPThread");
              Method ptInterrupt = ptClass.getMethod("interrupt", new Class[0]);
              ptInterrupt.invoke(pt, new Object[0]);
              return true;
         } catch(Exception e) {
              return false;
    }These appear to be working fine, the problem I have however is when I try to rename the existing jar file (proxy.jar) in order to replace it with a new one (proxy.new), the renameTo method on the File object fails. I am guessing that is because the proxy.jar file is still in use by the JVM. I have tried setting the classloader var to null, but this doesnt seem to have any effect.
    My main question is how can I 'free' the jar file so that it can be replaced with new code? Is it possible? My only otherway of working around this is to have a variable stored in a file pointing at the 'current' code, but the jar file isn't litterally replaced.
    This is a standalone application, which will probably run in a startup script on a server, so webstart isn't really an option.
    TIA
    iklesteve

    I have found this to be true anytime I try to use the renameTo() API to rename a file with a .jar file extension (regardless of the actual file type - i.e. it could be a text file with .jar appended and it will still fail) in the case where the class making the renameTo() call is loaded from another .jar file.
    I run the same exact code after extracting from the .jar, then the rename to the other .jar file is successful. Also, if I rename the .jar file to a ".ja" file, I can successfully rename the jar file even if the code is running with the context of another .jar file.
    Is this some kind of bogus security measure within the JVM or is it a bug?

  • Loading jar at runtime using custom classloader

    Hi,
    I'm trying to load a jar file to an application running inside weblogic at runtime.
    I followed the example that was posted at
    http://dev2dev.bea.com/cs/user/blog?file=/blog/jcscoobyrs/archive/2005/05/realworld_use_f.html
    and did the following:
    URLClassLoader loader = null;
    URL[] urls = {new URL("file:///" + "C:/Program Files/aaa/WEB-INF/lib/ImportTest3.jar")};
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader loader = new URLClassLoader(urls, classLoader);
    Thread.currentThread().setContextClassLoader(loader);
    Class customClass = Class.forName(className, true, loader);
    customCode = customClass.newInstance();
    Thread.currentThread().setContextClassLoader(classLoader);
    everything works fine when I access my application once.
    But when I'm trying to do the same again, everything fails.
    Any ideas?
    Thanks!

    When you say everything fails - can you clarify the failure? Can you paste the stacktrace? Is it a ClassNotFoundException?

  • Problem with behavior of the Thread Context ClassLoader on OC4J 10.1.3.2.0

    Hi,
    We run into different behavior of the Thread Context ClassLoader on OC4J 10.1.3.1.0 (which is OK) and OC4J 10.1.3.2.0 (here we have problems). It appeared in the Threads directly and indirectly (e.g. through Timer) created by our application. Threads, created by OC4j (e.g. the Thread, where our start-up servlet are running) are OK.
    Thread Context ClassLoader (could be received from Thread.currentThread().getContextClassLoader()) on OC4J 10.1.3.1.0 in all threads is the same ClassLoader instance as the current ClassLoader (could be received from getClass().getClassLoader()). Actually the same is true for JBoss, WebLogic and WebSphere.
    Thread Context ClassLoader on OC4J 10.1.3.2.0 is NOT the same ClassLoader instance as the current ClassLoader, it is even the instance of the different Class. This ClassLoader does not see classes, available at application level, which causes multiple problems.
    Is it possible to configure OC4J 10.1.3.2.0 to behave similar to OC4J 10.1.3.1.0?
    We tried to use “–userThreads”, but it did not help.
    To investigate this problem we created a simple Web Application, which has Start-up Servlet, creates one thread and one Timer Task. From each point it is checking if Thread Context ClassLoader is the same ClassLoader instance as the current ClassLoader and printing Class Loaders if they are different. In addition it checks if correct parser accessed (should be xerces, which is in the Web App classpath and for which we added a shared library). Below you could see what we received on OC4J 10.1.3.1.0 (which is OK) and OC4J 10.1.3.2.0:
    E:\OracleAS_1\j2ee\home>java -Xms128m -Xmx1024m -jar oc4j.jar -userThreads
    07/04/30 10:33:00 Oracle Containers for J2EE 10g (10.1.3.1.0) initialized
    07/04/30 10:39:31 ------In StartupServlet Init-----
    07/04/30 10:39:31 +++++++ ++++++++++++++++++++++++++++++++++++ ++++++++
    07/04/30 10:39:31 +++++++ Executing Code in the StrtServlet... ++++++++
    07/04/30 10:39:31 +++++++ (this Thread created by App Server) +++++++++
    07/04/30 10:39:31 ClassLoaders: fromClass = getClass().getClassLoader() = <TestL
    oaders.web.TestLoaders:0.0.0>*******<class oracle.classloader.PolicyClassLoader
    07/04/30 10:39:31 fromThread =Thread.currentThread().getContextCla
    ssLoader() = <TestLoaders.web.TestLoaders:0.0.0>*******<class oracle.classloader
    .PolicyClassLoader
    07/04/30 10:39:31 ******* THE SAME CLASSLOADER USED IN BOTH PLACES!!! *******
    07/04/30 10:39:31 DocumentBuilderFactory = <org.apache.xerces.jaxp.DocumentBuild
    erFactoryImpl@1908ba7>*******
    07/04/30 10:39:31 C O R R E C T !!!
    07/04/30 10:39:31 -CWD- =E:\OracleAS_1\j2ee\home; uer directory = E:\OracleAS_1\
    j2ee\home
    07/04/30 10:39:31 Constructing the Timer Task...
    07/04/30 10:39:31 Starting some Timer...
    07/04/30 10:39:31 Some Timer is started ...
    07/04/30 10:39:31 ------All actions done Successfully--------
    07/04/30 10:39:41 +++++++ +++++++++++++++++++++++++++++++++++ ++++++++
    07/04/30 10:39:41 +++++++ Executing Code in the new Thread... ++++++++
    07/04/30 10:39:41 ClassLoaders: fromClass = getClass().getClassLoader() = <TestL
    oaders.web.TestLoaders:0.0.0>*******<class oracle.classloader.PolicyClassLoader
    07/04/30 10:39:41 fromThread =Thread.currentThread().getContextCla
    ssLoader() = <TestLoaders.web.TestLoaders:0.0.0>*******<class oracle.classloader
    .PolicyClassLoader
    07/04/30 10:39:41 ******* THE SAME CLASSLOADER USED IN BOTH PLACES!!! *******
    07/04/30 10:39:41 DocumentBuilderFactory = <org.apache.xerces.jaxp.DocumentBuild
    erFactoryImpl@17e5e56>*******
    07/04/30 10:39:41 C O R R E C T !!!
    07/04/30 10:40:31 +++++++ +++++++++++++++++++++++++++++++++++ ++++++++
    07/04/30 10:40:31 +++++++ Executing the Session Timer Task... ++++++++
    07/04/30 10:40:31 ClassLoaders: fromClass = getClass().getClassLoader() = <TestL
    oaders.web.TestLoaders:0.0.0>*******<class oracle.classloader.PolicyClassLoader
    07/04/30 10:40:31 fromThread =Thread.currentThread().getContextCla
    ssLoader() = <TestLoaders.web.TestLoaders:0.0.0>*******<class oracle.classloader
    .PolicyClassLoader
    07/04/30 10:40:31 ******* THE SAME CLASSLOADER USED IN BOTH PLACES!!! *******
    07/04/30 10:40:31 DocumentBuilderFactory = <org.apache.xerces.jaxp.DocumentBuild
    erFactoryImpl@1c6988d>*******
    07/04/30 10:40:31 C O R R E C T !!!
    07/04/30 10:44:01 Shutting down OC4J...
    07/04/30 10:44:01
    E:\OracleAS_1\j2ee\home>
    C:\oc4j\j2ee\home>java -Xms128m -Xmx1024m -classpath .;oc4j.jar;C:\oc4j\j2ee\hom
    e\properties -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socke
    t,address=3999,server=y,suspend=n -jar oc4j.jar -userThreads
    07/05/01 21:14:33 ------In StartupServlet Init-----
    07/05/01 21:14:33 +++++++ ++++++++++++++++++++++++++++++++++++ ++++++++
    07/05/01 21:14:33 +++++++ Executing Code in the StrtServlet... ++++++++
    07/05/01 21:14:33 +++++++ (this Thread created by App Server) +++++++++
    07/05/01 21:14:33 ClassLoaders: fromClass = getClass().getClassLoader() = <TestL
    oaders.web.TestLoaders:0.0.0>*******<class oracle.classloader.PolicyClassLoader
    07/05/01 21:14:33 fromThread =Thread.currentThread().getContextCla
    ssLoader() = <TestLoaders.web.TestLoaders:0.0.0>*******<class oracle.classloader
    .PolicyClassLoader
    07/05/01 21:14:33 ******* THE SAME CLASSLOADER USED IN BOTH PLACES!!! *******
    07/05/01 21:14:33 DocumentBuilderFactory = <org.apache.xerces.jaxp.DocumentBuild
    erFactoryImpl@723c42>*******
    07/05/01 21:14:33 C O R R E C T !!!
    07/05/01 21:14:33 -CWD- =C:\oc4j\j2ee\home; uer directory = C:\oc4j\j2ee\home
    07/05/01 21:14:33 Constructing the Timer Task...
    07/05/01 21:14:33 Starting some Timer...
    07/05/01 21:14:33 Some Timer is started ...
    07/05/01 21:14:33 ------All actions done Successfully--------
    07/05/01 21:14:33 Oracle Containers for J2EE 10g (10.1.3.2.0) initialized
    07/05/01 21:14:43 +++++++ +++++++++++++++++++++++++++++++++++ ++++++++
    07/05/01 21:14:43 +++++++ Executing Code in the new Thread... ++++++++
    07/05/01 21:14:43 ClassLoaders: fromClass = getClass().getClassLoader() = <TestL
    oaders.web.TestLoaders:0.0.0>*******<class oracle.classloader.PolicyClassLoader
    07/05/01 21:14:43 fromThread =Thread.currentThread().getContextCla
    ssLoader() = <[ThreadContextLoader, current context: TestLoaders.web.TestLoaders
    :0.0.0]>*******<class com.evermind.server.ApplicationContextClassLoader
    07/05/01 21:14:43 ******************************************************
    07/05/01 21:14:43 Chain of ClassLoaders from Class
    07/05/01 21:14:43 --- TestLoaders.root:0.0.0 --- class oracle.classloader.Polic
    yClassLoader
    07/05/01 21:14:43 --- default.root:0.0.0 --- class oracle.classloader.PolicyCla
    ssLoader
    07/05/01 21:14:43 --- system.root:0.0.0 --- class oracle.classloader.PolicyClas
    sLoader
    07/05/01 21:14:43 --- oc4j:10.1.3 --- class oracle.classloader.PolicyClassLoade
    r
    07/05/01 21:14:43 --- api:1.4.0 --- class oracle.classloader.PolicyClassLoader
    07/05/01 21:14:43 --- jre.extension:0.0.0 --- class oracle.classloader.PolicyCl
    assLoader
    07/05/01 21:14:43 --- jre.bootstrap:1.4.2_08 --- class oracle.classloader.Polic
    yClassLoader
    07/05/01 21:14:43 --- null ---
    07/05/01 21:14:43 ********** End of Chain of ClassLoaders **************
    07/05/01 21:14:43 ******************************************************
    07/05/01 21:14:43 Chain of ClassLoaders from Thread
    07/05/01 21:14:43 --- oc4j:10.1.3 --- class oracle.classloader.PolicyClassLoade
    r
    07/05/01 21:14:43 --- api:1.4.0 --- class oracle.classloader.PolicyClassLoader
    07/05/01 21:14:43 --- jre.extension:0.0.0 --- class oracle.classloader.PolicyCl
    assLoader
    07/05/01 21:14:43 --- jre.bootstrap:1.4.2_08 --- class oracle.classloader.Polic
    yClassLoader
    07/05/01 21:14:43 --- null ---
    07/05/01 21:14:43 ********** End of Chain of ClassLoaders **************
    07/05/01 21:14:43 DocumentBuilderFactory = <oracle.xml.jaxp.JXDocumentBuilderFac
    tory@74a138>*******
    07/05/01 21:14:43 WRONG !!! Should be org.apache.xerces.jaxp.DocumentBuilderFact
    oryImpl
    07/05/01 21:15:33 +++++++ +++++++++++++++++++++++++++++++++++ ++++++++
    07/05/01 21:15:33 +++++++ Executing the Session Timer Task... ++++++++
    07/05/01 21:15:33 ClassLoaders: fromClass = getClass().getClassLoader() = <TestL
    oaders.web.TestLoaders:0.0.0>*******<class oracle.classloader.PolicyClassLoader
    07/05/01 21:15:33 fromThread =Thread.currentThread().getContextCla
    ssLoader() = <[ThreadContextLoader, current context: TestLoaders.web.TestLoaders
    :0.0.0]>*******<class com.evermind.server.ApplicationContextClassLoader
    07/05/01 21:15:33 **************************************************
    07/05/01 21:15:33 Chain of ClassLoaders from Class
    07/05/01 21:15:33 --- TestLoaders.root:0.0.0 --- class oracle.classloader.Polic
    yClassLoader
    07/05/01 21:15:33 --- default.root:0.0.0 --- class oracle.classloader.PolicyCla
    ssLoader
    07/05/01 21:15:33 --- system.root:0.0.0 --- class oracle.classloader.PolicyClas
    sLoader
    07/05/01 21:15:33 --- oc4j:10.1.3 --- class oracle.classloader.PolicyClassLoade
    r
    07/05/01 21:15:33 --- api:1.4.0 --- class oracle.classloader.PolicyClassLoader
    07/05/01 21:15:33 --- jre.extension:0.0.0 --- class oracle.classloader.PolicyCl
    assLoader
    07/05/01 21:15:33 --- jre.bootstrap:1.4.2_08 --- class oracle.classloader.Polic
    yClassLoader
    07/05/01 21:15:33 --- null ---
    07/05/01 21:15:33 ********** End of Chain of ClassLoaders **********
    07/05/01 21:15:33 **************************************************
    07/05/01 21:15:33 Chain of ClassLoaders from Thread
    07/05/01 21:15:33 --- oc4j:10.1.3 --- class oracle.classloader.PolicyClassLoade
    r
    07/05/01 21:15:33 --- api:1.4.0 --- class oracle.classloader.PolicyClassLoader
    07/05/01 21:15:33 --- jre.extension:0.0.0 --- class oracle.classloader.PolicyCl
    assLoader
    07/05/01 21:15:33 --- jre.bootstrap:1.4.2_08 --- class oracle.classloader.Polic
    yClassLoader
    07/05/01 21:15:33 --- null ---
    07/05/01 21:15:33 ********** End of Chain of ClassLoaders **********
    07/05/01 21:15:33 DocumentBuilderFactory = <oracle.xml.jaxp.JXDocumentBuilderFac
    tory@1d12d43>*******
    07/05/01 21:15:33 WRONG !!! Should be org.apache.xerces.jaxp.DocumentBuilderFact
    oryImpl
    Any help will be greatly appreciated.
    Thanks

    Sorry for confusion, version of OC4J does not really meter, but jdk does. It happened that in the case where everything OK (OC4J 10.1.3.1.0) I accidentally used jdk 1.5. Now I tried both (OC4J 10.1.3.1.0 and OC4J 10.1.3.2.0) with j2sdk1.4.2_14 (besides I tried j2sdk1.4.2_09 and _08) and j2sdk1.5.0_06.
    With JDK 1.5 everything is OK and with JDK 1.4 we have a problem, described in the previous posting. I believe now I should reformulate my initial question:
    Is it possible to configure OC4J 10.1.3 running under j2sdk1.4.2_14 to force Thread Context ClassLoader to behave similar to OC4J 10.1.3 under j2sdk1.5.0_06? If yes, how we could do it?
    Thanks

Maybe you are looking for

  • Playlists for updating no longer exist

    i am a novice...i deleted my ipod nano playlist from source list...i also updated yesterday...no i keep getting a screen when i connect my ipod to computer that reads, "songs on the ipod cannot be updated because all of the playlists for updating no

  • I really need some enlightening!!!!

    if i purches an application on my account, and i use more then one divise, can i use this application on all my divises or do i have to purches it again?

  • AD stored user Photos do not display in Lync for Mac 2011

    I'm using Lync for Mac 2011 14.0.9 and the my user photo as well as the photos of other users who are using photos stored in our AD do not display.  This behaviour has been occurring at least since 14.0.5.  The behaviour occurs regardless of whether

  • Change date format in table?

    Hi all, I'm trying to make my first VB.NET iview and I need some help! I can already display the results of a RFC in a databound table, but now the dates are displayed in YYYMMDD format. How can I change this to a .NET date (DD/MM/YYYY)? Thanks! Lies

  • Installed iTunes and do not get a Summary screen

    I have just purchased an iPod nano and installed iTunes for downloading. I am successful with music and audiobooks but do not get a Summary screen to allow me to access the tabs described in the online manuals that would allow me to download photos.