Re: Embedded Felix giving NumberFormatException
Sameera Withanage wrote: Hi, The services are the exact ones I get when I install the bundle to standalone Felix. But in embedded version there are no services for this bundle. Still no success even with you suggestions. Well, I didn't do anything special to get that service to appear...I am just using your Main... The only thing I did was in your FelixHost.callService() where it prints out the length of the services references array, I added a check for null so that it doesn't throw an NPE: Object[] services = m_tracker.getServices(); if (services != null) System.out.println("sevices length :" + services.length); else System.out.println("sevices length :" + services); After doing this the service does appear, even though I am seeing class load errors from Spring-OSGi. Perhaps you are just invoking the method too quickly...I am not sure if Spring-OSGi uses asynchronous events or not when listening for bundles... -> richard Thank you Sameera On 4/26/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: After yet even more poking around, I am not sure what is going on... I am definitely seeing some errors from Spring...looks like some class loading issues...I am not sure. However, am I supposed to be seeing bundle 32 offering a service? If so, I am seeing that: -> services 32 Simple-Service-Sample (32) provides: Bundle-SymbolicName = org.springframework.osgi.samples.simpleservice Bundle-Version = 1.0 objectClass = org.springframework.osgi.samples.simpleservice.MyService org.springframework.osgi.beanname = simpleService service.id = 26 objectClass = org.springframework.context.ApplicationContext org.springframework.context.service.name = org.springframework.osgi.samples.simpleservice service.id = 27 -> So, I am not really sure if I am on the right track, since I don't use Spring-OSGi at all. -> richard Richard S. Hall wrote: > Well, I sort of take back what I said below...since you are not > launching with the standard launcher, property substitution does not > happen in the roland.properties file, so you have to overwrite that > value with a "real" value. > > I will keep playing with it... > > -> richard > > Richard S. Hall wrote: >> After a quick look at your code, I noticed one thing that looks >> somewhat strange...I don't know if it is the root of your issues, but >> it is something to look at... >> >> Below you appear to read Felix' configuration properties from the >> roland.properties, which sets the org.osgi.framework.system.packages >> property inside of it, including all of the packages exported from >> the underlying JRE. Your code below then overwrites this value and >> sets it to only export the core OSGi packages along with your >> "simpleservice" package. >> >> The end result is that no JRE packages are being exported any more >> after you overwrite the value. To remedy this situation, you should >> either: >> >> 1. Add your "simpleservice" package to org.osgi.system.packages >> property in roland.properties or >> 2. Append your "simpleservice" package to the existing value in the >> code below. >> >> I am not sure if this will solve anything, but I am still working to >> get your example to compile since the pom files included with it are >> not working for me. >> >> One other minor thing I noticed below, you have an extraneous ';' >> character when you add your "simpleservice" package. I think Felix >> would ignore this, but you should probably still remove it. The ';' >> is used to separate packages that share attributes or to separate the >> attributes themselves. >> >> I will keep trying to build your code. Let me know if any of the >> above makes a difference or if you discover the issue in the meantime. >> >> -> richard >> >> >> Sameera Withanage wrote: >>> This is the host application >>> >>> import java.io.IOException; >>> import java.util.ArrayList; >>> import java.util.List; >>> import java.util.Map; >>> import java.util.Properties; >>> >>> import org.apache.felix.framework.Felix; >>> import org.apache.felix.framework.cache.BundleCache; >>> import org.apache.felix.framework.util.MutablePropertyResolver; >>> import org.apache.felix.framework.util.MutablePropertyResolverImpl; >>> import org.apache.felix.framework.util.StringMap; >>> import org.osgi.framework.Bundle; >>> import org.osgi.framework.BundleActivator; >>> import org.osgi.framework.BundleContext; >>> import org.osgi.framework.Constants; >>> import org.osgi.util.tracker.ServiceTracker; >>> import org.springframework.osgi.samples.simpleservice.MyService; >>> >>> public class FelixHost { >>>private HostActivator m_activator = null; >>> >>>private Felix m_felix = null; >>> >>>private ServiceTracker m_tracker = null; >>> >>>public FelixHost() { >>>Map configMap = new StringMap(false); >>> >>>Properties p = new Properties(); >>>try { >>>p.load(this.getClass ().getCl
Re: Embedded Felix giving NumberFormatException
Hi, The services are the exact ones I get when I install the bundle to standalone Felix. But in embedded version there are no services for this bundle. Still no success even with you suggestions. Thank you Sameera On 4/26/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: After yet even more poking around, I am not sure what is going on... I am definitely seeing some errors from Spring...looks like some class loading issues...I am not sure. However, am I supposed to be seeing bundle 32 offering a service? If so, I am seeing that: -> services 32 Simple-Service-Sample (32) provides: Bundle-SymbolicName = org.springframework.osgi.samples.simpleservice Bundle-Version = 1.0 objectClass = org.springframework.osgi.samples.simpleservice.MyService org.springframework.osgi.beanname = simpleService service.id = 26 objectClass = org.springframework.context.ApplicationContext org.springframework.context.service.name = org.springframework.osgi.samples.simpleservice service.id = 27 -> So, I am not really sure if I am on the right track, since I don't use Spring-OSGi at all. -> richard Richard S. Hall wrote: > Well, I sort of take back what I said below...since you are not > launching with the standard launcher, property substitution does not > happen in the roland.properties file, so you have to overwrite that > value with a "real" value. > > I will keep playing with it... > > -> richard > > Richard S. Hall wrote: >> After a quick look at your code, I noticed one thing that looks >> somewhat strange...I don't know if it is the root of your issues, but >> it is something to look at... >> >> Below you appear to read Felix' configuration properties from the >> roland.properties, which sets the org.osgi.framework.system.packages >> property inside of it, including all of the packages exported from >> the underlying JRE. Your code below then overwrites this value and >> sets it to only export the core OSGi packages along with your >> "simpleservice" package. >> >> The end result is that no JRE packages are being exported any more >> after you overwrite the value. To remedy this situation, you should >> either: >> >> 1. Add your "simpleservice" package to org.osgi.system.packages >> property in roland.properties or >> 2. Append your "simpleservice" package to the existing value in the >> code below. >> >> I am not sure if this will solve anything, but I am still working to >> get your example to compile since the pom files included with it are >> not working for me. >> >> One other minor thing I noticed below, you have an extraneous ';' >> character when you add your "simpleservice" package. I think Felix >> would ignore this, but you should probably still remove it. The ';' >> is used to separate packages that share attributes or to separate the >> attributes themselves. >> >> I will keep trying to build your code. Let me know if any of the >> above makes a difference or if you discover the issue in the meantime. >> >> -> richard >> >> >> Sameera Withanage wrote: >>> This is the host application >>> >>> import java.io.IOException; >>> import java.util.ArrayList; >>> import java.util.List; >>> import java.util.Map; >>> import java.util.Properties; >>> >>> import org.apache.felix.framework.Felix; >>> import org.apache.felix.framework.cache.BundleCache; >>> import org.apache.felix.framework.util.MutablePropertyResolver; >>> import org.apache.felix.framework.util.MutablePropertyResolverImpl; >>> import org.apache.felix.framework.util.StringMap; >>> import org.osgi.framework.Bundle; >>> import org.osgi.framework.BundleActivator; >>> import org.osgi.framework.BundleContext; >>> import org.osgi.framework.Constants; >>> import org.osgi.util.tracker.ServiceTracker; >>> import org.springframework.osgi.samples.simpleservice.MyService; >>> >>> public class FelixHost { >>>private HostActivator m_activator = null; >>> >>>private Felix m_felix = null; >>> >>>private ServiceTracker m_tracker = null; >>> >>>public FelixHost() { >>>Map configMap = new StringMap(false); >>> >>>Properties p = new Properties(); >>>try { >>>p.load(this.getClass ().getClassLoader().getResourceAsStream( >>>"roland.properties")); >>>} catch (IOException e) { >>>e.printStackTrace(); >>>} >>> >>>p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, >>>"org.osgi.framework; version=1.3.0," >>>+ "org.osgi.service.packageadmin; >>> version=1.2.0," >>>+ "org.osgi.service.startlevel; version=1.0.0," >>>+ "org.osgi.service.url; version=1.0.0," >>>+ >>> "org.springframework.osgi.samples.simpleservice >>> ;"); >>>p.put(BundleCache.CACHE_PROFILE_DIR_PROP, >>> "/home/sameera/.felix/new1"); >>> >>>try { >>>m_felix = new Felix(); >>> >>>m_activator = new HostActivat
Re: Embedded Felix giving NumberFormatException
After yet even more poking around, I am not sure what is going on... I am definitely seeing some errors from Spring...looks like some class loading issues...I am not sure. However, am I supposed to be seeing bundle 32 offering a service? If so, I am seeing that: -> services 32 Simple-Service-Sample (32) provides: Bundle-SymbolicName = org.springframework.osgi.samples.simpleservice Bundle-Version = 1.0 objectClass = org.springframework.osgi.samples.simpleservice.MyService org.springframework.osgi.beanname = simpleService service.id = 26 objectClass = org.springframework.context.ApplicationContext org.springframework.context.service.name = org.springframework.osgi.samples.simpleservice service.id = 27 -> So, I am not really sure if I am on the right track, since I don't use Spring-OSGi at all. -> richard Richard S. Hall wrote: Well, I sort of take back what I said below...since you are not launching with the standard launcher, property substitution does not happen in the roland.properties file, so you have to overwrite that value with a "real" value. I will keep playing with it... -> richard Richard S. Hall wrote: After a quick look at your code, I noticed one thing that looks somewhat strange...I don't know if it is the root of your issues, but it is something to look at... Below you appear to read Felix' configuration properties from the roland.properties, which sets the org.osgi.framework.system.packages property inside of it, including all of the packages exported from the underlying JRE. Your code below then overwrites this value and sets it to only export the core OSGi packages along with your "simpleservice" package. The end result is that no JRE packages are being exported any more after you overwrite the value. To remedy this situation, you should either: 1. Add your "simpleservice" package to org.osgi.system.packages property in roland.properties or 2. Append your "simpleservice" package to the existing value in the code below. I am not sure if this will solve anything, but I am still working to get your example to compile since the pom files included with it are not working for me. One other minor thing I noticed below, you have an extraneous ';' character when you add your "simpleservice" package. I think Felix would ignore this, but you should probably still remove it. The ';' is used to separate packages that share attributes or to separate the attributes themselves. I will keep trying to build your code. Let me know if any of the above makes a difference or if you discover the issue in the meantime. -> richard Sameera Withanage wrote: This is the host application import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.felix.framework.Felix; import org.apache.felix.framework.cache.BundleCache; import org.apache.felix.framework.util.MutablePropertyResolver; import org.apache.felix.framework.util.MutablePropertyResolverImpl; import org.apache.felix.framework.util.StringMap; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.util.tracker.ServiceTracker; import org.springframework.osgi.samples.simpleservice.MyService; public class FelixHost { private HostActivator m_activator = null; private Felix m_felix = null; private ServiceTracker m_tracker = null; public FelixHost() { Map configMap = new StringMap(false); Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream( "roland.properties")); } catch (IOException e) { e.printStackTrace(); } p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.0.0," + "org.osgi.service.url; version=1.0.0," + "org.springframework.osgi.samples.simpleservice ;"); p.put(BundleCache.CACHE_PROFILE_DIR_PROP, "/home/sameera/.felix/new1"); try { m_felix = new Felix(); m_activator = new HostActivator(); List act = new ArrayList(); act.add(m_activator); MutablePropertyResolver resolver = new MutablePropertyResolverImpl( p); m_felix.start(resolver, act); System.out.println("Felix started."); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } m_tracker = new ServiceTracker(m_activator.getContext(), MyService.class.getName(), null); m_tracker.open(); } publi
Re: Embedded Felix giving NumberFormatException
Well, I sort of take back what I said below...since you are not launching with the standard launcher, property substitution does not happen in the roland.properties file, so you have to overwrite that value with a "real" value. I will keep playing with it... -> richard Richard S. Hall wrote: After a quick look at your code, I noticed one thing that looks somewhat strange...I don't know if it is the root of your issues, but it is something to look at... Below you appear to read Felix' configuration properties from the roland.properties, which sets the org.osgi.framework.system.packages property inside of it, including all of the packages exported from the underlying JRE. Your code below then overwrites this value and sets it to only export the core OSGi packages along with your "simpleservice" package. The end result is that no JRE packages are being exported any more after you overwrite the value. To remedy this situation, you should either: 1. Add your "simpleservice" package to org.osgi.system.packages property in roland.properties or 2. Append your "simpleservice" package to the existing value in the code below. I am not sure if this will solve anything, but I am still working to get your example to compile since the pom files included with it are not working for me. One other minor thing I noticed below, you have an extraneous ';' character when you add your "simpleservice" package. I think Felix would ignore this, but you should probably still remove it. The ';' is used to separate packages that share attributes or to separate the attributes themselves. I will keep trying to build your code. Let me know if any of the above makes a difference or if you discover the issue in the meantime. -> richard Sameera Withanage wrote: This is the host application import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.felix.framework.Felix; import org.apache.felix.framework.cache.BundleCache; import org.apache.felix.framework.util.MutablePropertyResolver; import org.apache.felix.framework.util.MutablePropertyResolverImpl; import org.apache.felix.framework.util.StringMap; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.util.tracker.ServiceTracker; import org.springframework.osgi.samples.simpleservice.MyService; public class FelixHost { private HostActivator m_activator = null; private Felix m_felix = null; private ServiceTracker m_tracker = null; public FelixHost() { Map configMap = new StringMap(false); Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream( "roland.properties")); } catch (IOException e) { e.printStackTrace(); } p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.0.0," + "org.osgi.service.url; version=1.0.0," + "org.springframework.osgi.samples.simpleservice ;"); p.put(BundleCache.CACHE_PROFILE_DIR_PROP, "/home/sameera/.felix/new1"); try { m_felix = new Felix(); m_activator = new HostActivator(); List act = new ArrayList(); act.add(m_activator); MutablePropertyResolver resolver = new MutablePropertyResolverImpl( p); m_felix.start(resolver, act); System.out.println("Felix started."); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } m_tracker = new ServiceTracker(m_activator.getContext(), MyService.class.getName(), null); m_tracker.open(); } public String callService() { Object[] services = m_tracker.getServices(); System.out.println("sevices length :" + services.length); for (int i = 0; (services != null) && (i < services.length); i++) { try { return ((MyService) services[i]).stringValue(); } catch (Exception ex) { System.out.println(ex); } } return "):"; } public Bundle[] getInstalledBundles() { return m_activator.getContext().getBundles(); } public BundleContext getContext() { return m_activator.getContext(); } public void shutdownApplication() { System.out.println("Shutting down Felix."); m_felix.shutdown(); } } and from another class FelixHost host = new FelixHost(); BundleContext context = host.getContext(); Bundle bundle = context.installBundle("file:/work/bundle
Re: Embedded Felix giving NumberFormatException
After a quick look at your code, I noticed one thing that looks somewhat strange...I don't know if it is the root of your issues, but it is something to look at... Below you appear to read Felix' configuration properties from the roland.properties, which sets the org.osgi.framework.system.packages property inside of it, including all of the packages exported from the underlying JRE. Your code below then overwrites this value and sets it to only export the core OSGi packages along with your "simpleservice" package. The end result is that no JRE packages are being exported any more after you overwrite the value. To remedy this situation, you should either: 1. Add your "simpleservice" package to org.osgi.system.packages property in roland.properties or 2. Append your "simpleservice" package to the existing value in the code below. I am not sure if this will solve anything, but I am still working to get your example to compile since the pom files included with it are not working for me. One other minor thing I noticed below, you have an extraneous ';' character when you add your "simpleservice" package. I think Felix would ignore this, but you should probably still remove it. The ';' is used to separate packages that share attributes or to separate the attributes themselves. I will keep trying to build your code. Let me know if any of the above makes a difference or if you discover the issue in the meantime. -> richard Sameera Withanage wrote: This is the host application import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.felix.framework.Felix; import org.apache.felix.framework.cache.BundleCache; import org.apache.felix.framework.util.MutablePropertyResolver; import org.apache.felix.framework.util.MutablePropertyResolverImpl; import org.apache.felix.framework.util.StringMap; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.util.tracker.ServiceTracker; import org.springframework.osgi.samples.simpleservice.MyService; public class FelixHost { private HostActivator m_activator = null; private Felix m_felix = null; private ServiceTracker m_tracker = null; public FelixHost() { Map configMap = new StringMap(false); Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream( "roland.properties")); } catch (IOException e) { e.printStackTrace(); } p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.0.0," + "org.osgi.service.url; version=1.0.0," + "org.springframework.osgi.samples.simpleservice ;"); p.put(BundleCache.CACHE_PROFILE_DIR_PROP, "/home/sameera/.felix/new1"); try { m_felix = new Felix(); m_activator = new HostActivator(); List act = new ArrayList(); act.add(m_activator); MutablePropertyResolver resolver = new MutablePropertyResolverImpl( p); m_felix.start(resolver, act); System.out.println("Felix started."); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } m_tracker = new ServiceTracker(m_activator.getContext(), MyService.class.getName(), null); m_tracker.open(); } public String callService() { Object[] services = m_tracker.getServices(); System.out.println("sevices length :" + services.length); for (int i = 0; (services != null) && (i < services.length); i++) { try { return ((MyService) services[i]).stringValue(); } catch (Exception ex) { System.out.println(ex); } } return "):"; } public Bundle[] getInstalledBundles() { return m_activator.getContext().getBundles(); } public BundleContext getContext() { return m_activator.getContext(); } public void shutdownApplication() { System.out.println("Shutting down Felix."); m_felix.shutdown(); } } and from another class FelixHost host = new FelixHost(); BundleContext context = host.getContext(); Bundle bundle = context.installBundle("file:/work/bundle.jar"); bundle.start(); Additionally the activator ... import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class HostActivator implements BundleActivator { private BundleContext m_context = null; public void start(BundleContext context) { m_c
Re: Embedded Felix giving NumberFormatException
Ultimately, I am at a loss to explain what is going on... Perhaps, you could package the minimal set of pieces to reproduce the issue and I can try to look at it locally. Basically, I would need your launcher source with any necessary bundles to install and start. Send it to me off list. -> richard Sameera Withanage wrote: Today I took the latest of Felix and Spring-OSGi and built. WARNING: META-INF/services/org.apache.commons.logging.LogFactory ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/services/org.apache.commons.logging.LogFactory) WARNING: *** Class 'org.apache.commons.logging.impl.Log4JLogger' was not found. Bundle 32 does not import package 'org.apache.commons.logging.impl', nor is the package exported by any other bundle or available from the system class loader. *** (java.lang.ClassNotFoundException: *** Class ' org.apache.commons.logging.impl.Log4JLogger' was not found. Bundle 32 does not import package 'org.apache.commons.logging.impl', nor is the package exported by any other bundle or available from the system class loader. ***) org.osgi.framework.BundleException: org.apache.commons.logging.impl.Log4JLogger at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1184) at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java :337) at org.springframework.osgi.context.support.BundleDelegatingClassLoader.findClass (BundleDelegatingClassLoader.java:108) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.springframework.osgi.context.support.BundleDelegatingClassLoader.loadClass (BundleDelegatingClassLoader.java:389) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass (LogFactoryImpl.java:1005) at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation( LogFactoryImpl.java:838) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance( LogFactoryImpl.java:601) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance( LogFactoryImpl.java:333) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance( LogFactoryImpl.java:307) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645) at org.springframework.context.support.AbstractApplicationContext .(AbstractApplicationContext.java:134) at org.springframework.context.support.AbstractRefreshableApplicationContext .(AbstractRefreshableApplicationContext.java:80) at org.springframework.osgi.context.support.AbstractRefreshableOsgiBundleApplicationContext .(AbstractRefreshableOsgiBundleApplicationContext.java:115) at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext .(OsgiBundleXmlApplicationContext.java:57) at org.springframework.osgi.extender.support.ServiceDependentOsgiBundleXmlApplicationContext .(ServiceDependentOsgiBundleXmlApplicationContext.java:56) at org.springframework.osgi.extender.support.ApplicationContextCreator.createApplicationContext (ApplicationContextCreator.java:196) at org.springframework.osgi.extender.support.ApplicationContextCreator.run( ApplicationContextCreator.java:140) at java.lang.Thread.run(Thread.java:595) I'm getting this error when starting my bundle. I noticed through console that the extender service and all the spring modules are available. But the former gives list of these warnings WARNING: META-INF/spring.handlers ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.handlers) WARNING: META-INF/spring.schemas ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.schemas) WARNING: META-INF/spring/extender.xml ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring/extender.xml) Thank you. Sameera On 4/26/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: Sameera Withanage wrote: > Firstly thank you for all the help. > > I checked out the latest code and able to run it without that > numberformat > exception. I think I've done something wrong. > > But the spring service registration issue is still there. When I launched > Felix from command line I can see the registered services of my sample > spring bundle, but in embedded application it still returns null for > services[]. Which version of Felix and Spring-OSGi are you using? There was an issue where Spring-OSGi was making assumptions about the URL format being returned for bundle resources which was causing it to not correctly discover the Spring resource tiles, which ultimately led to it not creating Spring components/services, etc. Perhaps this is what you are seeing, but I thought it was fixed now. -> richard > > Sameera > > > > On 4/26/07, Sameera Withanage <[EM
Re: Embedded Felix giving NumberFormatException
Today I took the latest of Felix and Spring-OSGi and built. WARNING: META-INF/services/org.apache.commons.logging.LogFactory ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/services/org.apache.commons.logging.LogFactory) WARNING: *** Class 'org.apache.commons.logging.impl.Log4JLogger' was not found. Bundle 32 does not import package 'org.apache.commons.logging.impl', nor is the package exported by any other bundle or available from the system class loader. *** (java.lang.ClassNotFoundException: *** Class ' org.apache.commons.logging.impl.Log4JLogger' was not found. Bundle 32 does not import package 'org.apache.commons.logging.impl', nor is the package exported by any other bundle or available from the system class loader. ***) org.osgi.framework.BundleException: org.apache.commons.logging.impl.Log4JLogger at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1184) at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java :337) at org.springframework.osgi.context.support.BundleDelegatingClassLoader.findClass (BundleDelegatingClassLoader.java:108) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.springframework.osgi.context.support.BundleDelegatingClassLoader.loadClass (BundleDelegatingClassLoader.java:389) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass (LogFactoryImpl.java:1005) at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation( LogFactoryImpl.java:838) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance( LogFactoryImpl.java:601) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance( LogFactoryImpl.java:333) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance( LogFactoryImpl.java:307) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645) at org.springframework.context.support.AbstractApplicationContext .(AbstractApplicationContext.java:134) at org.springframework.context.support.AbstractRefreshableApplicationContext .(AbstractRefreshableApplicationContext.java:80) at org.springframework.osgi.context.support.AbstractRefreshableOsgiBundleApplicationContext .(AbstractRefreshableOsgiBundleApplicationContext.java:115) at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext .(OsgiBundleXmlApplicationContext.java:57) at org.springframework.osgi.extender.support.ServiceDependentOsgiBundleXmlApplicationContext .(ServiceDependentOsgiBundleXmlApplicationContext.java:56) at org.springframework.osgi.extender.support.ApplicationContextCreator.createApplicationContext (ApplicationContextCreator.java:196) at org.springframework.osgi.extender.support.ApplicationContextCreator.run( ApplicationContextCreator.java:140) at java.lang.Thread.run(Thread.java:595) I'm getting this error when starting my bundle. I noticed through console that the extender service and all the spring modules are available. But the former gives list of these warnings WARNING: META-INF/spring.handlers ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.handlers) WARNING: META-INF/spring.schemas ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.schemas) WARNING: META-INF/spring/extender.xml ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring/extender.xml) Thank you. Sameera On 4/26/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: Sameera Withanage wrote: > Firstly thank you for all the help. > > I checked out the latest code and able to run it without that > numberformat > exception. I think I've done something wrong. > > But the spring service registration issue is still there. When I launched > Felix from command line I can see the registered services of my sample > spring bundle, but in embedded application it still returns null for > services[]. Which version of Felix and Spring-OSGi are you using? There was an issue where Spring-OSGi was making assumptions about the URL format being returned for bundle resources which was causing it to not correctly discover the Spring resource tiles, which ultimately led to it not creating Spring components/services, etc. Perhaps this is what you are seeing, but I thought it was fixed now. -> richard > > Sameera > > > > On 4/26/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: >> >> This is the host application >> >> import java.io.IOException; >> import java.util.ArrayList; >> import java.util.List; >> import java.util.Map; >> import java.util.Properties; >> >> import org.apache.felix.framework.Felix ; >> import org.apache.felix.framework.cache.BundleCache; >> import org.apache.felix.framework.util.Mutable
Re: Embedded Felix giving NumberFormatException
Sameera Withanage wrote: Firstly thank you for all the help. I checked out the latest code and able to run it without that numberformat exception. I think I've done something wrong. But the spring service registration issue is still there. When I launched Felix from command line I can see the registered services of my sample spring bundle, but in embedded application it still returns null for services[]. Which version of Felix and Spring-OSGi are you using? There was an issue where Spring-OSGi was making assumptions about the URL format being returned for bundle resources which was causing it to not correctly discover the Spring resource tiles, which ultimately led to it not creating Spring components/services, etc. Perhaps this is what you are seeing, but I thought it was fixed now. -> richard Sameera On 4/26/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: This is the host application import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.felix.framework.Felix ; import org.apache.felix.framework.cache.BundleCache; import org.apache.felix.framework.util.MutablePropertyResolver; import org.apache.felix.framework.util.MutablePropertyResolverImpl; import org.apache.felix.framework.util.StringMap ; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.util.tracker.ServiceTracker; import org.springframework.osgi.samples.simpleservice.MyService; public class FelixHost { private HostActivator m_activator = null; private Felix m_felix = null; private ServiceTracker m_tracker = null; public FelixHost() { Map configMap = new StringMap(false); Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream( "roland.properties")); } catch (IOException e) { e.printStackTrace(); } p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, " org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.0.0," + " org.osgi.service.url; version=1.0.0," + "org.springframework.osgi.samples.simpleservice ;"); p.put(BundleCache.CACHE_PROFILE_DIR_PROP, "/home/sameera/.felix/new1"); try { m_felix = new Felix(); m_activator = new HostActivator(); List act = new ArrayList(); act.add(m_activator); MutablePropertyResolver resolver = new MutablePropertyResolverImpl( p); m_felix.start(resolver, act); System.out.println("Felix started."); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } m_tracker = new ServiceTracker(m_activator.getContext(), MyService.class.getName(), null); m_tracker.open(); } public String callService() { Object[] services = m_tracker.getServices(); System.out.println("sevices length :" + services.length); for (int i = 0; (services != null) && (i < services.length); i++) { try { return ((MyService) services[i]).stringValue(); } catch (Exception ex) { System.out.println(ex); } } return "):"; } public Bundle[] getInstalledBundles() { return m_activator.getContext().getBundles(); } public BundleContext getContext() { return m_activator.getContext(); } public void shutdownApplication() { System.out.println("Shutting down Felix."); m_felix.shutdown(); } } and from another class FelixHost host = new FelixHost(); BundleContext context = host.getContext(); Bundle bundle = context.installBundle("file:/work/bundle.jar"); bundle.start(); Additionally the activator ... import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class HostActivator implements BundleActivator { private BundleContext m_context = null; public void start(BundleContext context) { m_context = context; } public void stop(BundleContext context) { m_context = null; } public BundleContext getContext() { return m_context; } } Thank you. Sameera On 4/25/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: > > I cannot see what is going wrong...it definitely appears to be getting a > different manifest file, because the bundle version number giving you an > exception is ${pom...} rather than a real version. > > Perhaps you should let us see your code for launching Felix and > i
Re: Embedded Felix giving NumberFormatException
Hi, This is the debug message I get when my service starts. DEBUG: WIRE: 31.0 -> org.springframework.osgi.samples.simpleservice -> 0 WARNING: META-INF/spring.handlers ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.handlers) WARNING: META-INF/spring.schemas ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.schemas) WARNING: META-INF/spring/extender.xml ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring/extender.xml) and when accessing WARNING: META-INF/services/org.apache.commons.logging.LogFactory ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/services/org.apache.commons.logging.LogFactory) WARNING: *** Class 'org.apache.commons.logging.impl.Log4JLogger' was not found. Bundle 31 does not import package 'org.apache.commons.logging.impl', nor is the package exported by any other bundle or available from the system class loader. *** (java.lang.ClassNotFoundException: *** Class ' org.apache.commons.logging.impl.Log4JLogger' was not found. Bundle 31 does not import package 'org.apache.commons.logging.impl', nor is the package exported by any other bundle or available from the system class loader. ***) Thank you Sameera On 4/26/07, Stuart McCulloch <[EMAIL PROTECTED]> wrote: Here's a thought - Spring-OSGi uses a bundle event listener to detect spring powered bundles (listener is registered by the spring-osgi-extender bundle). If this bundle is not started when your client bundle starts then it won't get the STARTED event and so won't wire up the necessary Spring services. You should ensure all the core Spring-OSGi bundles start first. If you still don't see the spring service then it may be that for some reason loading the bundle via the embedded app is not triggering the bundle event. You might want to turn on debug logging in log4j. On 26/04/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: > Firstly thank you for all the help. > > I checked out the latest code and able to run it without that numberformat > exception. I think I've done something wrong. > > But the spring service registration issue is still there. When I launched > Felix from command line I can see the registered services of my sample > spring bundle, but in embedded application it still returns null for > services[]. > > Sameera > > > > On 4/26/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: > > > > This is the host application > > > > import java.io.IOException; > > import java.util.ArrayList; > > import java.util.List; > > import java.util.Map; > > import java.util.Properties; > > > > import org.apache.felix.framework.Felix ; > > import org.apache.felix.framework.cache.BundleCache; > > import org.apache.felix.framework.util.MutablePropertyResolver; > > import org.apache.felix.framework.util.MutablePropertyResolverImpl; > > import org.apache.felix.framework.util.StringMap ; > > import org.osgi.framework.Bundle; > > import org.osgi.framework.BundleActivator; > > import org.osgi.framework.BundleContext; > > import org.osgi.framework.Constants; > > import org.osgi.util.tracker.ServiceTracker; > > import org.springframework.osgi.samples.simpleservice.MyService; > > > > public class FelixHost { > > private HostActivator m_activator = null; > > > > private Felix m_felix = null; > > > > private ServiceTracker m_tracker = null; > > > > public FelixHost() { > > Map configMap = new StringMap(false); > > > > Properties p = new Properties(); > > try { > > p.load(this.getClass ().getClassLoader().getResourceAsStream( > > "roland.properties")); > > } catch (IOException e) { > > e.printStackTrace(); > > } > > > > p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, > > " org.osgi.framework; version=1.3.0," > > + "org.osgi.service.packageadmin; version= 1.2.0," > > + "org.osgi.service.startlevel; version=1.0.0 ," > > + " org.osgi.service.url; version=1.0.0," > > + " org.springframework.osgi.samples.simpleservice > > ;"); > > p.put(BundleCache.CACHE_PROFILE_DIR_PROP, > > "/home/sameera/.felix/new1"); > > > > try { > > m_felix = new Felix(); > > > > m_activator = new HostActivator(); > > List act = new ArrayList(); > > act.add(m_activator); > > > > MutablePropertyResolver resolver = new > > MutablePropertyResolverImpl( > > p); > > m_felix.start(resolver, act); > > System.out.println("Felix started."); > > } catch (Exception ex) { > > System.err.println("Could not create framework: " + ex); > > ex.printStackTrace(); > > } > > > > m_tracker = new ServiceTracker(m_activator.getContext(), > > MyService.class.getName(), null); > > m_tracker.open(); >
Re: Embedded Felix giving NumberFormatException
Here's a thought - Spring-OSGi uses a bundle event listener to detect spring powered bundles (listener is registered by the spring-osgi-extender bundle). If this bundle is not started when your client bundle starts then it won't get the STARTED event and so won't wire up the necessary Spring services. You should ensure all the core Spring-OSGi bundles start first. If you still don't see the spring service then it may be that for some reason loading the bundle via the embedded app is not triggering the bundle event. You might want to turn on debug logging in log4j. On 26/04/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: Firstly thank you for all the help. I checked out the latest code and able to run it without that numberformat exception. I think I've done something wrong. But the spring service registration issue is still there. When I launched Felix from command line I can see the registered services of my sample spring bundle, but in embedded application it still returns null for services[]. Sameera On 4/26/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: > > This is the host application > > import java.io.IOException; > import java.util.ArrayList; > import java.util.List; > import java.util.Map; > import java.util.Properties; > > import org.apache.felix.framework.Felix ; > import org.apache.felix.framework.cache.BundleCache; > import org.apache.felix.framework.util.MutablePropertyResolver; > import org.apache.felix.framework.util.MutablePropertyResolverImpl; > import org.apache.felix.framework.util.StringMap ; > import org.osgi.framework.Bundle; > import org.osgi.framework.BundleActivator; > import org.osgi.framework.BundleContext; > import org.osgi.framework.Constants; > import org.osgi.util.tracker.ServiceTracker; > import org.springframework.osgi.samples.simpleservice.MyService; > > public class FelixHost { > private HostActivator m_activator = null; > > private Felix m_felix = null; > > private ServiceTracker m_tracker = null; > > public FelixHost() { > Map configMap = new StringMap(false); > > Properties p = new Properties(); > try { > p.load(this.getClass().getClassLoader().getResourceAsStream( > "roland.properties")); > } catch (IOException e) { > e.printStackTrace(); > } > > p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, > " org.osgi.framework; version=1.3.0," > + "org.osgi.service.packageadmin; version=1.2.0," > + "org.osgi.service.startlevel; version=1.0.0," > + " org.osgi.service.url; version=1.0.0," > + "org.springframework.osgi.samples.simpleservice > ;"); > p.put(BundleCache.CACHE_PROFILE_DIR_PROP, > "/home/sameera/.felix/new1"); > > try { > m_felix = new Felix(); > > m_activator = new HostActivator(); > List act = new ArrayList(); > act.add(m_activator); > > MutablePropertyResolver resolver = new > MutablePropertyResolverImpl( > p); > m_felix.start(resolver, act); > System.out.println("Felix started."); > } catch (Exception ex) { > System.err.println("Could not create framework: " + ex); > ex.printStackTrace(); > } > > m_tracker = new ServiceTracker(m_activator.getContext(), > MyService.class.getName(), null); > m_tracker.open(); > } > > public String callService() { > Object[] services = m_tracker.getServices(); > System.out.println("sevices length :" + services.length); > for (int i = 0; (services != null) && (i < services.length); i++) > { > try { > return ((MyService) services[i]).stringValue(); > > } catch (Exception ex) { > System.out.println(ex); > } > } > return "):"; > } > > public Bundle[] getInstalledBundles() { > return m_activator.getContext().getBundles(); > } > > public BundleContext getContext() { > return m_activator.getContext(); > } > > public void shutdownApplication() { > System.out.println("Shutting down Felix."); > m_felix.shutdown(); > } > > } > > and from another class > > FelixHost host = new FelixHost(); > BundleContext context = host.getContext(); > Bundle bundle = context.installBundle("file:/work/bundle.jar"); > bundle.start(); > > Additionally the activator ... > > import org.osgi.framework.BundleActivator; > import org.osgi.framework.BundleContext; > > public class HostActivator implements BundleActivator > { > private BundleContext m_context = null; > > public void start(BundleContext context) > { > m_context = context; > } > > public void stop(BundleContext context) > { > m_context = null; > } > > public BundleCon
Re: Embedded Felix giving NumberFormatException
Firstly thank you for all the help. I checked out the latest code and able to run it without that numberformat exception. I think I've done something wrong. But the spring service registration issue is still there. When I launched Felix from command line I can see the registered services of my sample spring bundle, but in embedded application it still returns null for services[]. Sameera On 4/26/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: This is the host application import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.felix.framework.Felix ; import org.apache.felix.framework.cache.BundleCache; import org.apache.felix.framework.util.MutablePropertyResolver; import org.apache.felix.framework.util.MutablePropertyResolverImpl; import org.apache.felix.framework.util.StringMap ; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.util.tracker.ServiceTracker; import org.springframework.osgi.samples.simpleservice.MyService; public class FelixHost { private HostActivator m_activator = null; private Felix m_felix = null; private ServiceTracker m_tracker = null; public FelixHost() { Map configMap = new StringMap(false); Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream( "roland.properties")); } catch (IOException e) { e.printStackTrace(); } p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, " org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.0.0," + " org.osgi.service.url; version=1.0.0," + "org.springframework.osgi.samples.simpleservice ;"); p.put(BundleCache.CACHE_PROFILE_DIR_PROP, "/home/sameera/.felix/new1"); try { m_felix = new Felix(); m_activator = new HostActivator(); List act = new ArrayList(); act.add(m_activator); MutablePropertyResolver resolver = new MutablePropertyResolverImpl( p); m_felix.start(resolver, act); System.out.println("Felix started."); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } m_tracker = new ServiceTracker(m_activator.getContext(), MyService.class.getName(), null); m_tracker.open(); } public String callService() { Object[] services = m_tracker.getServices(); System.out.println("sevices length :" + services.length); for (int i = 0; (services != null) && (i < services.length); i++) { try { return ((MyService) services[i]).stringValue(); } catch (Exception ex) { System.out.println(ex); } } return "):"; } public Bundle[] getInstalledBundles() { return m_activator.getContext().getBundles(); } public BundleContext getContext() { return m_activator.getContext(); } public void shutdownApplication() { System.out.println("Shutting down Felix."); m_felix.shutdown(); } } and from another class FelixHost host = new FelixHost(); BundleContext context = host.getContext(); Bundle bundle = context.installBundle("file:/work/bundle.jar"); bundle.start(); Additionally the activator ... import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class HostActivator implements BundleActivator { private BundleContext m_context = null; public void start(BundleContext context) { m_context = context; } public void stop(BundleContext context) { m_context = null; } public BundleContext getContext() { return m_context; } } Thank you. Sameera On 4/25/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: > > I cannot see what is going wrong...it definitely appears to be getting a > different manifest file, because the bundle version number giving you an > exception is ${pom...} rather than a real version. > > Perhaps you should let us see your code for launching Felix and > installing the bundle. > > -> richard > > Sameera Withanage wrote: > > I checked all the manifest entries in all jar files and found no > entries. > > But the entries I found were in pom.xml. > > > > I think something wrong the way I launched Felix, because standalone > is > > working fine. > > > > I'm loading bundle from a jar. It is from the simple-service-bundle > > sample > > comes with spring-osgi. > > > > -Bundle Content--- > > > >
Re: Embedded Felix giving NumberFormatException
This is the host application import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.felix.framework.Felix; import org.apache.felix.framework.cache.BundleCache; import org.apache.felix.framework.util.MutablePropertyResolver; import org.apache.felix.framework.util.MutablePropertyResolverImpl; import org.apache.felix.framework.util.StringMap; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.util.tracker.ServiceTracker; import org.springframework.osgi.samples.simpleservice.MyService; public class FelixHost { private HostActivator m_activator = null; private Felix m_felix = null; private ServiceTracker m_tracker = null; public FelixHost() { Map configMap = new StringMap(false); Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream( "roland.properties")); } catch (IOException e) { e.printStackTrace(); } p.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0," + "org.osgi.service.startlevel; version=1.0.0," + "org.osgi.service.url; version=1.0.0," + "org.springframework.osgi.samples.simpleservice ;"); p.put(BundleCache.CACHE_PROFILE_DIR_PROP, "/home/sameera/.felix/new1"); try { m_felix = new Felix(); m_activator = new HostActivator(); List act = new ArrayList(); act.add(m_activator); MutablePropertyResolver resolver = new MutablePropertyResolverImpl( p); m_felix.start(resolver, act); System.out.println("Felix started."); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } m_tracker = new ServiceTracker(m_activator.getContext(), MyService.class.getName(), null); m_tracker.open(); } public String callService() { Object[] services = m_tracker.getServices(); System.out.println("sevices length :" + services.length); for (int i = 0; (services != null) && (i < services.length); i++) { try { return ((MyService) services[i]).stringValue(); } catch (Exception ex) { System.out.println(ex); } } return "):"; } public Bundle[] getInstalledBundles() { return m_activator.getContext().getBundles(); } public BundleContext getContext() { return m_activator.getContext(); } public void shutdownApplication() { System.out.println("Shutting down Felix."); m_felix.shutdown(); } } and from another class FelixHost host = new FelixHost(); BundleContext context = host.getContext(); Bundle bundle = context.installBundle("file:/work/bundle.jar"); bundle.start(); Additionally the activator ... import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class HostActivator implements BundleActivator { private BundleContext m_context = null; public void start(BundleContext context) { m_context = context; } public void stop(BundleContext context) { m_context = null; } public BundleContext getContext() { return m_context; } } Thank you. Sameera On 4/25/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: I cannot see what is going wrong...it definitely appears to be getting a different manifest file, because the bundle version number giving you an exception is ${pom...} rather than a real version. Perhaps you should let us see your code for launching Felix and installing the bundle. -> richard Sameera Withanage wrote: > I checked all the manifest entries in all jar files and found no entries. > But the entries I found were in pom.xml. > > I think something wrong the way I launched Felix, because standalone is > working fine. > > I'm loading bundle from a jar. It is from the simple-service-bundle > sample > comes with spring-osgi. > > -Bundle Content--- > > META-INF/ > META-INF/MANIFEST.MF > META-INF/spring/ > META-INF/spring/simpleservice-osgi.xml > META-INF/spring/simpleservice.xml > META-INF/maven/ > META-INF/maven/org.springframework.osgi.samples/ > > META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/ > > META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/pom.xml > > > META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/pom.properties > > org/ > org/springframework/ > org/springframework/osgi/ > org/springframework/osgi/sa
Re: Embedded Felix giving NumberFormatException
I cannot see what is going wrong...it definitely appears to be getting a different manifest file, because the bundle version number giving you an exception is ${pom...} rather than a real version. Perhaps you should let us see your code for launching Felix and installing the bundle. -> richard Sameera Withanage wrote: I checked all the manifest entries in all jar files and found no entries. But the entries I found were in pom.xml. I think something wrong the way I launched Felix, because standalone is working fine. I'm loading bundle from a jar. It is from the simple-service-bundle sample comes with spring-osgi. -Bundle Content--- META-INF/ META-INF/MANIFEST.MF META-INF/spring/ META-INF/spring/simpleservice-osgi.xml META-INF/spring/simpleservice.xml META-INF/maven/ META-INF/maven/org.springframework.osgi.samples/ META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/ META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/pom.xml META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/pom.properties org/ org/springframework/ org/springframework/osgi/ org/springframework/osgi/samples/ org/springframework/osgi/samples/simpleservice/ org/springframework/osgi/samples/simpleservice/impl/ org/springframework/osgi/samples/simpleservice/impl/MyServiceImpl.class org/springframework/osgi/samples/simpleservice/MyService.class -Manifest file Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: sameera Build-Jdk: 1.5.0_09 Extension-Name: simple-service-bundle Specification-Title: The Spring-OSGi project makes it easy to build Sp ring applications that run in an OSGi framework. A Spring applicati on written in this way provides better separation of modules, the a bility to dynamically add, remove, and update modules in a running system, the ability to deploy multiple versions of a module simulta neously (and have clients automatically bind to the appropriate one ), and a dynamic service model. Specification-Vendor: Spring Framework Implementation-Vendor: Spring Framework Implementation-Title: simple-service-bundle Implementation-Version: 1.0-m1 Bundle-Version: 1.0 Bundle-Vendor: Spring Framework Bundle-DocURL: http://www.springframework.org/osgi Bundle-ClassPath: .,target/classes/ Bundle-SymbolicName: org.springframework.osgi.samples.simpleservice Bundle-Name: Simple-Service-Sample Export-Package: org.springframework.osgi.samples.simpleservice Simpleservice.xml --- http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd";> Simpleservice-OSGi.xml --- http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:osgi="http://www.springframework.org/schema/osgi"; xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd";> interface="org.springframework.osgi.samples.simpleservice.MyService" /> --- Thank you Sameera On 4/24/07, Stuart McCulloch <[EMAIL PROTECTED]> wrote: On 25/04/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: > I'm using the Felix built from trunk. > > Here is the exception... > > java.lang.NumberFormatException: For input string: "${pom" Looks like it's using a manifest that hasn't been filtered by maven and still has the ${pom} variable, which of course is not valid. The warnings from spring-osgi are possibly related - build issue? Are you loading this bundle from a jar or directory? Could you provide a jar / directory listing along with the manifest? > at java.lang.NumberFormatException.forInputString( > NumberFormatException.java :48) > at java.lang.Integer.parseInt(Integer.java:447) > at java.lang.Integer.parseInt(Integer.java:497) > at org.osgi.framework.Version.(Version.java:127) > at org.osgi.framework.Version.parseVersion (Version.java:208) > at org.apache.felix.framework.Felix.createModule(Felix.java:3112) > at org.apache.felix.framework.Felix.createBundleInfo(Felix.java :3057) > at org.apache.felix.framework.Felix.installBundle (Felix.java:1961) > at org.apache.felix.framework.Felix.start(Felix.java:443) > at com.aeturnum.athiva.rnd.FelixHost.(FelixHost.java:82) > at com.aeturnum.athiva.rnd.Main.main(Main.java:17) > org.osgi.framework.BundleException : Could not create bundle object. > at org.apache.felix.framework.Felix.installBundle(Felix.java:2012) > at org.apache.felix.framework.Felix.start(Felix.java:443) > at com.aeturnum.athiva.rnd.FelixHost.( FelixHost.java:
Re: Embedded Felix giving NumberFormatException
I checked all the manifest entries in all jar files and found no entries. But the entries I found were in pom.xml. I think something wrong the way I launched Felix, because standalone is working fine. I'm loading bundle from a jar. It is from the simple-service-bundle sample comes with spring-osgi. -Bundle Content--- META-INF/ META-INF/MANIFEST.MF META-INF/spring/ META-INF/spring/simpleservice-osgi.xml META-INF/spring/simpleservice.xml META-INF/maven/ META-INF/maven/org.springframework.osgi.samples/ META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/ META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/pom.xml META-INF/maven/org.springframework.osgi.samples/simple-service-bundle/pom.properties org/ org/springframework/ org/springframework/osgi/ org/springframework/osgi/samples/ org/springframework/osgi/samples/simpleservice/ org/springframework/osgi/samples/simpleservice/impl/ org/springframework/osgi/samples/simpleservice/impl/MyServiceImpl.class org/springframework/osgi/samples/simpleservice/MyService.class -Manifest file Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: sameera Build-Jdk: 1.5.0_09 Extension-Name: simple-service-bundle Specification-Title: The Spring-OSGi project makes it easy to build Sp ring applications that run in an OSGi framework. A Spring applicati on written in this way provides better separation of modules, the a bility to dynamically add, remove, and update modules in a running system, the ability to deploy multiple versions of a module simulta neously (and have clients automatically bind to the appropriate one ), and a dynamic service model. Specification-Vendor: Spring Framework Implementation-Vendor: Spring Framework Implementation-Title: simple-service-bundle Implementation-Version: 1.0-m1 Bundle-Version: 1.0 Bundle-Vendor: Spring Framework Bundle-DocURL: http://www.springframework.org/osgi Bundle-ClassPath: .,target/classes/ Bundle-SymbolicName: org.springframework.osgi.samples.simpleservice Bundle-Name: Simple-Service-Sample Export-Package: org.springframework.osgi.samples.simpleservice Simpleservice.xml --- http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd";> Simpleservice-OSGi.xml --- http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:osgi="http://www.springframework.org/schema/osgi"; xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd";> --- Thank you Sameera On 4/24/07, Stuart McCulloch <[EMAIL PROTECTED]> wrote: On 25/04/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: > I'm using the Felix built from trunk. > > Here is the exception... > > java.lang.NumberFormatException: For input string: "${pom" Looks like it's using a manifest that hasn't been filtered by maven and still has the ${pom} variable, which of course is not valid. The warnings from spring-osgi are possibly related - build issue? Are you loading this bundle from a jar or directory? Could you provide a jar / directory listing along with the manifest? > at java.lang.NumberFormatException.forInputString( > NumberFormatException.java :48) > at java.lang.Integer.parseInt(Integer.java:447) > at java.lang.Integer.parseInt(Integer.java:497) > at org.osgi.framework.Version.(Version.java:127) > at org.osgi.framework.Version.parseVersion (Version.java:208) > at org.apache.felix.framework.Felix.createModule(Felix.java:3112) > at org.apache.felix.framework.Felix.createBundleInfo(Felix.java :3057) > at org.apache.felix.framework.Felix.installBundle (Felix.java:1961) > at org.apache.felix.framework.Felix.start(Felix.java:443) > at com.aeturnum.athiva.rnd.FelixHost.(FelixHost.java:82) > at com.aeturnum.athiva.rnd.Main.main(Main.java:17) > org.osgi.framework.BundleException : Could not create bundle object. > at org.apache.felix.framework.Felix.installBundle(Felix.java:2012) > at org.apache.felix.framework.Felix.start(Felix.java:443) > at com.aeturnum.athiva.rnd.FelixHost.( FelixHost.java:82) > at com.aeturnum.athiva.rnd.Main.main(Main.java:17) > Caused by: java.lang.NumberFormatException: For input string: "${pom" > at java.lang.NumberFormatException.forInputString( > NumberFormatException.java :48) > at java.lang.Integer.parseInt(Integer.java:447) > at java.lang.Integer.parseInt(Integer.java:497) > at org.osgi.framework.Version.(Version.java:127) > at org.osgi.framework.Ver
Re: Embedded Felix giving NumberFormatException
On 25/04/07, Sameera Withanage <[EMAIL PROTECTED]> wrote: I'm using the Felix built from trunk. Here is the exception... java.lang.NumberFormatException: For input string: "${pom" Looks like it's using a manifest that hasn't been filtered by maven and still has the ${pom} variable, which of course is not valid. The warnings from spring-osgi are possibly related - build issue? Are you loading this bundle from a jar or directory? Could you provide a jar / directory listing along with the manifest? at java.lang.NumberFormatException.forInputString( NumberFormatException.java :48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at org.osgi.framework.Version.(Version.java:127) at org.osgi.framework.Version.parseVersion (Version.java:208) at org.apache.felix.framework.Felix.createModule(Felix.java:3112) at org.apache.felix.framework.Felix.createBundleInfo(Felix.java:3057) at org.apache.felix.framework.Felix.installBundle (Felix.java:1961) at org.apache.felix.framework.Felix.start(Felix.java:443) at com.aeturnum.athiva.rnd.FelixHost.(FelixHost.java:82) at com.aeturnum.athiva.rnd.Main.main(Main.java:17) org.osgi.framework.BundleException : Could not create bundle object. at org.apache.felix.framework.Felix.installBundle(Felix.java:2012) at org.apache.felix.framework.Felix.start(Felix.java:443) at com.aeturnum.athiva.rnd.FelixHost.( FelixHost.java:82) at com.aeturnum.athiva.rnd.Main.main(Main.java:17) Caused by: java.lang.NumberFormatException: For input string: "${pom" at java.lang.NumberFormatException.forInputString( NumberFormatException.java :48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at org.osgi.framework.Version.(Version.java:127) at org.osgi.framework.Version.parseVersion (Version.java:208) at org.apache.felix.framework.Felix.createModule(Felix.java:3112) at org.apache.felix.framework.Felix.createBundleInfo(Felix.java:3057) at org.apache.felix.framework.Felix.installBundle (Felix.java:1961) ... 3 more And additionally once I start a spring bundle it gives this warnings and not registering services exported from it. WARNING: META-INF/spring.handlers ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.handlers) WARNING: META-INF/spring.schemas ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.schemas) I'm still new to relate this exception to some place, but this bundle works fine in standalone felix and it registers the services as well. Thank you Sameera On 4/24/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: > > Could you post the exception? > > Also, are you using Felix built from trunk or 0.8.0-incubator ? > > -> richard > > Sameera Withanage wrote: > > Hi, > > > > I'm embedding Felix in a host application following the examples given > in > > Felix site. When I'm trying to install a bundle, for instance > > spring-osgi, > > it gives NumberformatException. I installed the same set of bundles > using > > standalone Felix console and all started successfully. I couldn't > > figure out > > why the same is not happening at embedded version. > > > > I tried removing all the META-INF/maven folders from jar bundles and > > found > > all bundles are starting, but it seems not practicle to always edit > > bundles. > > > > Any help would be greatly appreciated. > > > > Sameera > > > -- Cheers, Stuart
Re: Embedded Felix giving NumberFormatException
I'm using the Felix built from trunk. Here is the exception... java.lang.NumberFormatException: For input string: "${pom" at java.lang.NumberFormatException.forInputString( NumberFormatException.java :48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at org.osgi.framework.Version.(Version.java:127) at org.osgi.framework.Version.parseVersion (Version.java:208) at org.apache.felix.framework.Felix.createModule(Felix.java:3112) at org.apache.felix.framework.Felix.createBundleInfo(Felix.java:3057) at org.apache.felix.framework.Felix.installBundle (Felix.java:1961) at org.apache.felix.framework.Felix.start(Felix.java:443) at com.aeturnum.athiva.rnd.FelixHost.(FelixHost.java:82) at com.aeturnum.athiva.rnd.Main.main(Main.java:17) org.osgi.framework.BundleException : Could not create bundle object. at org.apache.felix.framework.Felix.installBundle(Felix.java:2012) at org.apache.felix.framework.Felix.start(Felix.java:443) at com.aeturnum.athiva.rnd.FelixHost.( FelixHost.java:82) at com.aeturnum.athiva.rnd.Main.main(Main.java:17) Caused by: java.lang.NumberFormatException: For input string: "${pom" at java.lang.NumberFormatException.forInputString( NumberFormatException.java :48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at org.osgi.framework.Version.(Version.java:127) at org.osgi.framework.Version.parseVersion (Version.java:208) at org.apache.felix.framework.Felix.createModule(Felix.java:3112) at org.apache.felix.framework.Felix.createBundleInfo(Felix.java:3057) at org.apache.felix.framework.Felix.installBundle (Felix.java:1961) ... 3 more And additionally once I start a spring bundle it gives this warnings and not registering services exported from it. WARNING: META-INF/spring.handlers ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.handlers) WARNING: META-INF/spring.schemas ( org.apache.felix.moduleloader.ResourceNotFoundException: META-INF/spring.schemas) I'm still new to relate this exception to some place, but this bundle works fine in standalone felix and it registers the services as well. Thank you Sameera On 4/24/07, Richard S. Hall <[EMAIL PROTECTED]> wrote: Could you post the exception? Also, are you using Felix built from trunk or 0.8.0-incubator ? -> richard Sameera Withanage wrote: > Hi, > > I'm embedding Felix in a host application following the examples given in > Felix site. When I'm trying to install a bundle, for instance > spring-osgi, > it gives NumberformatException. I installed the same set of bundles using > standalone Felix console and all started successfully. I couldn't > figure out > why the same is not happening at embedded version. > > I tried removing all the META-INF/maven folders from jar bundles and > found > all bundles are starting, but it seems not practicle to always edit > bundles. > > Any help would be greatly appreciated. > > Sameera >
Re: Embedded Felix giving NumberFormatException
Could you post the exception? Also, are you using Felix built from trunk or 0.8.0-incubator? -> richard Sameera Withanage wrote: Hi, I'm embedding Felix in a host application following the examples given in Felix site. When I'm trying to install a bundle, for instance spring-osgi, it gives NumberformatException. I installed the same set of bundles using standalone Felix console and all started successfully. I couldn't figure out why the same is not happening at embedded version. I tried removing all the META-INF/maven folders from jar bundles and found all bundles are starting, but it seems not practicle to always edit bundles. Any help would be greatly appreciated. Sameera
Re: Embedded Felix
Felix Meschberger wrote: Hi Asaf, The main problem you would probably face when getting your hands on something inside the OSGi framework is ClassLoading issues: You will have to use a class (usually and interface) which is loaded from a class laoder commoner to both the OSGi framework and the "outer world". On the other hand, you might want your inside objects make themselves known to the outside world through - for example - a bridge service, which is registered by a BundleActivator given to the Felix constructor. This is how the Equinox HttpService to Servlet bridge works. To be precise, you don't pass in BundleActivator instances to the Felix constructor, but to Felix.start(). Regardless, this is the appropriate way to embed Felix and get access to the System Bundle context object, because each passed in BundleActivator instance is treated as an extension of the System Bundle, where start() and stop() on each will be invoked when the System Bundle is started and stopped, respectively. This is the approach for your host application (i.e., the embedding application) to get a context to interact with the framework and any installed bundles/services, such as installing/removing bundles or using/providing services. All is not roses however, there is a catch. If the host application wants to use services from bundles or provide services to bundles, the service interface classes must come from the class path so that the host application and the bundles use the same class definitions. As Felix points out elsewhere, you can use the org.osgi.framework.system.packages property to export packages from the class path via the System Bundle. There is one alternative, which is if you just want to use services in the host application, you can instead use reflection to invoke service methods, then the host application does not need access to the class definitions at all. -> richard The details - as always - depend on what exactly you want to achieve. Anyway, I would not hold on to the BundleContext given to an Activator for this. Hope this helps a bit. Regards Felix On 4/11/07, Asaf Lahav <[EMAIL PROTECTED]> wrote: Hi everybody, I am running Felix as an Embedded OSGi framework. What would be the best way for components outside of the OSGi boundaries to consume OSGi bundles and service references? In other words, would it be bad design to maintain a singleton instance of a context handle I get in my custom activator? If it is, what would be a better design? Thanks in advance, Asaf
Re: Embedded Felix
Yes, by listing such packages in the "org.osgi.framework.system.packages" property given to the Felix constructor, you may make external packages visible inside the framework and hence use and share objects created from those classes. Regards Felix On 4/11/07, asaf.lahav <[EMAIL PROTECTED]> wrote: Isn't it possible to specify via the "Import-Package" configuration element which packages are to be loaded from the underlying class loader/bundle class loader? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Felix Meschberger Sent: Wednesday, April 11, 2007 7:42 PM To: felix-dev@incubator.apache.org Subject: Re: Embedded Felix Hi Asaf, The main problem you would probably face when getting your hands on something inside the OSGi framework is ClassLoading issues: You will have to use a class (usually and interface) which is loaded from a class laoder commoner to both the OSGi framework and the "outer world". On the other hand, you might want your inside objects make themselves known to the outside world through - for example - a bridge service, which is registered by a BundleActivator given to the Felix constructor. This is how the Equinox HttpService to Servlet bridge works. The details - as always - depend on what exactly you want to achieve. Anyway, I would not hold on to the BundleContext given to an Activator for this. Hope this helps a bit. Regards Felix On 4/11/07, Asaf Lahav <[EMAIL PROTECTED]> wrote: > > Hi everybody, > > > > I am running Felix as an Embedded OSGi framework. > > What would be the best way for components outside of the OSGi boundaries > to > consume OSGi bundles and service references? > > In other words, would it be bad design to maintain a singleton instance of > a > context handle I get in my custom activator? > > If it is, what would be a better design? > > > > Thanks in advance, > > Asaf > >
RE: Embedded Felix
Isn't it possible to specify via the "Import-Package" configuration element which packages are to be loaded from the underlying class loader/bundle class loader? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Felix Meschberger Sent: Wednesday, April 11, 2007 7:42 PM To: felix-dev@incubator.apache.org Subject: Re: Embedded Felix Hi Asaf, The main problem you would probably face when getting your hands on something inside the OSGi framework is ClassLoading issues: You will have to use a class (usually and interface) which is loaded from a class laoder commoner to both the OSGi framework and the "outer world". On the other hand, you might want your inside objects make themselves known to the outside world through - for example - a bridge service, which is registered by a BundleActivator given to the Felix constructor. This is how the Equinox HttpService to Servlet bridge works. The details - as always - depend on what exactly you want to achieve. Anyway, I would not hold on to the BundleContext given to an Activator for this. Hope this helps a bit. Regards Felix On 4/11/07, Asaf Lahav <[EMAIL PROTECTED]> wrote: > > Hi everybody, > > > > I am running Felix as an Embedded OSGi framework. > > What would be the best way for components outside of the OSGi boundaries > to > consume OSGi bundles and service references? > > In other words, would it be bad design to maintain a singleton instance of > a > context handle I get in my custom activator? > > If it is, what would be a better design? > > > > Thanks in advance, > > Asaf > >
Re: Embedded Felix
Hi Asaf, The main problem you would probably face when getting your hands on something inside the OSGi framework is ClassLoading issues: You will have to use a class (usually and interface) which is loaded from a class laoder commoner to both the OSGi framework and the "outer world". On the other hand, you might want your inside objects make themselves known to the outside world through - for example - a bridge service, which is registered by a BundleActivator given to the Felix constructor. This is how the Equinox HttpService to Servlet bridge works. The details - as always - depend on what exactly you want to achieve. Anyway, I would not hold on to the BundleContext given to an Activator for this. Hope this helps a bit. Regards Felix On 4/11/07, Asaf Lahav <[EMAIL PROTECTED]> wrote: Hi everybody, I am running Felix as an Embedded OSGi framework. What would be the best way for components outside of the OSGi boundaries to consume OSGi bundles and service references? In other words, would it be bad design to maintain a singleton instance of a context handle I get in my custom activator? If it is, what would be a better design? Thanks in advance, Asaf