|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????Hi,
i'm sorry if this is some kind of noob question (since today is the first day i am experimenting with apache felix - and OSGI in general), but i can't find a solution on google or in this forum. I created a bundle for my swing application. Although i know that i have to find a solution to my log4j logging problems, this is not the main problem. Here is the output after starting felix: <code> Welcome to Felix. ================= log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable. log4j:ERROR The class "org.apache.log4j.Appender" was loaded by log4j:ERROR [1.0] whereas object of type log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader@2c2bbd86]. log4j:ERROR Could not instantiate appender named "A1". ERROR: Error starting file:/home/niko/workspace/JSimulation/bundle/de.krismer.simulation.core.runtime.jar (org.osgi.framework.BundleException: Activator start error in bundle [1].) java.lang.NoClassDefFoundError: javax/swing/UIManager at de.krismer.simulation.SimulationRuntimeImpl.startRuntime(Unknown Source) at de.krismer.simulation.SimulationRuntimeActivator.startApplication(Unknown Source) at de.krismer.simulation.SimulationRuntimeActivator.start(Unknown Source) at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:667) at org.apache.felix.framework.Felix.activateBundle(Felix.java:1699) at org.apache.felix.framework.Felix.startBundle(Felix.java:1621) at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1076) at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.ClassNotFoundException: javax.swing.UIManager at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:726) at org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:60) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1631) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 9 more </code> Shouldn't this class be part of the jdk itself? I started Felix with the custom framework launcher from http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html. Is this problem related with my custom launcher? Maybe someone can help me with this problem (or even with my log4j problem) Best regards, Niko |
|
|
Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????Bundles only have access to java.* package and what they explicitly import.
Is your bundle explicitly referencing javax.swing.UIManager? If so, then make sure your bundle is importing javax.swing. If your bundle does not explicitly reference it, then it might be a boot delegation issue. -> richard On 10/9/09 20:59, Niko_K wrote: > Hi, > > i'm sorry if this is some kind of noob question (since today is the first > day i am experimenting with apache felix - and OSGI in general), but i can't > find a solution on google or in this forum. > > I created a bundle for my swing application. > Although i know that i have to find a solution to my log4j logging problems, > this is not the main problem. > > Here is the output after starting felix: > <code> > Welcome to Felix. > ================= > > log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to > a "org.apache.log4j.Appender" variable. > log4j:ERROR The class "org.apache.log4j.Appender" was loaded by > log4j:ERROR [1.0] whereas object of type > log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by > [sun.misc.Launcher$AppClassLoader@2c2bbd86]. > log4j:ERROR Could not instantiate appender named "A1". > ERROR: Error starting > file:/home/niko/workspace/JSimulation/bundle/de.krismer.simulation.core.runtime.jar > (org.osgi.framework.BundleException: Activator start error in bundle [1].) > java.lang.NoClassDefFoundError: javax/swing/UIManager > at de.krismer.simulation.SimulationRuntimeImpl.startRuntime(Unknown Source) > at > de.krismer.simulation.SimulationRuntimeActivator.startApplication(Unknown > Source) > at de.krismer.simulation.SimulationRuntimeActivator.start(Unknown Source) > at > org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:667) > at org.apache.felix.framework.Felix.activateBundle(Felix.java:1699) > at org.apache.felix.framework.Felix.startBundle(Felix.java:1621) > at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1076) > at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264) > at java.lang.Thread.run(Thread.java:619) > Caused by: java.lang.ClassNotFoundException: javax.swing.UIManager > at > org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:726) > at org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:60) > at > org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1631) > at java.lang.ClassLoader.loadClass(ClassLoader.java:252) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) > ... 9 more > </code> > > Shouldn't this class be part of the jdk itself? > I started Felix with the custom framework launcher from > http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html. > Is this problem related with my custom launcher? > > Maybe someone can help me with this problem (or even with my log4j problem) > > Best regards, > Niko > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????My bundle references javax.swing.UIManager explicitly.
I tried to add it to my bundle's manifest file, but now i get a "org.osgi.framework.BundleException: Unresolved constraint in bundle [1]: package; (&(package=javax.swing)(version>=1.6.0))". My manifest file looks like this: <code> Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 14.2-b01 (Sun Microsystems Inc.) Bundle-Name: JSimulation Core Runtime Bundle-Description: Bundle that registers the main GUI Bundle-Vendor: Apache Felix Bundle-Version: 0.1 Bundle-Activator: de.krismer.simulation.core.SimulationRuntimeActivator Bundle-Classpath: . Export-Package: de.krismer.simulation.core.SimulationRuntimeService Import-Package: org.osgi.framework;version="1.0.0", javax.swing;version="1.6.0" </code> Where is the problem and how can i fix it? Regards, Niko
|
|
|
Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????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 On 10/12/09 17:16, Niko_K wrote: > My bundle references javax.swing.UIManager explicitly. > I tried to add it to my bundle's manifest file, but now i get a > "org.osgi.framework.BundleException: Unresolved constraint in bundle [1]: > package; (&(package=javax.swing)(version>=1.6.0))". > > My manifest file looks like this: > <code> > Manifest-Version: 1.0 > Ant-Version: Apache Ant 1.7.1 > Created-By: 14.2-b01 (Sun Microsystems Inc.) > Bundle-Name: JSimulation Core Runtime > Bundle-Description: Bundle that registers the main GUI > Bundle-Vendor: Apache Felix > Bundle-Version: 0.1 > Bundle-Activator: de.krismer.simulation.core.SimulationRuntimeActivator > Bundle-Classpath: . > Export-Package: de.krismer.simulation.core.SimulationRuntimeService > Import-Package: org.osgi.framework;version="1.0.0", > javax.swing;version="1.6.0" > </code> > > Where is the problem and how can i fix it? > > Regards, > Niko > > > Richard S. Hall wrote: > >> Bundles only have access to java.* package and what they explicitly >> import. >> >> Is your bundle explicitly referencing javax.swing.UIManager? If so, then >> make sure your bundle is importing javax.swing. >> >> If your bundle does not explicitly reference it, then it might be a boot >> delegation issue. >> >> -> richard >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????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. 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
|
|
|
Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????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@... For additional commands, e-mail: users-help@... |
|
|
Re: Error starting bundle - ClassNotFoundException -> for javax.swing.UIManager????That was the problem. It works great now!
Thanks you ;-)
|
| Free embeddable forum powered by Nabble | Forum Help |