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
().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<BundleActivator> 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/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 ---
>>>> > <?xml version="1.0" encoding="UTF-8"?>
>>>> > <beans xmlns="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";>
>>>> >
>>>> >  <bean name="simpleService" class="
>>>> >
>>>> org.springframework.osgi.samples.simpleservice.impl.MyServiceImpl" />
>>>> >
>>>> > </beans>
>>>> >
>>>> > ----Simpleservice-OSGi.xml ---
>>>> >
>>>> > <?xml version="1.0" encoding="UTF-8"?>
>>>> > <beans xmlns="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";>
>>>> >
>>>> >  <osgi:service id="simpleServiceOsgi" ref="simpleService"
>>>> >
>>>> >
>>>> interface="org.springframework.osgi.samples.simpleservice.MyService"
>>>> />
>>>> >
>>>> > </beans>
>>>> >
>>>> > -------------------------------------------
>>>> >
>>>> > 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.<init>(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.<init>(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.<init>(
>>>> 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.<init>(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
>>>> >>
>>>> >
>>>>
>>>


Reply via email to