VMware vCenter

 View Only
Expand all | Collapse all

Can't find resource for bundle java.util.PropertyResourceBundle, key util.config.exceptionLoadingProperty exception

  • 1.  Can't find resource for bundle java.util.PropertyResourceBundle, key util.config.exceptionLoadingProperty exception

    Posted Jul 12, 2010 07:41 AM

    I have developed a plugin for VMO ..However when i try to execute a workflow which uses my plugged in technology...i get the following exception...

    Can't find resource for bundle java.util.PropertyResourceBundle, key util.config.exceptionLoadingProperty

    Could anyone tell the possible reason this exception is appearing



  • 2.  RE: Can't find resource for bundle java.util.PropertyResourceBundle, key util.config.exceptionLoadingProperty exception

    Posted Jul 13, 2010 04:19 PM

    I think it's a class loader problem.

    The vCO server doesn't use the same class loader during plug-in initialization (IPluginAdaptor) and when calling methods on the plug-in (IPluginFactory).

    Your plug-in seems to want to find a resource from the class loader (typically a call to this.getClass().getResourceAsStream()), but because when the call is made it's not the class loader used in initialization, the resource is unavailable.

    To solve this issue, before making the call that needs to load the resource, you will have to switch the current class loader to the "plug-in" one in order to find the resource.

    You'll first have to store the "plug-in" class loader. To do so, you'll need to change your Adaptor (the class implementing IPluginAdaptor) constructor to something like this:

    public class YourAdaptor implements IPluginAdaptor
    {
    	private static ClassLoader pluginClassLoader;
    	.
    	.
    	.
    
    	public YourAdaptor( ClassLoader aPluginClassLoader ) {
        	    pluginClassLoader = aPluginClassLoader;
    	} 
    
    	.
    	.
    	.
    	public static ClassLoader getPluginClassLoader() {
                return pluginClassLoader;
    	}
    }
    

    You can store the plug-in class loader as a static variable or in any other way (a map by adaptor, etc).

    Then in the method(s) that load resources, you'll need to switch the current class loader to the "plug-in" one.

    Here's a quick example:

    public void methodLoadingTheResource() {
    	ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
       	try {
    	    // Switch to the ‘pluginClassLoader’ class loader previously stored
    	    Thread.currentThread().setContextClassLoader( YourAdaptor.getPluginClassLoader() );
    	    // The piece of code that needs the resource
    		.
    		.
    		.
    	}
    	finally {
        	    Thread.currentThread().setContextClassLoader( originalClassLoader );
       	}
    	// Rest of the code
    	.
    	.
    	.
    }
    

    Hope this helps.

    Regards,

    Vincent.



  • 3.  RE: Can't find resource for bundle java.util.PropertyResourceBundle, key util.config.exceptionLoadingProperty exception

    Posted Jul 19, 2010 06:20 AM

    Thanks Vincent,

    I was able to take care of my problem

    Ashish