You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Marta Luna Serrano <ma...@gmail.com> on 2009/06/16 13:21:37 UTC

Problem with starting bundles

Hi everyone!!
I try to embbed felix into a Web page, I have follow the way that it is
explain here:
http://felix.apache.org/site/launching-and-embedding-apache-felix.html
But when I oppen the browser, I find that there are no bundles in the
cache...
I have no errors in the Java Console...
This is my code:

private static final String AUTO_START_PROP = AutoActivator.AUTO_START_PROP;


    // the felix instance
    private Felix felix = null;

    private HostActivator m_activator = null;

    // the activator for the applet bundle
    private AppletActivator appletActivator = null;


    public void init()
    {

        userHome = System.getProperty("user.home") + File.separator;
// remove the cache dir from a previous startup to make sure that the new
bundles are loaded
        File existingCacheDir = new File(userHome + CACHE_DIR);
        //if (existingCacheDir.exists())
        //{
            //boolean deleted = deleteDirectory(existingCacheDir);
        //}

        // use the codeBase as the server we are running on
        String server = getCodeBase().toString();

        // Print welcome banner.
        System.out.println("\nWelcome to Felix.");
        System.out.println("=================\n");

       // Map<String, String> configMap = new StringMap(false);

        // Configure the Felix instance to be embedded.
        // Create a configuration property map.
       Map configMap = new StringMap(false);

        // Create host activator;
        m_activator = new HostActivator();
        List list = new ArrayList();
        list.add(m_activator);
        configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);

        //configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
"true");

        // add all the framework system packages to the config map
        //configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP,"true");
        configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
            "org.osgi.framework; version=1.3.0," +


            "javax.swing;" +
            "javax.swing.event;" +
            "javax.swing.table;" +
            "javax.swing.text;" + .....

        // add all the bundles we need to the config map
       /* configMap.put(AUTO_START_PROP + ".10",
                server +
"lib/bundle/org.apache.felix.bundlerepository-1.0.0.jar " +
                server +
"lib/bundle/org.apache.felix.servicebinder-0.9.0-SNAPSHOT.jar");
        // And more bundles


        configMap.put("org.osgi.framework.startlevel", "100");

        configMap.put("felix.startlevel.framework", "100");

        configMap.put("felix.startlevel.bundle", "100");

        // this prevents felix from loading stream and content factories a
second time
        configMap.put("felix.service.urlhandlers", "false");


        // create an AppletActivator to make this applet available to the
framework
        appletActivator = new AppletActivator(this);

        // add this appletActivator to the parameter list for felix
    //    List list = new ArrayList();
        list.add(appletActivator);

        // add an autoActivator to start the bundles - only in Felix 1.0.3
//        list.add(new AutoActivator(configMap));

        try
       {
            // Now create an instance of the framework.
            //System.out.println(configMap);
            felix = new Felix(configMap);
            // and start it!
            felix.start();
            System.out.println("Se crea el framework");
        }
        catch (Exception ex)
        {
            System.err.println("Could not create framework: " + ex);
            ex.printStackTrace();
        }
    }

Can anybody help me?
Thanks in advance,
Regards
Marta

Re: Problem with starting bundles

Posted by Marta Luna Serrano <ma...@gmail.com>.
Hi!
Thanks for your reply, but I still have the same problem...
I am using Felix 1.3.0... the problem I have is that although the program
creates cache directory correctly, the bundles don't start... and as a
result I have the directory of bundle0 empty.
Any idea?
Thanks!!
Marta

2009/6/16 Richard S. Hall <he...@ungoverned.org>

> Assuming you are using Felix 1.8.0...
>
> I think you need to look at the launching and embedding documentation
> again...it looks like you are mixing info from an older version of Felix.
>
> I see one outdated property below:
>
>   * org.osgi.framework.startlevel should be
>     org.osgi.framework.startlevel.beginning, which replaced
>     felix.startlevel.framework.
>
> You no longer need to specify the system packages in configMap, although
> you can if you want to narrow down the default value.
>
> Also, you still need to use the AutoActivator if you want to auto-start
> bundles, which it looks like you've commented it out.
>
> Again, go back to the documentation page and try to rectify your approach
> with what is there.
>
> -> richard
>
>
> On 6/16/09 7:21 AM, Marta Luna Serrano wrote:
>
>> Hi everyone!!
>> I try to embbed felix into a Web page, I have follow the way that it is
>> explain here:
>> http://felix.apache.org/site/launching-and-embedding-apache-felix.html
>> But when I oppen the browser, I find that there are no bundles in the
>> cache...
>> I have no errors in the Java Console...
>> This is my code:
>>
>> private static final String AUTO_START_PROP =
>> AutoActivator.AUTO_START_PROP;
>>
>>
>>     // the felix instance
>>     private Felix felix = null;
>>
>>     private HostActivator m_activator = null;
>>
>>     // the activator for the applet bundle
>>     private AppletActivator appletActivator = null;
>>
>>
>>     public void init()
>>     {
>>
>>         userHome = System.getProperty("user.home") + File.separator;
>> // remove the cache dir from a previous startup to make sure that the new
>> bundles are loaded
>>         File existingCacheDir = new File(userHome + CACHE_DIR);
>>         //if (existingCacheDir.exists())
>>         //{
>>             //boolean deleted = deleteDirectory(existingCacheDir);
>>         //}
>>
>>         // use the codeBase as the server we are running on
>>         String server = getCodeBase().toString();
>>
>>         // Print welcome banner.
>>         System.out.println("\nWelcome to Felix.");
>>         System.out.println("=================\n");
>>
>>        // Map<String, String>  configMap = new StringMap(false);
>>
>>         // Configure the Felix instance to be embedded.
>>         // Create a configuration property map.
>>        Map configMap = new StringMap(false);
>>
>>         // Create host activator;
>>         m_activator = new HostActivator();
>>         List list = new ArrayList();
>>         list.add(m_activator);
>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
>>
>>         //configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>> "true");
>>
>>         // add all the framework system packages to the config map
>>         //configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP,"true");
>>         configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
>>             "org.osgi.framework; version=1.3.0," +
>>
>>
>>             "javax.swing;" +
>>             "javax.swing.event;" +
>>             "javax.swing.table;" +
>>             "javax.swing.text;" + .....
>>
>>         // add all the bundles we need to the config map
>>        /* configMap.put(AUTO_START_PROP + ".10",
>>                 server +
>> "lib/bundle/org.apache.felix.bundlerepository-1.0.0.jar " +
>>                 server +
>> "lib/bundle/org.apache.felix.servicebinder-0.9.0-SNAPSHOT.jar");
>>         // And more bundles
>>
>>
>>         configMap.put("org.osgi.framework.startlevel", "100");
>>
>>         configMap.put("felix.startlevel.framework", "100");
>>
>>         configMap.put("felix.startlevel.bundle", "100");
>>
>>         // this prevents felix from loading stream and content factories a
>> second time
>>         configMap.put("felix.service.urlhandlers", "false");
>>
>>
>>         // create an AppletActivator to make this applet available to the
>> framework
>>         appletActivator = new AppletActivator(this);
>>
>>         // add this appletActivator to the parameter list for felix
>>     //    List list = new ArrayList();
>>         list.add(appletActivator);
>>
>>         // add an autoActivator to start the bundles - only in Felix 1.0.3
>> //        list.add(new AutoActivator(configMap));
>>
>>         try
>>        {
>>             // Now create an instance of the framework.
>>             //System.out.println(configMap);
>>             felix = new Felix(configMap);
>>             // and start it!
>>             felix.start();
>>             System.out.println("Se crea el framework");
>>         }
>>         catch (Exception ex)
>>         {
>>             System.err.println("Could not create framework: " + ex);
>>             ex.printStackTrace();
>>         }
>>     }
>>
>> Can anybody help me?
>> Thanks in advance,
>> Regards
>> Marta
>>
>>
>>
>

Re: Problem with starting bundles

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Assuming you are using Felix 1.8.0...

I think you need to look at the launching and embedding documentation 
again...it looks like you are mixing info from an older version of Felix.

I see one outdated property below:

    * org.osgi.framework.startlevel should be
      org.osgi.framework.startlevel.beginning, which replaced
      felix.startlevel.framework.

You no longer need to specify the system packages in configMap, although 
you can if you want to narrow down the default value.

Also, you still need to use the AutoActivator if you want to auto-start 
bundles, which it looks like you've commented it out.

Again, go back to the documentation page and try to rectify your 
approach with what is there.

-> richard

On 6/16/09 7:21 AM, Marta Luna Serrano wrote:
> Hi everyone!!
> I try to embbed felix into a Web page, I have follow the way that it is
> explain here:
> http://felix.apache.org/site/launching-and-embedding-apache-felix.html
> But when I oppen the browser, I find that there are no bundles in the
> cache...
> I have no errors in the Java Console...
> This is my code:
>
> private static final String AUTO_START_PROP = AutoActivator.AUTO_START_PROP;
>
>
>      // the felix instance
>      private Felix felix = null;
>
>      private HostActivator m_activator = null;
>
>      // the activator for the applet bundle
>      private AppletActivator appletActivator = null;
>
>
>      public void init()
>      {
>
>          userHome = System.getProperty("user.home") + File.separator;
> // remove the cache dir from a previous startup to make sure that the new
> bundles are loaded
>          File existingCacheDir = new File(userHome + CACHE_DIR);
>          //if (existingCacheDir.exists())
>          //{
>              //boolean deleted = deleteDirectory(existingCacheDir);
>          //}
>
>          // use the codeBase as the server we are running on
>          String server = getCodeBase().toString();
>
>          // Print welcome banner.
>          System.out.println("\nWelcome to Felix.");
>          System.out.println("=================\n");
>
>         // Map<String, String>  configMap = new StringMap(false);
>
>          // Configure the Felix instance to be embedded.
>          // Create a configuration property map.
>         Map configMap = new StringMap(false);
>
>          // Create host activator;
>          m_activator = new HostActivator();
>          List list = new ArrayList();
>          list.add(m_activator);
>          configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
>
>          //configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
> "true");
>
>          // add all the framework system packages to the config map
>          //configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP,"true");
>          configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
>              "org.osgi.framework; version=1.3.0," +
>
>
>              "javax.swing;" +
>              "javax.swing.event;" +
>              "javax.swing.table;" +
>              "javax.swing.text;" + .....
>
>          // add all the bundles we need to the config map
>         /* configMap.put(AUTO_START_PROP + ".10",
>                  server +
> "lib/bundle/org.apache.felix.bundlerepository-1.0.0.jar " +
>                  server +
> "lib/bundle/org.apache.felix.servicebinder-0.9.0-SNAPSHOT.jar");
>          // And more bundles
>
>
>          configMap.put("org.osgi.framework.startlevel", "100");
>
>          configMap.put("felix.startlevel.framework", "100");
>
>          configMap.put("felix.startlevel.bundle", "100");
>
>          // this prevents felix from loading stream and content factories a
> second time
>          configMap.put("felix.service.urlhandlers", "false");
>
>
>          // create an AppletActivator to make this applet available to the
> framework
>          appletActivator = new AppletActivator(this);
>
>          // add this appletActivator to the parameter list for felix
>      //    List list = new ArrayList();
>          list.add(appletActivator);
>
>          // add an autoActivator to start the bundles - only in Felix 1.0.3
> //        list.add(new AutoActivator(configMap));
>
>          try
>         {
>              // Now create an instance of the framework.
>              //System.out.println(configMap);
>              felix = new Felix(configMap);
>              // and start it!
>              felix.start();
>              System.out.println("Se crea el framework");
>          }
>          catch (Exception ex)
>          {
>              System.err.println("Could not create framework: " + ex);
>              ex.printStackTrace();
>          }
>      }
>
> Can anybody help me?
> Thanks in advance,
> Regards
> Marta
>
>