Class Loading order/exception in JRockit 31

Hi all,
We recently migrated to Weblogic 10.3.6 and JRockit 31 1.6 (64 bit). I tried to analyze JVM performance using flight recording. I noticed several (around 200K withing 5 minutes!) ClassNotFoundExceptions in the flight recording, but no big issue in the application. This got me curious and I decided to run with Java run-time options verbose:class=trace. This gave more details in the log. I found that for loading every Weblogic class the JRockit first tried 4-5 times and then successfully loaded the class from the Jar file. So for each class I got this exception trace below. I am attaching the example for how the JVM loaded the weblogic.management.scripting.WLST class. My question is:
1. Is this the expected behavior?
2. Is there a better way to load classes in JRockit?
3. Am I just seeing these exceptions because I am setting the Flight recording at a very verbose level?
Please advise. Thanks in advance.
- Shankar.
+[class  ][Fri Sep 21 23:15:37 2012][00514] initiate 621 weblogic/management/scripting/WLST+
+[class  ][Fri Sep 21 23:15:37 2012][00514] 621 weblogic/management/scripting/WLST fail (0.00 ms)+
+[excepti][Fri Sep 21 23:15:37 2012][00514][00004] java/lang/ClassNotFoundException: weblogic.management.scripting.WLST+
at jrockit/vm/Classes.forName(Classes.java:130)
at java/lang/ClassLoader.findBootstrapClass(Ljava/lang/String;)Ljava/lang/Class;(Native Method)
at java/lang/ClassLoader.findBootstrapClassOrNull(ClassLoader.java:926)
at java/lang/ClassLoader.loadClass(ClassLoader.java:297)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at sun/misc/Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at java/lang/ClassLoader.loadClass(ClassLoader.java:247)
at weblogic/WLST.main(WLST.java:27)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
--- End of stack trace
+[excepti][Fri Sep 21 23:15:37 2012][00514][00004] java/lang/ClassNotFoundException: weblogic.management.scripting.WLST+
at java/net/URLClassLoader$1.run(URLClassLoader.java:202)
at jrockit/vm/AccessController.doPrivileged(AccessController.java:254)
at java/net/URLClassLoader.findClass(URLClassLoader.java:190)
at sun/misc/Launcher$ExtClassLoader.findClass(Launcher.java:234)
at java/lang/ClassLoader.loadClass(ClassLoader.java:306)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at sun/misc/Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at java/lang/ClassLoader.loadClass(ClassLoader.java:247)
at weblogic/WLST.main(WLST.java:27)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
--- End of stack trace
+[excepti][Fri Sep 21 23:15:37 2012][00514][00004] java/security/PrivilegedActionException:+
at jrockit/vm/AccessController.doPrivileged(AccessController.java:258)
at java/net/URLClassLoader.findClass(URLClassLoader.java:190)
at sun/misc/Launcher$ExtClassLoader.findClass(Launcher.java:234)
at java/lang/ClassLoader.loadClass(ClassLoader.java:306)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at sun/misc/Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at java/lang/ClassLoader.loadClass(ClassLoader.java:247)
at weblogic/WLST.main(WLST.java:27)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
--- End of stack trace
+[excepti][Fri Sep 21 23:15:37 2012][00514][00004] java/security/PrivilegedActionException:+
at jrockit/vm/AccessController.doPrivileged(AccessController.java:258)
at java/net/URLClassLoader.findClass(URLClassLoader.java:190)
at sun/misc/Launcher$ExtClassLoader.findClass(Launcher.java:234)
at java/lang/ClassLoader.loadClass(ClassLoader.java:306)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at sun/misc/Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at java/lang/ClassLoader.loadClass(ClassLoader.java:247)
at weblogic/WLST.main(WLST.java:27)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
--- End of stack trace
+[excepti][Fri Sep 21 23:15:37 2012][00514][00004] java/lang/ClassNotFoundException: weblogic.management.scripting.WLST+
at java/net/URLClassLoader$1.run(URLClassLoader.java:202)
at jrockit/vm/AccessController.doPrivileged(AccessController.java:254)
at java/net/URLClassLoader.findClass(URLClassLoader.java:190)
at sun/misc/Launcher$ExtClassLoader.findClass(Launcher.java:234)
at java/lang/ClassLoader.loadClass(ClassLoader.java:306)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at sun/misc/Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at java/lang/ClassLoader.loadClass(ClassLoader.java:247)
at weblogic/WLST.main(WLST.java:27)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
--- End of stack trace
+[excepti][Fri Sep 21 23:15:37 2012][00514][00004] java/lang/ClassNotFoundException: weblogic.management.scripting.WLST+
at java/net/URLClassLoader$1.run(URLClassLoader.java:202)
at jrockit/vm/AccessController.doPrivileged(AccessController.java:254)
at java/net/URLClassLoader.findClass(URLClassLoader.java:190)
at sun/misc/Launcher$ExtClassLoader.findClass(Launcher.java:234)
at java/lang/ClassLoader.loadClass(ClassLoader.java:306)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at sun/misc/Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java/lang/ClassLoader.loadClass(ClassLoader.java:295)
at java/lang/ClassLoader.loadClass(ClassLoader.java:247)
at weblogic/WLST.main(WLST.java:27)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
--- End of stack trace
+[load   ][Fri Sep 21 23:15:37 2012][00514] define #556 weblogic/management/scripting/WLST, src=file:/opt/apps/weblogic11g/wlserver_10.3/server/lib/weblogic.jar+

Hi Shankar,
I seen several BUGs based on this issue better open a ticket with WLS support.
Regards,
Kal

Similar Messages

  • Class loading order

    A Java tutorial, http://java.sun.com/docs/books/tutorial/ext/basics/load.html, tells:
    <quote>
    ... the class path is searched only if a class to be loaded hasn't been found among the classes in
    rt.jar, i18n.jar or the installed extensions.
    </quote>
    However, for example, if we inadvertently have a String.class in the classpath, current directory,
    and run the code below:
    java Test
    public class Test{
      public static void main(String[] args){
        System.out.println("Test");
    }we get an exception:
    Exception in thread "main" java.lang.NoSuchMethodError: mainWhy is our bad String.class not ignored, in the first place?

    I think the implicit "import java.lang.*" is a
    type-import-on-demand in the
    sense of the JLS 7.5.2
    These never cause any other declaration to be
    shadowed.
    If I understand the example given in JLS 7.5.2
    correctly, java.lang.String
    will be shadowed "by a type named [String] and
    declared in the
    package to which the compilation unit belongs". (As
    you don't want).OK. Thanks. Your reply has swept the little cloud above my brain.
    The javadoc documentation should have been written as:
    <vquote>
    The compiler searches for class files first in the bootstrap and extension classes, then in the
    user class path (which by default is the current directory). If the class name is under some
    shadowing(JLS 7.5.2), however, a specific search order isn't guaranteed.
    </vquote>
    Thanks again, pb.

  • Order of class loading in a Web Application

    Hi,
    I have been trying to find out if there is a defined order in which classes contained in WEB-INF/classes
    and/or WEB-INF/lib should be loaded.
    There doesn't appear to be any mention of class loading order in either the J2EE 1.3 or J2EE 1.4
    specifications. That does not mean that there isn't a defined class load order, it just means I haven't found one.
    Typical behaviour from servers such as Tomcat (reference implementation of the Servlet Engine) show
    that classes in WEB-INF/classes are loaded before classes contained in jars under WEB-INF/lib.
    Because there doesn't appear to be a mandated class load order I cannot assume that the same
    behaviour holds for all servers, unless someone here knows better of course.
    The reason for the question is that relying on the exhibited class load order means we can patch web applications by simply putting the patch under the WEB-INF/classes directory.
    If this should not be relied upon then patches will have to be applied directly to the affected jar files,
    this is not a problem in itself however it is nice to be able to keep the patches out of the jars for
    ease of rolling back patches without having to copy jar files all over the place.
    Any insights would be welcome.
    Thanks

    If you say that it is server specific i don't find
    that to be the correct answer b'cozI didn't give an answer, I am looking for one. I gave an example of the behaviour that Tomcat 4.1.x
    exhibits, one that we currently make use of for patching web applications. My question was about
    whether or not this behaviour can be relied upon.
    the class files are depended on the jar files which
    need to checked in first before getting loaded b'coz
    it should check for dependent files before only while
    getting deployed.This is why the class load order is important.
    Is the Web Application Classloader going to look in WEB-INF/classes first every time followed
    by WEB-INF/lib everytime, is the order undefined, or is it reversed?
    More over if you just think of class loading mechanism
    of classes folder only then it is loaded in the order
    specified in the web.xml file.
    in this we specify the order of loading.As far as I know web.xml does not allow you to specify where classes should be loaded from and in
    which classpath order, you define which classes should be used for application components.
    The only load order you can specify is the load order of servlets on startup.
    If you know different I would love to know how you would configure web.xml to specify the classpath order
    in which classes are loaded.

  • Unknown deployment tag - web-app-class-loader

    I can create the ear file with jdeveloper, but when deploy in 9iAs with the ear file, the next error apaers:
    Deployment failed:
    Unknown deployment tag in
    orion-web.xml:
    <web-app-class-loader>;
    nested exception is:
    java.lang.InstantiationException:
    when deploy the system show the web module.
    I have a CMP entity bean and too show in deploy.
    I don't know wath can I do.
    Please Help Me
    Miguel Angel Caro
    [email protected]

    I manually hacked the EAR file generated by JDeveloper 10g and removed the offending tag from the orion-web.xml
    After removing the tag I was able to deploy the EAR to 9iAS (9.0.2.3) but now I am getting runtime errors...
    Anyone who has gone through this please let me know!
    Thanks!

  • Detecting when exception was thrown using custom class loader

    Hello all,
    I would like to implement the solution described here - http://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java - that uses custom class loader in order to detect when an Exeption thrown somewhere in the JVM hosting my app, please note that exceptions might be thrown from 3rd party jars the app is using. So, thanks to help I got from another post, I've managed to code the custom class loader. My question is how can the class loader wrap the original exception, as the methods in ClassLoader deals with classes, not instances. So where should I set the original exception?
    Thanks!
    Edited by: user9355666 on Sep 28, 2010 10:48 PM

    user9355666 wrote:
    I think I'm missing something fundumental, forgive me for being slow...
    This is what I did so far. For the exception wrapper I made a simple class extens Exception that recieve Exception in its ctor and store it. I also subclassed ClassLoader and override its loadClass(). I've registered it as the system classloader. My thinking was to check in that point that if the requested class is instance of Exception and if yes, returning my wrapper class wrapping this exception. But, since loadClass() return class, how can I set in the wrapper the original exception?
    In addition, let's say 2 different places in the code throws NPE, to my understanding the classloader will load NPE only once, so how throwing the NPE in the second time can be detected?you are missing a key point. you should creating a custom implementation of the NPE class which hooks into your detection code in its constructor. from that point forward, anytime any NPE (which is your custom class) is constructed, you can detect it.

  • ADS: com.adobe.ProcessingException: Class not found exception while loading

    Hi All,
    While i'm trying to activate FORM (Interactive Form in Transaction SFP), i'm getting error -
    ADS: com.adobe.ProcessingException: Class not found exception while loading class SAPForm, classpath: /usr/sap/AHS/DVEBMGS00/exe/jstart7 1.jar/usr/sap/AHS/DVEBMGS00/exe.
    Could anyone let me know the way to resolve this issue.
    Thanks and Regards,
    Sunil

    Many Thanks for the reply-It's working now
    I added the MySQL connector in the following manner
    1)Open the Tom Cat server console by Selecting 'Servers' in Package Explorer
    2)Right Click 'Tomcat v5.5 at localhost.server'
    3)Select 'Open Launch Configuration' under 'General Information'
    4)Select the 'Classpath' tab in the Edit configuration window that opens
    5)Select 'Add External Jars' and add the required connector

  • Class loading exceptions while importing Spring, EHCache in BPMStudio 10g

    Hi,
    We are facing Class loading / Class NOt Found exceptions while importing Spring.jar and EHCache.jar in BPMStudio 10g Catalog and BPM Enterprise Server 10g. Java classes are bundled in an external JAR file. This JAR is referencing Spring and EHCache library. This Java component is invoked from an automatic activity in BPM process. Task execution is failing in BPM workspace in Studio and Enterprise server.
    We tried copying the JARS in the following folders. But nothing is working.
    D:\OraBPMStudioHome\lib
    D:\OraBPMStudioHome\ext
    D:\OraBPMStudioHome\webapps\workspace\WEB-INF\lib
    D:\OraBPMStudioHome\webapps\workspace\WEB-INF\classes
    <Enterprise_Server_WL_Home>/server/<Domain_Lib>

    Ariel,
    You are right. I have already added the JARS as external resource. I am getting the errors while cataloging Java component in BPM Studio in a Catalog Module. I am able to add Log4J Jar as an external resource and catalog the resource as java component. In case one JAR has a dependency on another JAR it is failing to catalog. In Eclipse or Weblogic Workshop 10g, we can add multiple JARS in the Project classpath and it works fine. In case of BPM Studio, we are getting Class Loading or ClassNotFound errors while cataloging multiple JAR files
    Thanks
    Subhabrata

  • Failed loading disp class "HSIService". Exception java.lang.ClassCastExcep

    <Failed loading disp class "HSIService". Exception java.lang.ClassCastExcep
    Posted: 12 Aug 2004 13:36 PM Reply
    I am receiving the following error in most all of the logs when trying to run/test this web service. The service worked fine a day ago, then this happened. I finally rebuilt it entirely in workshop, it ran a couple of times between changes and then started producing this error again. The workshop test browser either states "DispMessage is null" on the test form or if the form appears then it says "get" is not supported for the operation .... and maybe other weird stuff.
    Can you give me an idea of where to specifically look for the problem?? Complete error message is below:
    ####<Aug 12, 2004 3:40:16 PM EDT> <Error> <WLW> <KLRAY8Z> <cgServer>
    <ExecuteThread: '14' for queue: 'weblogic.kernel.Default'> <<anonymous>> <>
    <Failed loading disp class "HSIService". Exception java.lang.ClassCastException at
    com.bea.wlw.runtime.core.dispatcher.TypeUtils.validate(TypeUtils.java:1130)
    at com.bea.wlw.runtime.jws.dispatcher.JwsDispClass.<init>(JwsDispClass.java:398)
    at com.bea.wlw.runtime.jws.dispatcher.JwsDispFile.createPrimaryDispClass(JwsDispFile.java:52)
    at com.bea.wlw.runtime.core.dispatcher.DispFile.<init>(DispFile.java:162)
    at com.bea.wlw.runtime.jws.dispatcher.JwsDispFile.<init>(JwsDispFile.java:44)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at com.bea.wlw.runtime.core.dispatcher.DispUnit.loadDispFile(DispUnit.java:219)
    at com.bea.wlw.runtime.core.dispatcher.DispUnit.<init>(DispUnit.java:153)
    at com.bea.wlw.runtime.core.dispatcher.DispCache.ensureDispUnit(DispCache.java:553)
    at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.getDispUnit(HttpServerHelper.java:491)
    at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.executeGetRequest(HttpServerHelper.java:531)
    at com.bea.wlw.runtime.core.dispatcher.HttpServer.doGet(HttpServer.java:81)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6354)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    >
    --------------------------------------------------------

    FYI - solved this problem. The problem was that I had set a callback handler as an operation like so:
    * @common:operation
    * @common:message-buffer enable="true"
    * @jws:conversation phase="finish"
    public void mycontrol_mycallbackhandler()
    Apparently callback handler's can not be operations.

  • Influencing JAR order for Application Class Loader

              I have seen some questions about this in the past but there has never been a definitive
              reply one way of the other.
              Is it possible to influence the order in which the web application class loader
              looks through the JAR files located in the /WEB-INF/lib directory?
              I have two JAR files - one contains the base release version of some software
              and the other contains some fixes so I need the fixes JAR to be loaded first.
              Thanks
              Gary Johnson
              

    Hi Gary,
              The order jars searched in WEB-INF/lib is not defined.
              You may cosider merging those two jars in one jar.
              Regards,
              Slava Imeshev
              "Gary Johnson" <[email protected]> wrote in message
              news:[email protected]..
              >
              > I have seen some questions about this in the past but there has never been
              a definitive
              > reply one way of the other.
              >
              > Is it possible to influence the order in which the web application class
              loader
              > looks through the JAR files located in the /WEB-INF/lib directory?
              >
              > I have two JAR files - one contains the base release version of some
              software
              > and the other contains some fixes so I need the fixes JAR to be loaded
              first.
              >
              > Thanks
              > Gary Johnson
              

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

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

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

  • Class loader Exception

    I am getting the following error even though the corresponding file is present in the app.jar.
    This happens when hibernates are getting loaded , when i start the oracle app server.
    Does anyone knows why its so.
    Caused by: org.hibernate.MappingException: entity class not found: com.iflex.fcr.app.deposit.td.us.dto.DepositRateHistoryDTOCheckNew
         at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
         at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:166)
         at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
         at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:115)
         at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
         at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
         at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
         at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
         at com.iflex.fcr.infra.das.orm.hibernate.SessionFactoryLoader.<clinit>(Unknown Source)
         ... 5 more
    Caused by: oracle.classloader.util.AnnotatedClassNotFoundException:
         Missing class: com.iflex.fcr.app.deposit.td.us.dto.DepositRateHistoryDTOCheckNew
         Dependent class: org.hibernate.util.ReflectHelper
         Loader: global.libraries:1.0
         Code-Source: /D:/product/10.1.3.1/OracleAS_3/j2ee/FSI_RETAIL/applib/hibernate313.jar
         Configuration: <code-source> in /D:/product/10.1.3.1/OracleAS_3/j2ee/FSI_RETAIL/config/server.xml
    This load was initiated at global.libraries:1.0 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.
         at oracle.classloader.PolicyClassLoader.handleClassNotFound(PolicyClassLoader.java:2078)
         at oracle.classloader.PolicyClassLoader.internalLoadClass(PolicyClassLoader.java:1679)
         at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1635)
         at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1620)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:164)
         at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
         at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
         ... 14 more

    Neither, not using Oracle HTTP Server nor using JDK 1.4 incluence the behaviour of OC4J. It is your application deployment. As it should be with every Java EE server you provide an EAR file structure with modules like WAR files or EJB jar files. Each of these modules has more or less its own class loading environment.
    OC4J however supports application and global shared libraries. Application shared libraries can be packaged in the EAR file using the Java EE 5 library mechanism. In essence your libraries must be known by the class loader of the Java EE module otherwise your application doesn't work.
    What I need to know is what type of application (WAR, EJB, combo of both) you're using and how the files are laid out in the directory structure.
    To have an example, see this blog entry: http://blogs.oracle.com/olaf/2007/07/25
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Application Class Loader problem calling virtual function

    Hello everyone
    I have run in to very strange behavior of JVM
    I have created a class loader which allows my to load classes from
    jar file, regardless that URLClassLoader supplies this functionality.
    I am using this class loader to load some classes and call their virtual functions. The class diagram looks like that:
    public interface I {
       public void init();
    public class AAA implements
       public void init(){
    public class BBB extends AAA{
       public void init(){
          //here comes implementation
    }Interface I and class AAA are loaded with System Class loader and Class BBB is loaded using my class loader from jar file.
    ByteStreamClassLoader  classLoader =  new ByteStreamClassLoader  ();
    Class cl = classLoader. loadClass(�com.product.BBB�,true);
    I myInterface = cl.newInstance();
    myInterface.init();The problem is that from some unknown reason java class AAA.init() instead of BBB.init().
    Can somebody help me what am I doing wrong?
    Class Loader code attached below
      public class ByteStreamClassLoader   extends ClassLoader {
        protected HashMap m_cache = new HashMap();
        public void clearCashe() {
          m_cache = new HashMap();
        private String definePackage(String className) {
          StringBuilder strB = new StringBuilder();
          //Class name must be removed from the URI in order to define a package
          String[] packageArray = className.split("\\.");
          for (int i = 0; i < packageArray.length - 1; i++) {
            strB.append(packageArray).append(".");
    String packageName = strB.toString();
    packageName = packageName.substring(0, packageName.length() - 1);
    if (getPackage(packageName) == null) {
    m_logger.log(Level.FINEST, "Defining package '" + packageName + "'");
    definePackage(packageName, null, null, null, null, null, null, null);
    return packageName;
    public synchronized Class loadClass(String name, boolean resolve) throws
    ClassNotFoundException {
    name = name.replaceAll("/", ".").replaceAll(".class", "");
    //Try to locate the Class in cashe
    Class c = (Class) m_cache.get(name);
    //Try to locate the Class in the System Class Loader
    if (c == null) {
    try {
    c = ClassLoader.getSystemClassLoader().loadClass(name);
    catch (Exception ex) {}
    else {
    m_logger.log(Level.FINEST, "Class '" + name + "' found in cache");
    //Load the class from byte array
    if (c == null) {
    String resourceName = name;
    if (!resourceName.endsWith(".class")) {
    resourceName = resourceName.concat(".class");
    //Retrieve class byte representation
    if (resourceName.indexOf(".") != -1) {
    resourceName =
    resourceName.replaceAll("\\.", "/").replaceAll("/class", ".class");
    //Use the ByteStreamClassLoader to load the class from byte array
    byte[] classByteArray = null;
    try {
    classByteArray = getResourceBytes(resourceName);
    catch (IOException ex1) {
    throw new ClassNotFoundException(
    "Could not load class data." + ex1.getMessage());
    m_logger.log(
    Level.FINEST, "Loading class '" +
    name + "' Byte Length: " + classByteArray.length);
    String p = definePackage(name);
    c = defineClass(
    name,
    classByteArray,
    0,
    classByteArray.length,
    ByteStreamClassLoader.class.getProtectionDomain());
    m_cache.put(name, c);
    if (resolve) {
    resolveClass(c);
    return c;

    Hello everyone
    I have run in to very strange behavior of JVM
    I have created a class loader which allows my to load classes from
    jar file, regardless that URLClassLoader supplies this functionality.
    I am using this class loader to load some classes and call their virtual functions. The class diagram looks like that:
    public interface I {
       public void init();
    public class AAA implements
       public void init(){
    public class BBB extends AAA{
       public void init(){
          //here comes implementation
    }Interface I and class AAA are loaded with System Class loader and Class BBB is loaded using my class loader from jar file.
    ByteStreamClassLoader  classLoader =  new ByteStreamClassLoader  ();
    Class cl = classLoader. loadClass(�com.product.BBB�,true);
    I myInterface = cl.newInstance();
    myInterface.init();The problem is that from some unknown reason java class AAA.init() instead of BBB.init().
    Can somebody help me what am I doing wrong?
    Class Loader code attached below
      public class ByteStreamClassLoader   extends ClassLoader {
        protected HashMap m_cache = new HashMap();
        public void clearCashe() {
          m_cache = new HashMap();
        private String definePackage(String className) {
          StringBuilder strB = new StringBuilder();
          //Class name must be removed from the URI in order to define a package
          String[] packageArray = className.split("\\.");
          for (int i = 0; i < packageArray.length - 1; i++) {
            strB.append(packageArray).append(".");
    String packageName = strB.toString();
    packageName = packageName.substring(0, packageName.length() - 1);
    if (getPackage(packageName) == null) {
    m_logger.log(Level.FINEST, "Defining package '" + packageName + "'");
    definePackage(packageName, null, null, null, null, null, null, null);
    return packageName;
    public synchronized Class loadClass(String name, boolean resolve) throws
    ClassNotFoundException {
    name = name.replaceAll("/", ".").replaceAll(".class", "");
    //Try to locate the Class in cashe
    Class c = (Class) m_cache.get(name);
    //Try to locate the Class in the System Class Loader
    if (c == null) {
    try {
    c = ClassLoader.getSystemClassLoader().loadClass(name);
    catch (Exception ex) {}
    else {
    m_logger.log(Level.FINEST, "Class '" + name + "' found in cache");
    //Load the class from byte array
    if (c == null) {
    String resourceName = name;
    if (!resourceName.endsWith(".class")) {
    resourceName = resourceName.concat(".class");
    //Retrieve class byte representation
    if (resourceName.indexOf(".") != -1) {
    resourceName =
    resourceName.replaceAll("\\.", "/").replaceAll("/class", ".class");
    //Use the ByteStreamClassLoader to load the class from byte array
    byte[] classByteArray = null;
    try {
    classByteArray = getResourceBytes(resourceName);
    catch (IOException ex1) {
    throw new ClassNotFoundException(
    "Could not load class data." + ex1.getMessage());
    m_logger.log(
    Level.FINEST, "Loading class '" +
    name + "' Byte Length: " + classByteArray.length);
    String p = definePackage(name);
    c = defineClass(
    name,
    classByteArray,
    0,
    classByteArray.length,
    ByteStreamClassLoader.class.getProtectionDomain());
    m_cache.put(name, c);
    if (resolve) {
    resolveClass(c);
    return c;

  • Hibernate in Weblogic10 : class not found exception

    Hi All,
    I am using JPA/Hibernate in Weblogic 10. While running the application, I am getting the following exception. Can someone help on this.
    Exception caught is : java.lang.IllegalArgumentException : org.hibernate.QueryException : ClassNotFoundException : org.hibernate.hql.ast.HqlToken [select  p from ParentProfileEntity p where p.email=?1]
    I am using JBoss's seam framework . Copy of the persistence.xml is given below.
         <persistence-unit name="userDatabase" transaction-type="JTA">
         <provider>org.hibernate.ejb.HibernatePersistence</provider>
         <jta-data-source>PNDataSource</jta-data-source>
         <properties>
         <property name="hibernate.archive.autodetection" value="class, hbm"/>
              <property name="hibernate.show_sql" value="true"/>
              <property name="hibernate.format_sql" value="true"/>
              <property name="use_sql_comments" value="true"/>
              <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
              <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>          
         </properties>
         </persistence-unit>
         </persistence>

    Hi,
    It's a problem with the antlr lib that also exist in weblogic.
    You can configure the class loader search order:
    Add a file META-INF/weblogic-application.xml in your EAR:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- weblogic-application xmlns="http://www.bea.com/ns/weblogic/100" -->
    <weblogic-application>
         <prefer-application-packages>
               <package-name>antlr.*</package-name>
         </prefer-application-packages>
    </weblogic-application>You must provide the antlr lib within the EAR.
    Should be ok after that....
    Olivier

  • Dynamic Class Loading in an EJB Container

    Hello,
    We have a need to load classes from a nonstandard place with in an ejb container, ie a database or secure store. In order to do so we have created a custom class loader. Two issues have come up we have not been able to solve, and perhaps some one knows the answer to.
    Issue 1.
    Given the following code:
    public static void main(String args[])
    MyClassLoader loader = new MyClassLoader("lic.dat");
    System.out.println("Loading class ..." + "TestObject");
    Object o = Class.forName("TestObject",true,loader).newInstance();
    System.out.println("Object:" + o.toString());
    TestObject tstObj = (TestObject) o;
    tstObj.doIt();
    What happens when executed is as follows. Class.forName calls our loader and does load the class as we hoped, it returns it as well, and the o.toString() properly executes just fine. The cast of the object to the actual TestObject fails with a class not found exception. We know why this happens but don't know what to do about it. It happens because the class that contains main was loaded by the system class loader (the primordial class loader as its sometimes called), That class loader does not know about TestObject, so when we cast even though the class is "loaded" in memory the class we are in has no knowledge of it, and uses its class loader to attempt to find it, which fails.
    > So the question is how do you let the main class know to use our class loader instead of
    the system class loader dispite the fact is was loaded by the system class loader.
    Issue 2:
    To make matters worse we want to do this with in an EJB container. So it now begs the question how do you inform an EJB container to use a specific class loader for some classes?
    Mike...

    Holy crap! We are in a similar situation. In creating a plugin engine that dynamically loads classes we use a new class loader for each plugin. The purpose is so that we can easily unload and/or reload a class at runtime. This is a feature supposedly done by J2EE app servers for hot-deploy.
    So our plugins are packaged as JAR files. If you put any class in the CLASSPATH, the JVM class loader (or the class loader of the class that is loading the plugin(s)), will load the class. The JavaDoc API states that the parent classloader is first used to see if it can find the class. Even if you create a new URLClassLoader with NULL for parent, it will always use the JVM class loader as its parent. So, ideally, in our couse, plugins will be at web sites, network drives, or outside of the classpath of the application and JVM.
    This feature has two benefits. First, at runtime, new updates of plugins can be loaded without having to restart the app. We are even handling versions and dependencies. Second, during development, especially of large apps that have a long startup time, being able to reload only one plugin as opposed to the annoying startup time of Java apps is great! Speeds up development greatly.
    So, our problem sounds just like yours. Apparently, the Client, which creates an instance of the plugin engine, tries to access a plugin (after the engine loades it via a new classloader instance for each plugin). Apparently, it says NoDefClassFound, because as you say, the client classloader has no idea about the plugin class loaded by another classloader.
    My co-developer came up with one solution, which I really dont like, but seems to be the only way. The client MUST have the class (java .class file) in its classpath in order to work with the class loaded by another class loader. Much like how in an EJB container, the web server calling to EJB MUST contain the Home and Remote interface .class files in its classpath, the same thing needs to be done here. For us, this means if a plugin depends on 5 others, it must contain ALL of the .class files of those plugins it depends on, so that the classloader instance that loads the plugin, can also see those classes and work with them.
    Have you got any other ideas? I really dislike that this has to be done in this manner. It seems to me that the JVM should be able to allow various class loaders to work with one another in such a way that if a client loaded by one classloader has an import statement in it to use a class, the JVM should be able to fetch the .class out of the other classloader and share it, or something!
    This seems to me that there really is no way to actually properly unload and then reload a class so that the JVM will discard and free up the previous class completely, while using the new class.
    I would be interested in discussing this topic further. Maybe some others will join in and help out on this topic. I am surprised there isn't a top-level forum topic about things like class loaders, JVM, etc. I wish there was a way to add one!

  • Dynamic class loading when CODEBASE is unreachable. A bug?

    Let us suppose that we have a large-scale distributed application with ca. 1000 participants communicating via RMI and utilizing dynamic class loading. As we all know, a HTTP code server must be available for this purpose in order to provide dynamically downloaded code, usually the communication proxy code of remote objects. In a real-world scenario, the HTTP server will never be 100% available, so that we will have cases that a Java process will not be able to download the necessary Java classes, causing the RMI communication to fail with a ClassNotFoundException or similar exception. In such a case, a robust application would perform some recovery activities and retry the remote call. Eventually, the HTTP server becomes available again and the distributed system recovers automatically. This seems to work fine with J2SE 1.4.2_10, but not with 1.4.2_11 and newer versions. Considering Java 5, the Update 9 exhibits the same problem.
    For tracking down the problem, I've written a simple distributed test application, consisting of a client and a server. A server listens on a port, and sends a MarshalledObject to the client. The code of the MarshalledObject is annotated with the value of the "java.rmi.server.codebase" system property. The annotation contains an URL of the JAR file containing the code of the original object. The client connects to the server, reads data form the socket and unmarshalls the original object. This is basically the same procedure as when objects are accross the wire as arguments/return values/exceptions by the RMI/JRMP engine. This procedure is repeated forever in the loop. Due to the fact that the client's CLASSPATH doesn't contain the code of the original object, this code should dynamically be loaded from the HTTP server using the appropriate annotation provided by the server.
    If we start the client while the HTTP server is down, the client will keep generating the ClassNotFoundException over and over again, as expected. So far, so good. If we now start the HTTP server while the client is still running, we will observe different behaviors, depending on the version of the client's JVM:
    1. In J2SE 1.4.2_10, the client will download the code from the HTTP server and successfully unmarshal the original object sent by the server. ClassNotFoundExceptions will not be generated again.
    2. In J2SE 1.4.2_11, 1.4.2_12 and 1.4.2_13 as well as in J2SE 5.0 Update 9, the client will continue generating ClassNotFoundExceptions. Analysis of the HTTP server's access log shows that there were no attempts to download the JAR file required for unmarshaling the object sent by the server.
    It seems that in the newer JVM versions the RMI engine remembers URLs which have failed and does not attempt to access them anymore. Althogh this may have some advantages considering the overall network load, the dynamical class loading becomes practically useless in productive large distributed systems. The very first attempt to load the codebase of the communication peer must succeed, otherwise the whole process must be restarted for the communication to work, which is a very expensive (and for most customers unacceptable) operation in terms of preformance and resources usage.
    Should this be seen as a bug or a feature of the JVM? What do you think?
    Regards,
    Miran
    Here is the code to reproduce:
    Server code
    package server;
    import java.net.*;
    import java.rmi.*;
    import java.io.*;
    public class Server implements Serializable {
      private int value = 42;
      public Server() {
      public String toString() {
        return "The Answer is " + value;
      public static void main( String[] args ) {
        if( args.length!=1 ) {
          System.out.println( "Usage: server.Server <port>" );
          System.exit( 1 );
        try {
          MarshalledObject data = new MarshalledObject( new Server() );
          int port = Integer.parseInt( args[0] );
          ServerSocket serverSocket = new ServerSocket( port );
          System.out.println( "Accepting connections..." );
          while( true ) {
            Socket s = serverSocket.accept();
            new Thread( new SocketHandler( s, data ) ).start();
        } catch( Exception ex ) {
          ex.printStackTrace();
        System.exit( 0 );
      public static class SocketHandler implements Runnable {
        private Socket s;
        private Serializable data;
        public SocketHandler( Socket s, Serializable data ) {
          this.s = s;
          this.data = data;
        public void run() {
          try {
            OutputStream os = s.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream( os );
            oos.writeObject( data );
            oos.close();
            os.close();
            s.close();
            System.out.println( "Serving socket succeeded" );
          } catch( Exception ex ) {
            System.out.println( "Serving socket failed" );
            ex.printStackTrace();
    Client code
    package client;
    import java.rmi.*;
    import java.net.*;
    import java.io.*;
    public class Client {
      public static void main( String[] args ) {
        if( args.length!=1 ) {
          System.out.println( "Usage: client.Client <port>" );
          System.exit( 1 );
        try {
          if( System.getSecurityManager()==null ) {
            System.setSecurityManager( new RMISecurityManager() );
          int port = Integer.parseInt( args[0] );
          for( int i = 1; true; ++i ) {
            try {
              Socket s = new Socket( "localhost", port );
              InputStream is = s.getInputStream();
              ObjectInputStream ois = new ObjectInputStream( is );
              Object o = ois.readObject();
              ois.close();
              is.close();
              s.close();
              Object umo = ((MarshalledObject) o).get();
              System.out.println( i + ". Retreiving MarshalledObject succeeded: "
                                  + umo );
            } catch( Exception ex ) {
              System.out.println( i + ". Retreiving MarshalledObject failed" );
              ex.printStackTrace();
            System.out.println( i + ". Waiting for 10 sec" );
            Thread.sleep( 10000 );
        } catch( Exception ex ) {
          ex.printStackTrace();
        System.exit( 0 );
    Start command for the server
    java -cp server.jar -Djava.rmi.server.codebase="http://localhost/playground/server.jar" server.Server 33933
    Start command for the client
    java -cp client.jar -Djava.security.policy=all.policy client.Client 33933
    The policy.all file should look as follows
    // All permissions
    grant {
       permission java.security.AllPermission;
    };The server.jar file should only contain the classes from the server package. This file should also be made accessible via HTTP (e.g. by using the Apache HTTP server).
    The client.jar file should only contain the classes from the client package.

    no body know about this??

Maybe you are looking for

  • L8 and L9 asking always for registration alternatively + Prob in Monitoring

    After few problem of hardware, i had to reinstalled an old backup system in which i had only L8. Reinstall L9 witouht problem . But everytime i activate L9 then L8 alternately they asked me to register before to open the application(things i did alwa

  • Vendor Minority Status

    Dear All, Can you please let me know on how to change the minority status of the vendor in SRM? I tried the transaction BP but could not do anything there. Thanks for your time.

  • Unable to update InDesign CC 9.2

    Hello, I'm unable to update InDesign CC 9.2, since the option 'Updates' from Help menu looks disabled. Please advise to update this version in any other way. Thanks in advance, Praveen

  • Help: access right session context in servlet

    Hello, I've an master detail table in an adf app working fine. I've a servlet accessing the View of the detail Table woking fine (getBindingContext, ApplicationModule, findViewObject, and going thru the details Table wit a RowSetIterator). BUT if i c

  • Transmitting music from a radio app / web site to my Airport wifi

    Hi, I want to be able to use my Ipad to transmitt media from a radio app / web site to my airport. I use Airfoil for my Macbook to transmit from a website but I want to transmit from my ipad using my account for that. How can I do this?