Here's what we're doing.  Basically you need to touch the class
to force it to be loaded in the thread that initializes the MBean.

The AHelpers.loadGCOSLibraries method is called from the MBean.
Then we touch one class from each jar file that references native
methods.  Once the jar file is bound to a class loader, I believe
that class loader will load all classes from that jar, regardless
of which thread/class requests the class to be loaded later.

When debugging, we also log the value of getClassLoader() for
the MBean class and each of the classes with native methods.
If they don't match, you're in for trouble.

Hope this helps,
Bob Handsaker



  | public class AHelpers {
  | 
  |     public synchronized static boolean loadGCOSLibraries() {
  | 
  |         // Prevent multiple initialization.
  |         if (m_gcosInitialized) {
  |             return true;
  |         }
  | 
  |         log.info("Loading GCOS libraries...");
  |         log.info("System PATH: " +
  |                  System.getProperty("java.library.path"));
  | 
  |         try {
  | 
  |             System.loadLibrary("GcdoAffyJava");
  |             log.info("System.loadLibrary(\"GcdoAffyJava\") is successful.");
  |             System.loadLibrary("GcdoAnalysisController");
  |             log.info("System.loadLibrary(\"GcdoAnalysisController\") is 
successful.");
  |             System.loadLibrary("GdacFilesJava");
  |             log.info("System.loadLibrary(\"GdacFilesJava\") is 
successful.");
  | 
  |             log.info("About to check Classes in GCOSSDK.jar ...");
  |             checkClass(GcdoConnection.class);
  |             log.info("GcdoConnection passed.");
  |             checkClass(GcdoSample.class);
  |             log.info("GcdoSample passed.");
  | 
  |             log.info("About the check Classes in GdacFiles.jar ...");
  |             checkClass(GDACCELFile.class);
  |             log.info("GDACCELFile passed.");
  |             checkClass(GDACCHPFile.class);
  |             log.info("GDACCHPFile passed.");
  | 
  |         } catch(Throwable t) {
  |             log.error("GCOS API initialization failed: " + t.getMessage(), 
t);
  |             return false;
  |         }
  | 
  |         m_gcosInitialized = true;
  |         return true;
  |     }
  | 
  |     private static void checkClass(Class c) throws Exception {
  |     if (c.getClassLoader() != AHelpers.class.getClassLoader()) {
  |         throw new Exception ("Class " + c.getName() + " not loaded by 
correct class loader");
  |     }
  |     }
  | 
  |     private static Log log = LogFactory.getLog(AHelpers.class);
  | 
  |     private static boolean m_gcosInitialized = false;
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3905062#3905062

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3905062


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to