felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard S. Hall" <he...@ungoverned.org>
Subject Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????
Date Mon, 12 Oct 2009 18:11:53 GMT


On 10/12/09 20:05, Niko_K wrote:
> Removing the version did not help.
> However, i am not using java -jar bin/felix.jar.
>
> I use a custom launcher, since i embedded felix in my application.
> I tried 2 different ways to init/start felix.
>    

This is the issue. Do not set FRAMEWORK_SYSTEMPACKAGES at all, since it 
will be set by default to include everything in the underlying JRE and 
the various OSGi packages exported by the framework. If you really need 
to set it, then you also need to include every other package you want 
exported from the underlying JRE (i.e., javax.swing and anything else).

-> richard

> The first one (which i now use by default) is:
> <code>
> 		Map<String, String>  configMap = new HashMap<String, String>();
> 		configMap.put(Constants.FRAMEWORK_STORAGE, "cache");
> 		configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework;
> version=2.0.0,");
> 		configMap.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
> "install,start,update");
>
> 		try {
> 			Felix felix = new Felix(configMap);
> 			felix.init();
> 			AutoProcessor.process(configMap, felix.getBundleContext());
> 			felix.start();
> 			felix.waitForStop(0);
>
> 			System.exit(0);
> 		} catch (Exception ex) {
> 			System.err.println("Could not start apache felix: " + ex);
> 			ex.printStackTrace();
> 			System.exit(-1);
> 		}
> </code>
>
> The second approach is very similar, but it uses a framework object instead:
> <code>
> 	public static void main(String[] args) {
> 		Map<String, String>  configMap = new HashMap<String, String>();
> 		configMap.put(Constants.FRAMEWORK_STORAGE, "cache");
> 		configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework;
> version=2.0.0,");
> 		configMap.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
> "install,start,update");
>
> 		try {
> 			framework = getFrameworkFactory().newFramework(configMap);
> 			framework.init();
> 			AutoProcessor.process(configMap, framework.getBundleContext());
> 			framework.start();
>
> 			framework.waitForStop(0);
> 			System.exit(0);
> 		} catch (Exception ex) {
> 			System.err.println("Could not create framework: " + ex);
> 			ex.printStackTrace();
> 			System.exit(-1);
> 		}
> 	}
>
> 	private static FrameworkFactory getFrameworkFactory() throws Exception {
> 		URL url =
> Main.class.getClassLoader().getResource("META-INF/services/org.osgi.framework.launch.FrameworkFactory");
> 		if (url != null) {
> 			BufferedReader br = new BufferedReader(new
> InputStreamReader(url.openStream()));
> 			try {
> 				for (String s = br.readLine(); s != null; s = br.readLine()) {
> 					s = s.trim();
> 					// Try to load first non-empty, non-commented line.
> 					if ((s.length()>  0)&&  (s.charAt(0) != '#')) {
> 						return (FrameworkFactory) Class.forName(s).newInstance();
> 					}
> 				}
> 			} finally {
> 				br.close();
> 			}
> 		}
>
> 		throw new Exception("Could not find framework factory.");
> 	}
> </code>
>
> Both of these ways result in the described error. Is this the problem?
>
> Niko
>
> Richard S. Hall wrote:
>    
>> How are you launching the framework? With "java -jar bin/felix.jar"? If
>> so, it should be exporting javax.swing from the system bundle by
>> default. You could try to remove your "version>=1.6.0" just in case.
>>
>> ->  richard
>>
>>      
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message