Topic
3 replies Latest Post - ‏2012-11-08T20:33:23Z by bkail
ishkin
ishkin
2 Posts
ACCEPTED ANSWER

Pinned topic class loader problem for shared library in Websphere 8.0.0.4

‏2012-10-11T14:11:11Z |
Hello, I am migrating an existing J2ee project from WAS 6.1 to WAS 8.0
All the projects were recompiled for WAS 8.0 using RSA 8.5

I am having a weird problem in loading a shared library class within my application.
We have an external jar updated from time to time which our application is dependent on. (the jar was also recompiled, however I also tried the old version...)
I have defined this jar as a shared lib, and also pointed my application to refer this shared library.

One of the modules within my application tries to dynamically load a class contained within this jar (I have verified the class exists in the jar, the path to the jar is correct, no permissions issues reading the jar - running on Windows).
The EJB module use the following code to load the class:

Class clazz;
clazz = Class.forName(cls);

where cls is the fully qualified name of the class located within the jar.

However when the application runs I am getting ClassNotFound exception.

The classloading options of the application, the server are the default options (parent-first). The classloader view shows the path of the jar on the classpath of com.ibm.ws.classloader.CompoundClassLoader, however the class is not loaded, does not appear in the classes within the ClassLoader view, and doesn't appear in class search results of the ClassLoader view (however the jar does).

I have gathered the traces recommended for debugging of this problem if someone is willing to take a look. (I couldn't find anything meaningful in those traces except reference to failing to load the class:
10/10/12 16:06:50:307 IST 00000020 CompoundClass > loadClass 'ccm.eep.CcmEepLibraryProvider' this=com.ibm.ws.classloader.CompoundClassLoader@64fe353app:AmitProject Entry
10/10/12 16:06:50:307 IST 00000020 CompoundClass < loadClass 'ccm.eep.CcmEepLibraryProvider' failed Exit
)

I would really appreciate if someone could shed some light on what am I missing here...
Thank you!
Updated on 2012-11-08T20:33:23Z at 2012-11-08T20:33:23Z by bkail
  • bkail
    bkail
    372 Posts
    ACCEPTED ANSWER

    Re: class loader problem for shared library in Websphere 8.0.0.4

    ‏2012-10-11T16:39:23Z  in response to ishkin
    In the code that is doing the Class.forName, I would suggest adding a diagnostic:
    System.out.println(getClass().getClassLoader());
    

    This should print the full classpath to the class loader. Also, if you're already looking through trace, you might look near "adding application shared library class paths" at the time your application is starting.
    Updated on 2014-03-25T23:52:06Z at 2014-03-25T23:52:06Z by iron-man
    • ishkin
      ishkin
      2 Posts
      ACCEPTED ANSWER

      Re: class loader problem for shared library in Websphere 8.0.0.4

      ‏2012-10-11T19:04:09Z  in response to bkail
      Thank you very much for your reply.
      The output of the diagnostic trace you've suggested is as follows:

      com.ibm.ws.classloader.CompoundClassLoader@f3d6ceceapp:AmitProject
      Local ClassPath: C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\AmitManagementEJB.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\AmitWAS.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\AmitMonitoringWAS.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\AmitActionManagerWAS.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\AmitDefinitionManagerWAS.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\AmitOutputWAS.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\lib\Amit3.0Common.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\lib\Amit3.0EEP.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\lib\AmitWASUtilities.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\lib\serviceLocatorMgr.jar;C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\AppSrv01\installedApps\Cell\AmitProject.ear\library\serviceLocatorMgr.jar;C:\AMIT\CcmEepProvider\CcmEepExtension.jar
      Parent: com.ibm.ws.classloader.ProtectionClassLoader@8cd6f871
      Delegation Mode: PARENT_FIRST

      As you can see, the last entry on the classpath of this application classloader is the shared library path - the path to the CcmEepExtension.jar which contains the ccm.eep.CcmEepLibraryProvider class file...The one which for some reason the classloader doesn't find.

      About your second suggestion - I didn't understand your meaning - what should I look for in the trace? I have been looking for the name of the missing class and reading all entries related to it. Also for the name of the jar file and all the entries related to it.
      If you mean the second one, here are the entries related to it at application start:

      10/11/12 15:36:38:124 IST 00000018 ClassLoaderUt > addDependents Entry
      C:\AMIT\CcmEepProvider\CcmEepExtension.jar
      10/11/12 15:36:38:124 IST 00000018 ClassLoaderUt < addDependents Exit
      C:\AMIT\CcmEepProvider\CcmEepExtension.jar
      no dependents found
      also
      10/11/12 15:36:38:233 IST 00000018 SinglePathCla 3 adding cached provider com.ibm.ws.classloader.SinglePathClassProvider@eac7c578C:\AMIT\CcmEepProvider\CcmEepExtension.jar
      10/11/12 15:36:38:233 IST 00000018 CompoundClass 3 adding com.ibm.ws.classloader.SinglePathClassProvider@eac7c578C:\AMIT\CcmEepProvider\CcmEepExtension.jar

      and
      10/11/12 15:36:44:813 IST 00000018 SinglePathCla 3 adding cached zip file C:\AMIT\CcmEepProvider\CcmEepExtension.jar
      10/11/12 15:36:44:828 IST 00000018 Handler > parseURL Entry
      wsjar:file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/
      META-INF/MANIFEST.MF
      0
      20
      10/11/12 15:36:44:828 IST 00000018 Handler > parseRelativePath Entry
      wsjar:file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/
      META-INF/MANIFEST.MF
      10/11/12 15:36:44:828 IST 00000018 Handler > canonicalize Entry
      /META-INF/MANIFEST.MF
      10/11/12 15:36:44:828 IST 00000018 Handler < canonicalize Exit
      /META-INF/MANIFEST.MF
      10/11/12 15:36:44:828 IST 00000018 Handler < parseRelativePath Exit
      file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/META-INF/MANIFEST.MF
      10/11/12 15:36:44:828 IST 00000018 Handler < parseURL Exit
      wsjar:file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/META-INF/MANIFEST.MF
      10/11/12 15:36:44:828 IST 00000018 CompoundClass 3 found META-INF/MANIFEST.MF in com.ibm.ws.classloader.SinglePathClassProvider@eac7c578C:\AMIT\CcmEepProvider\CcmEepExtension.jar this=com.ibm.ws.classloader.CompoundClassLoader@eac96c1fapp:AmitProject

      also

      10/11/12 15:36:45:235 IST 00000018 Handler > openConnection Entry
      wsjar:file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/META-INF/MANIFEST.MF
      10/11/12 15:36:45:235 IST 00000018 Handler 3 Handler.openConnection() - path from url.getPath() : file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/META-INF/MANIFEST.MF
      10/11/12 15:36:45:235 IST 00000018 Handler 3 Handler.openConnection() - urlString from ParserUtils : file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar
      10/11/12 15:36:45:235 IST 00000018 ClassLoaderUt 3 ClassLoaderUtils.constructHostlessURL - computed new urlPath : /C:/AMIT/CcmEepProvider/CcmEepExtension.jar
      10/11/12 15:36:45:235 IST 00000018 Handler$Class > <init> Entry
      wsjar:file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/META-INF/MANIFEST.MF
      /C:/AMIT/CcmEepProvider/CcmEepExtension.jar
      META-INF/MANIFEST.MF
      10/11/12 15:36:45:235 IST 00000018 Handler$Class < <init> Exit
      10/11/12 15:36:45:235 IST 00000018 Handler < openConnection Exit
      com.ibm.ws.classloader.Handler$ClassLoaderURLConnection:wsjar:file:/C:/AMIT/CcmEepProvider/CcmEepExtension.jar!/META-INF/MANIFEST.MF

      The next entry is the failure to load the class:
      10/11/12 15:36:54:549 IST 00000018 CompoundClass > loadClass 'ccm.eep.CcmEepLibraryProvider' this=com.ibm.ws.classloader.CompoundClassLoader@eac96c1fapp:AmitProject Entry
      10/11/12 15:36:54:549 IST 00000018 CompoundClass < loadClass 'ccm.eep.CcmEepLibraryProvider' failed Exit
      Hope this helps
      • bkail
        bkail
        372 Posts
        ACCEPTED ANSWER

        Re: class loader problem for shared library in Websphere 8.0.0.4

        ‏2012-11-08T20:33:23Z  in response to ishkin
        I was hoping that the class loader trace might show some issue opening the JAR, but from the trace snippets it looks ok. Given that there's no other output near the loadClass trace point, I might guess that the package does not exist in the JAR. What does 'unzip -l CcmEepExtension.jar' show? It's also possible you've found a product bug and should open a PMR with IBM...