You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Vinicius Carvalho <vi...@caravelatech.com> on 2009/01/15 17:19:13 UTC

Web console

Hello there! I'm reading the webconsole docs, but I really did not get how
to get it working. I'm lauching felix inside a container. I've checked
Sling, and eclipse equinox-server site, but one thing that I can't figure is
what is needed to get the webconsole running?

Just putting the equinox httpservice there won't work. From the examples
I've seen it seems that I need to register the servlets, but for web console
which one?

Could someone help me on this?

Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well thanks a lot. I've placed it under
www.furiousbob.com/spotlight.zip(Sorry we are still working on a
public svn)

This is the structure so far:

spotlight/
pom.xml (parent pom)
spotlight-graph/ Graph API, not used yet on this osgi issue

spotligh-core/ (this is the web project)
servlet-1.0.1.jar (this is a build of the latest equinox HTTPService, we
install in our local repository in order to use it)

Inside spotlight-core, for now we decided to put all our bundles inside
web-inf/resources/bundles, so all libs are packed not referenced by maven
(yet)

Ok, as the spotlight core, we tried the same approach as sling:

OSLServlet is the servlet that should repond on /config and than delegate to
the web console, this servlet creates a class named OSL (more bellow) and
creates the HttpServiceServlet and configures it as well.

OSL is the class responsible to startup felix, it's also a BundleActivator,
and we use a BootstrapInstaller (from sling) to start and install all
bundles, the BootstrapInstaller is  a BundleActivator.

As I mentioned, from what I've seen, everything goes normal, but the
HTTPServiceTracker of the webconsole never gets fired, don't know why. So
the ProxyServlet from equinox never gets a registration, and always send an
HttpError as response.

Using Pax-Web, the webconsole Tracker gets called, but, I have no delegate
servlet (don't know how to do it)

Well, thanks very much for the help, If you need any other information
please let us know.

We are very, very happy with your help

Best regards


On Wed, Jan 21, 2009 at 6:13 PM, Karl Pauls <ka...@gmail.com> wrote:

> Well, can you make your project available someplace so that we can
> have a look at what is going wrong exactly?
>
> regards,
>
> Karl
>
> On Wed, Jan 21, 2009 at 8:10 PM, Vinicius Carvalho
> <vi...@caravelatech.com> wrote:
> > Hello there! We are almost giving up on OSGi since we can not find how to
> > get the webconsole running. It's a real pain to get it working inside a
> > servlet container. We've debugged the entire sling app and it works as a
> > charm (although it uses older versions of all libs). I really can't
> imagine
> > why after my HttpServiceServlet gets started and register itsefl as and
> > HTTPService service in the context the ServiceTracker of the webconsole
> is
> > not triggered.
> >
> > We tried to replace equinox httpservice by pax-web, and the Tracker this
> > time gets notified but, we could not access the console since there's no
> > servlet to delegate the service. We are still checking this, I wish I
> could
> > use the embedded version of containers like tomcat and jetty, the way
> spring
> > DM does, or even use spring dm server, but unfortunatelly we need to be
> able
> > to deploy on any container, and this is my last week, if that does not
> work,
> > we might drop OSGi and use another approach to build our modules.
> >
> > Anyone got another idea that could help us?
> >
> > Regards
> >
> > On Tue, Jan 20, 2009 at 3:47 PM, Vinicius Carvalho <
> > vinicius@caravelatech.com> wrote:
> >
> >> Well, Sling uses Felix 1.0.4 right? I'm running my tests with 1.4.1 and
> >> also I have a newer version of the equinox. After running sling on debug
> >> mode here I found that the source I have for the equinox server api is
> not
> >> the same. I wonder if this is the problem. One difference I have is the
> >> props.put(EMBEDDED_EXECUTION_PROP, "true"); since it seems that it does
> not
> >> exist anymore.
> >>
> >>
> >> On Tue, Jan 20, 2009 at 2:15 PM, Vinicius Carvalho <
> >> vinicius@caravelatech.com> wrote:
> >>
> >>> Well, I'm still trying here to get it working. As for using Sling,
> well,
> >>> if we could use just the launcher that would be one ideia, but we
> really
> >>> would not like to have the whole sling application just to use
> web-console.
> >>> Although we will need a JCR repository in our app, I don't think we
> should
> >>> have sling embedded .
> >>>
> >>> Regards
> >>>
> >>> On Tue, Jan 20, 2009 at 1:44 PM, Carsten Ziegeler <
> cziegeler@apache.org>wrote:
> >>>
> >>>> Vinicius Carvalho wrote:
> >>>> > Well, The Activator is receiving the System bundlecontext where the
> >>>> > webconsole gets its own bundlecontext. When we register a service
> >>>> tracker it
> >>>> > tracks services only for the specific bundle? could this be the
> >>>> problem?
> >>>> >
> >>>> This is correct, the service tracker tracks all services regardless
> from
> >>>> which bundle
> >>>> they're comming.
> >>>>
> >>>> I've no idea what goes wrong in your case, but why are you not just
> >>>> using the Sling Webapp? I has nearly no overhead and provides you with
> a
> >>>> usuable setup. Or you can use the standalone jar from Sling.
> >>>>
> >>>> Carsten
> >>>>
> >>>>
> >>>> --
> >>>> Carsten Ziegeler
> >>>> cziegeler@apache.org
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >>>> For additional commands, e-mail: users-help@felix.apache.org
> >>>>
> >>>>
> >>>
> >>
> >
>
>
>
> --
> Karl Pauls
> karlpauls@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Web console

Posted by Karl Pauls <ka...@gmail.com>.
Well, can you make your project available someplace so that we can
have a look at what is going wrong exactly?

regards,

Karl

On Wed, Jan 21, 2009 at 8:10 PM, Vinicius Carvalho
<vi...@caravelatech.com> wrote:
> Hello there! We are almost giving up on OSGi since we can not find how to
> get the webconsole running. It's a real pain to get it working inside a
> servlet container. We've debugged the entire sling app and it works as a
> charm (although it uses older versions of all libs). I really can't imagine
> why after my HttpServiceServlet gets started and register itsefl as and
> HTTPService service in the context the ServiceTracker of the webconsole is
> not triggered.
>
> We tried to replace equinox httpservice by pax-web, and the Tracker this
> time gets notified but, we could not access the console since there's no
> servlet to delegate the service. We are still checking this, I wish I could
> use the embedded version of containers like tomcat and jetty, the way spring
> DM does, or even use spring dm server, but unfortunatelly we need to be able
> to deploy on any container, and this is my last week, if that does not work,
> we might drop OSGi and use another approach to build our modules.
>
> Anyone got another idea that could help us?
>
> Regards
>
> On Tue, Jan 20, 2009 at 3:47 PM, Vinicius Carvalho <
> vinicius@caravelatech.com> wrote:
>
>> Well, Sling uses Felix 1.0.4 right? I'm running my tests with 1.4.1 and
>> also I have a newer version of the equinox. After running sling on debug
>> mode here I found that the source I have for the equinox server api is not
>> the same. I wonder if this is the problem. One difference I have is the
>> props.put(EMBEDDED_EXECUTION_PROP, "true"); since it seems that it does not
>> exist anymore.
>>
>>
>> On Tue, Jan 20, 2009 at 2:15 PM, Vinicius Carvalho <
>> vinicius@caravelatech.com> wrote:
>>
>>> Well, I'm still trying here to get it working. As for using Sling, well,
>>> if we could use just the launcher that would be one ideia, but we really
>>> would not like to have the whole sling application just to use web-console.
>>> Although we will need a JCR repository in our app, I don't think we should
>>> have sling embedded .
>>>
>>> Regards
>>>
>>> On Tue, Jan 20, 2009 at 1:44 PM, Carsten Ziegeler <cz...@apache.org>wrote:
>>>
>>>> Vinicius Carvalho wrote:
>>>> > Well, The Activator is receiving the System bundlecontext where the
>>>> > webconsole gets its own bundlecontext. When we register a service
>>>> tracker it
>>>> > tracks services only for the specific bundle? could this be the
>>>> problem?
>>>> >
>>>> This is correct, the service tracker tracks all services regardless from
>>>> which bundle
>>>> they're comming.
>>>>
>>>> I've no idea what goes wrong in your case, but why are you not just
>>>> using the Sling Webapp? I has nearly no overhead and provides you with a
>>>> usuable setup. Or you can use the standalone jar from Sling.
>>>>
>>>> Carsten
>>>>
>>>>
>>>> --
>>>> Carsten Ziegeler
>>>> cziegeler@apache.org
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>>>
>>>
>>
>



-- 
Karl Pauls
karlpauls@gmail.com

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


Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Hello there! We are almost giving up on OSGi since we can not find how to
get the webconsole running. It's a real pain to get it working inside a
servlet container. We've debugged the entire sling app and it works as a
charm (although it uses older versions of all libs). I really can't imagine
why after my HttpServiceServlet gets started and register itsefl as and
HTTPService service in the context the ServiceTracker of the webconsole is
not triggered.

We tried to replace equinox httpservice by pax-web, and the Tracker this
time gets notified but, we could not access the console since there's no
servlet to delegate the service. We are still checking this, I wish I could
use the embedded version of containers like tomcat and jetty, the way spring
DM does, or even use spring dm server, but unfortunatelly we need to be able
to deploy on any container, and this is my last week, if that does not work,
we might drop OSGi and use another approach to build our modules.

Anyone got another idea that could help us?

Regards

On Tue, Jan 20, 2009 at 3:47 PM, Vinicius Carvalho <
vinicius@caravelatech.com> wrote:

> Well, Sling uses Felix 1.0.4 right? I'm running my tests with 1.4.1 and
> also I have a newer version of the equinox. After running sling on debug
> mode here I found that the source I have for the equinox server api is not
> the same. I wonder if this is the problem. One difference I have is the
> props.put(EMBEDDED_EXECUTION_PROP, "true"); since it seems that it does not
> exist anymore.
>
>
> On Tue, Jan 20, 2009 at 2:15 PM, Vinicius Carvalho <
> vinicius@caravelatech.com> wrote:
>
>> Well, I'm still trying here to get it working. As for using Sling, well,
>> if we could use just the launcher that would be one ideia, but we really
>> would not like to have the whole sling application just to use web-console.
>> Although we will need a JCR repository in our app, I don't think we should
>> have sling embedded .
>>
>> Regards
>>
>> On Tue, Jan 20, 2009 at 1:44 PM, Carsten Ziegeler <cz...@apache.org>wrote:
>>
>>> Vinicius Carvalho wrote:
>>> > Well, The Activator is receiving the System bundlecontext where the
>>> > webconsole gets its own bundlecontext. When we register a service
>>> tracker it
>>> > tracks services only for the specific bundle? could this be the
>>> problem?
>>> >
>>> This is correct, the service tracker tracks all services regardless from
>>> which bundle
>>> they're comming.
>>>
>>> I've no idea what goes wrong in your case, but why are you not just
>>> using the Sling Webapp? I has nearly no overhead and provides you with a
>>> usuable setup. Or you can use the standalone jar from Sling.
>>>
>>> Carsten
>>>
>>>
>>> --
>>> Carsten Ziegeler
>>> cziegeler@apache.org
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>
>

Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well, Sling uses Felix 1.0.4 right? I'm running my tests with 1.4.1 and also
I have a newer version of the equinox. After running sling on debug mode
here I found that the source I have for the equinox server api is not the
same. I wonder if this is the problem. One difference I have is the
props.put(EMBEDDED_EXECUTION_PROP, "true"); since it seems that it does not
exist anymore.

On Tue, Jan 20, 2009 at 2:15 PM, Vinicius Carvalho <
vinicius@caravelatech.com> wrote:

> Well, I'm still trying here to get it working. As for using Sling, well, if
> we could use just the launcher that would be one ideia, but we really would
> not like to have the whole sling application just to use web-console.
> Although we will need a JCR repository in our app, I don't think we should
> have sling embedded .
>
> Regards
>
> On Tue, Jan 20, 2009 at 1:44 PM, Carsten Ziegeler <cz...@apache.org>wrote:
>
>> Vinicius Carvalho wrote:
>> > Well, The Activator is receiving the System bundlecontext where the
>> > webconsole gets its own bundlecontext. When we register a service
>> tracker it
>> > tracks services only for the specific bundle? could this be the problem?
>> >
>> This is correct, the service tracker tracks all services regardless from
>> which bundle
>> they're comming.
>>
>> I've no idea what goes wrong in your case, but why are you not just
>> using the Sling Webapp? I has nearly no overhead and provides you with a
>> usuable setup. Or you can use the standalone jar from Sling.
>>
>> Carsten
>>
>>
>> --
>> Carsten Ziegeler
>> cziegeler@apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>

Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well, I'm still trying here to get it working. As for using Sling, well, if
we could use just the launcher that would be one ideia, but we really would
not like to have the whole sling application just to use web-console.
Although we will need a JCR repository in our app, I don't think we should
have sling embedded .

Regards

On Tue, Jan 20, 2009 at 1:44 PM, Carsten Ziegeler <cz...@apache.org>wrote:

> Vinicius Carvalho wrote:
> > Well, The Activator is receiving the System bundlecontext where the
> > webconsole gets its own bundlecontext. When we register a service tracker
> it
> > tracks services only for the specific bundle? could this be the problem?
> >
> This is correct, the service tracker tracks all services regardless from
> which bundle
> they're comming.
>
> I've no idea what goes wrong in your case, but why are you not just
> using the Sling Webapp? I has nearly no overhead and provides you with a
> usuable setup. Or you can use the standalone jar from Sling.
>
> Carsten
>
>
> --
> Carsten Ziegeler
> cziegeler@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Web console

Posted by Carsten Ziegeler <cz...@apache.org>.
Vinicius Carvalho wrote:
> Well, The Activator is receiving the System bundlecontext where the
> webconsole gets its own bundlecontext. When we register a service tracker it
> tracks services only for the specific bundle? could this be the problem?
> 
This is correct, the service tracker tracks all services regardless from
which bundle
they're comming.

I've no idea what goes wrong in your case, but why are you not just
using the Sling Webapp? I has nearly no overhead and provides you with a
usuable setup. Or you can use the standalone jar from Sling.

Carsten


-- 
Carsten Ziegeler
cziegeler@apache.org

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


Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well, The Activator is receiving the System bundlecontext where the
webconsole gets its own bundlecontext. When we register a service tracker it
tracks services only for the specific bundle? could this be the problem?

On Tue, Jan 20, 2009 at 10:39 AM, Vinicius Carvalho <
vinicius@caravelatech.com> wrote:

> Ok, they have different class loaders :(
>
> The Activator has a ContentClassLoader
> and the HTTPService the WebAppClassLoader
>
> But, I'm still lost on how to solve this :(
>
>
> On Tue, Jan 20, 2009 at 10:33 AM, Vinicius Carvalho <
> vinicius@caravelatech.com> wrote:
>
>> Well digging a little bit more, I found this:
>>
>> I'm putting the equinox servlet as a bundle: so the class:
>>
>> org.eclipse.equinox.http.servlet.internal.Activator gets started:
>> public void start(BundleContext context) throws Exception {
>>         startHttpServiceProxy(context);
>>     }
>> private static synchronized void startHttpServiceProxy(BundleContext
>> bundleContext) {
>>         context = bundleContext;
>>         Object[] proxyServlets = serviceRegistrations.keySet().toArray();
>>         for (int i = 0; i < proxyServlets.length; ++i) {
>>             ServiceRegistration registration =
>> registerHttpService((ProxyServlet) proxyServlets[i]);
>>             serviceRegistrations.put(proxyServlets[i], registration);
>>         }
>>     }
>>
>> Well it assigns the bundlecontext to its internal variable, so far so
>> good. Problem is when I create the HTTPProxyServlet:
>>
>>         this.delegatee = new HttpServiceServlet();
>>         this.delegatee.init(getServletConfig());
>>
>> And it gets initiated:
>>
>> public void init(ServletConfig config) throws ServletException {
>>         super.init(config);
>>         proxyContext = new ProxyContext(config.getServletContext());
>>         Activator.addProxyServlet(this);
>>     }
>>
>> The Activator is called in a static way, the addProxyServlet methods
>> checks for a bundlecontext which is null :(, so it never calls the
>> registerHttpService, which in turns never triggers the Tracker from the
>> webconsole.
>>
>> Anyone got a solution for this please?
>>
>> Regards
>>
>>
>>
>>
>> On Mon, Jan 19, 2009 at 6:48 PM, Vinicius Carvalho <
>> vinicius@caravelatech.com> wrote:
>>
>>> Well, I fixed the project a bit, removed the servlet-api and add a
>>> property org.osgi.framework.system.packages.extra = javax.servlet,
>>> javax.servlet.http to Felix startup properties.
>>>
>>> But still no success. So I decided to go to the source code.
>>>
>>> Well, it seems that the webconsole service tracker HttpServiceTracker
>>> never gets its addingService method called. So it does not bind itself.
>>>
>>> One thing I found my self lost (again) is that the Sling implementation
>>> starts an HttpService, what about the HttpServiceImpl which register the
>>> proxy servlet? Isn't this one the one to be instantiated?
>>>
>>> Regards
>>>
>>>
>>> On Fri, Jan 16, 2009 at 4:53 PM, Felix Meschberger <fm...@gmail.com>wrote:
>>>
>>>> Hi Vinicius,
>>>>
>>>> Vinicius Carvalho schrieb:
>>>> > Well, still can't get it to work :(
>>>>
>>>> To bad ...
>>>>
>>>> >
>>>> > Here's my web structure:
>>>> >
>>>> > web-inf/
>>>> >   -web.xml
>>>> >   -lib/
>>>> >     org.apache.felix.framework-1.4.1.jar
>>>> >     org.eclipse.osgi.services.jar
>>>> >     org.osgi.compendium.jar
>>>> >     org.osgi.core.jar
>>>> >     org.osgi.foundation.jar
>>>> >     org.eclipse.equinox.servlet-1.0.1.jar
>>>> >    -resources/
>>>> >     -bundles/
>>>> >        org.apache.felix.configadmin.jar
>>>> >        org.apache.felix.metatype.jar
>>>> >        org.apache.felix.webconsole.jar
>>>> >        org.eclipse.osgi.services.jar
>>>> >    -corebundles/
>>>> >        servlet-api.osg1-2.5.jar
>>>>
>>>> Notes: servlet-api is not required in a servlet container environment,
>>>> since this api is provided by the container and should be injected
>>>> through the system bundle. The osgi.services jar should probably not be
>>>> place in the lib and the bundles folder, one location should do it.
>>>>
>>>> I suggest to add an OSGi LogService implementation bundle, such that you
>>>> get logging of OSGi events as well as the web console itself (and
>>>> others).
>>>>
>>>> From the classes below, I can unfortunately not tell you exactly, why
>>>> this does not work.
>>>>
>>>> If you could send me your web application directly (off-list), I could
>>>> try to find out, what exactly is going on here.
>>>>
>>>> Regards
>>>> Felix
>>>>
>>>> >
>>>> >
>>>> > Well, here's the serlvet that boots the system (got it from sling)
>>>> >
>>>> > package org.openspotlight.core.loader;
>>>> >
>>>> > import java.io.IOException;
>>>> > import java.net.MalformedURLException;
>>>> > import java.net.URL;
>>>> > import java.util.Collections;
>>>> > import java.util.HashMap;
>>>> > import java.util.Iterator;
>>>> > import java.util.Map;
>>>> > import java.util.Set;
>>>> >
>>>> > import javax.servlet.GenericServlet;
>>>> > import javax.servlet.Servlet;
>>>> > import javax.servlet.ServletContext;
>>>> > import javax.servlet.ServletException;
>>>> > import javax.servlet.ServletRequest;
>>>> > import javax.servlet.ServletResponse;
>>>> > import javax.servlet.http.HttpServletResponse;
>>>> >
>>>> > import org.apache.felix.framework.Logger;
>>>> > import org.eclipse.equinox.http.servlet.HttpServiceServlet;
>>>> > import org.osgi.framework.BundleException;
>>>> > import org.osgi.framework.ServiceReference;
>>>> >
>>>> > public class OSLServlet extends GenericServlet {
>>>> >
>>>> >     private OSL osl;
>>>> >     private Servlet delegatee;
>>>> >
>>>> >     @Override
>>>> >     public void service(ServletRequest req, ServletResponse res)
>>>> >             throws ServletException, IOException {
>>>> >          Servlet delegatee = getDelegatee();
>>>> >             if (delegatee == null) {
>>>> >                 ((HttpServletResponse)
>>>> > res).sendError(HttpServletResponse.SC_NOT_FOUND);
>>>> >             } else {
>>>> >                 delegatee.service(req, res);
>>>> >             }
>>>> >     }
>>>> >     @Override
>>>> >     public void init() throws ServletException {
>>>> >         ServletContextResourceProvider rp = new
>>>> > ServletContextResourceProvider(getServletContext());
>>>> >         Logger logger = new ServletContextLogger(getServletContext());
>>>> >         Map<String, String> props = new HashMap<String, String>();
>>>> >         this.osl = new OSL(rp,props,logger);
>>>> >         this.delegatee = new HttpServiceServlet();
>>>> >         this.delegatee.init(getServletConfig());
>>>> >         super.init();
>>>> >     }
>>>> >
>>>> >
>>>> >     @Override
>>>> >     public void destroy() {
>>>> >         if(this.delegatee != null){
>>>> >             this.delegatee.destroy();
>>>> >             this.delegatee = null;
>>>> >         }
>>>> >
>>>> >         if(this.osl != null){
>>>> >             osl.destroy();
>>>> >             this.osl = null;
>>>> >         }
>>>> >         super.destroy();
>>>> >     }
>>>> >
>>>> >     public Servlet getDelegatee(){
>>>> >         return this.delegatee;
>>>> >     }
>>>> >
>>>> >
>>>> >
>>>> > }
>>>> >
>>>> >
>>>> > Here's the bridge (OSL) also got from Sling:
>>>> >
>>>> > package org.openspotlight.core.loader;
>>>> >
>>>> > import java.util.ArrayList;
>>>> > import java.util.HashMap;
>>>> > import java.util.List;
>>>> > import java.util.Map;
>>>> > import java.util.concurrent.locks.ReadWriteLock;
>>>> >
>>>> > import org.apache.felix.framework.Felix;
>>>> > import org.apache.felix.framework.Logger;
>>>> > import org.apache.felix.framework.util.FelixConstants;
>>>> > import org.eclipse.equinox.http.servlet.internal.Activator;
>>>> > import org.osgi.framework.BundleActivator;
>>>> > import org.osgi.framework.BundleContext;
>>>> > import org.osgi.framework.BundleException;
>>>> >
>>>> > public class OSL implements BundleActivator {
>>>> >
>>>> >     private Felix felix;
>>>> >     private ReadWriteLock felixLock;
>>>> >     private ResourceProvider resourceProvider;
>>>> >     private Logger logger;
>>>> >     private BundleActivator httpServiceActivator;
>>>> >
>>>> >     public OSL(ResourceProvider rp, Map<String, String> props, Logger
>>>> > logger){
>>>> >         this.resourceProvider = rp;
>>>> >         this.logger = logger;
>>>> >         List<BundleActivator> activators = new
>>>> ArrayList<BundleActivator>();
>>>> >         activators.add(this);
>>>> >         activators.add(new BootstrapInstaller(logger,rp));
>>>> >         Map configMap = new HashMap();
>>>> >         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>>>> > activators);
>>>> >         felix = new Felix(configMap);
>>>> >         try {
>>>> >             felix.start();
>>>> >         } catch (Exception e) {
>>>> >             e.printStackTrace();
>>>> >         }
>>>> >     }
>>>> >
>>>> >     public void start(BundleContext context) throws Exception {
>>>> >         this.httpServiceActivator = new Activator();
>>>> >         this.httpServiceActivator.start(context);
>>>> >
>>>> >     }
>>>> >
>>>> >     public void stop(BundleContext context) throws Exception {
>>>> >         try {
>>>> >             this.httpServiceActivator.stop(context);
>>>> >         } catch (Exception e) {
>>>> >             e.printStackTrace();
>>>> >         }
>>>> >         this.httpServiceActivator = null;
>>>> >     }
>>>> >
>>>> >     public void destroy(){
>>>> >         if (felix != null) {
>>>> >             logger.log(Logger.LOG_INFO, "Shutting down OSL");
>>>> >             try {
>>>> >                 felix.stop();
>>>> >             } catch (BundleException e) {
>>>> >                 // TODO Auto-generated catch block
>>>> >                 e.printStackTrace();
>>>> >             }
>>>> >             logger.log(Logger.LOG_INFO, "Sling stopped");
>>>> >             felix = null;
>>>> >         }
>>>> >     }
>>>> >
>>>> > }
>>>> >
>>>> >
>>>> > Well, I get this messages at console when starting up:
>>>> >
>>>> > 16:14:17,887 ERROR [STDERR] *DEBUG* Scheduling task ManagedService
>>>> Update:
>>>> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
>>>> > 16:14:17,888 ERROR [STDERR] *DEBUG* Running task ManagedService
>>>> Update:
>>>> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
>>>> >
>>>> > But when I access: localhost:8080/osl/system/console It does not find
>>>> the
>>>> > service. Looking at the ServletProxy source I found that there was no
>>>> > registrations in the class.
>>>> >
>>>> > Also, the first time I start the framework (after cleaning the cache
>>>> dir) I
>>>> > only find the system bundle. If I redeploy the war, it finds all the
>>>> bundles
>>>> > on the second time.
>>>> >
>>>> > Any ideas?
>>>> >
>>>> > Regards
>>>> >
>>>> >
>>>> > On Fri, Jan 16, 2009 at 11:33 AM, Carsten Ziegeler <
>>>> cziegeler@apache.org>wrote:
>>>> >
>>>> >> Vinicius Carvalho wrote:
>>>> >>> Thanks Felix that really helped, just a couple of more questions :)
>>>> >>>
>>>> >>> 1- Do I need to launch the container from a servlet (I was doing
>>>> from a
>>>> >>> Listener)
>>>> >>> 2- So, this servlet must be mapped to /* url, just like the Sling
>>>> does?
>>>> >>>
>>>> >> You can map the servlet to any path, like /myosgi - the web console
>>>> is
>>>> >> then by default reachable at /myosgi/system/console.
>>>> >>
>>>> >> HTH
>>>> >> Carsten
>>>> >> --
>>>> >> Carsten Ziegeler
>>>> >> cziegeler@apache.org
>>>> >>
>>>> >> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> >> For additional commands, e-mail: users-help@felix.apache.org
>>>> >>
>>>> >>
>>>> >
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>>>
>>>
>>
>

Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Ok, they have different class loaders :(

The Activator has a ContentClassLoader
and the HTTPService the WebAppClassLoader

But, I'm still lost on how to solve this :(

On Tue, Jan 20, 2009 at 10:33 AM, Vinicius Carvalho <
vinicius@caravelatech.com> wrote:

> Well digging a little bit more, I found this:
>
> I'm putting the equinox servlet as a bundle: so the class:
>
> org.eclipse.equinox.http.servlet.internal.Activator gets started:
> public void start(BundleContext context) throws Exception {
>         startHttpServiceProxy(context);
>     }
> private static synchronized void startHttpServiceProxy(BundleContext
> bundleContext) {
>         context = bundleContext;
>         Object[] proxyServlets = serviceRegistrations.keySet().toArray();
>         for (int i = 0; i < proxyServlets.length; ++i) {
>             ServiceRegistration registration =
> registerHttpService((ProxyServlet) proxyServlets[i]);
>             serviceRegistrations.put(proxyServlets[i], registration);
>         }
>     }
>
> Well it assigns the bundlecontext to its internal variable, so far so good.
> Problem is when I create the HTTPProxyServlet:
>
>         this.delegatee = new HttpServiceServlet();
>         this.delegatee.init(getServletConfig());
>
> And it gets initiated:
>
> public void init(ServletConfig config) throws ServletException {
>         super.init(config);
>         proxyContext = new ProxyContext(config.getServletContext());
>         Activator.addProxyServlet(this);
>     }
>
> The Activator is called in a static way, the addProxyServlet methods checks
> for a bundlecontext which is null :(, so it never calls the
> registerHttpService, which in turns never triggers the Tracker from the
> webconsole.
>
> Anyone got a solution for this please?
>
> Regards
>
>
>
>
> On Mon, Jan 19, 2009 at 6:48 PM, Vinicius Carvalho <
> vinicius@caravelatech.com> wrote:
>
>> Well, I fixed the project a bit, removed the servlet-api and add a
>> property org.osgi.framework.system.packages.extra = javax.servlet,
>> javax.servlet.http to Felix startup properties.
>>
>> But still no success. So I decided to go to the source code.
>>
>> Well, it seems that the webconsole service tracker HttpServiceTracker
>> never gets its addingService method called. So it does not bind itself.
>>
>> One thing I found my self lost (again) is that the Sling implementation
>> starts an HttpService, what about the HttpServiceImpl which register the
>> proxy servlet? Isn't this one the one to be instantiated?
>>
>> Regards
>>
>>
>> On Fri, Jan 16, 2009 at 4:53 PM, Felix Meschberger <fm...@gmail.com>wrote:
>>
>>> Hi Vinicius,
>>>
>>> Vinicius Carvalho schrieb:
>>> > Well, still can't get it to work :(
>>>
>>> To bad ...
>>>
>>> >
>>> > Here's my web structure:
>>> >
>>> > web-inf/
>>> >   -web.xml
>>> >   -lib/
>>> >     org.apache.felix.framework-1.4.1.jar
>>> >     org.eclipse.osgi.services.jar
>>> >     org.osgi.compendium.jar
>>> >     org.osgi.core.jar
>>> >     org.osgi.foundation.jar
>>> >     org.eclipse.equinox.servlet-1.0.1.jar
>>> >    -resources/
>>> >     -bundles/
>>> >        org.apache.felix.configadmin.jar
>>> >        org.apache.felix.metatype.jar
>>> >        org.apache.felix.webconsole.jar
>>> >        org.eclipse.osgi.services.jar
>>> >    -corebundles/
>>> >        servlet-api.osg1-2.5.jar
>>>
>>> Notes: servlet-api is not required in a servlet container environment,
>>> since this api is provided by the container and should be injected
>>> through the system bundle. The osgi.services jar should probably not be
>>> place in the lib and the bundles folder, one location should do it.
>>>
>>> I suggest to add an OSGi LogService implementation bundle, such that you
>>> get logging of OSGi events as well as the web console itself (and
>>> others).
>>>
>>> From the classes below, I can unfortunately not tell you exactly, why
>>> this does not work.
>>>
>>> If you could send me your web application directly (off-list), I could
>>> try to find out, what exactly is going on here.
>>>
>>> Regards
>>> Felix
>>>
>>> >
>>> >
>>> > Well, here's the serlvet that boots the system (got it from sling)
>>> >
>>> > package org.openspotlight.core.loader;
>>> >
>>> > import java.io.IOException;
>>> > import java.net.MalformedURLException;
>>> > import java.net.URL;
>>> > import java.util.Collections;
>>> > import java.util.HashMap;
>>> > import java.util.Iterator;
>>> > import java.util.Map;
>>> > import java.util.Set;
>>> >
>>> > import javax.servlet.GenericServlet;
>>> > import javax.servlet.Servlet;
>>> > import javax.servlet.ServletContext;
>>> > import javax.servlet.ServletException;
>>> > import javax.servlet.ServletRequest;
>>> > import javax.servlet.ServletResponse;
>>> > import javax.servlet.http.HttpServletResponse;
>>> >
>>> > import org.apache.felix.framework.Logger;
>>> > import org.eclipse.equinox.http.servlet.HttpServiceServlet;
>>> > import org.osgi.framework.BundleException;
>>> > import org.osgi.framework.ServiceReference;
>>> >
>>> > public class OSLServlet extends GenericServlet {
>>> >
>>> >     private OSL osl;
>>> >     private Servlet delegatee;
>>> >
>>> >     @Override
>>> >     public void service(ServletRequest req, ServletResponse res)
>>> >             throws ServletException, IOException {
>>> >          Servlet delegatee = getDelegatee();
>>> >             if (delegatee == null) {
>>> >                 ((HttpServletResponse)
>>> > res).sendError(HttpServletResponse.SC_NOT_FOUND);
>>> >             } else {
>>> >                 delegatee.service(req, res);
>>> >             }
>>> >     }
>>> >     @Override
>>> >     public void init() throws ServletException {
>>> >         ServletContextResourceProvider rp = new
>>> > ServletContextResourceProvider(getServletContext());
>>> >         Logger logger = new ServletContextLogger(getServletContext());
>>> >         Map<String, String> props = new HashMap<String, String>();
>>> >         this.osl = new OSL(rp,props,logger);
>>> >         this.delegatee = new HttpServiceServlet();
>>> >         this.delegatee.init(getServletConfig());
>>> >         super.init();
>>> >     }
>>> >
>>> >
>>> >     @Override
>>> >     public void destroy() {
>>> >         if(this.delegatee != null){
>>> >             this.delegatee.destroy();
>>> >             this.delegatee = null;
>>> >         }
>>> >
>>> >         if(this.osl != null){
>>> >             osl.destroy();
>>> >             this.osl = null;
>>> >         }
>>> >         super.destroy();
>>> >     }
>>> >
>>> >     public Servlet getDelegatee(){
>>> >         return this.delegatee;
>>> >     }
>>> >
>>> >
>>> >
>>> > }
>>> >
>>> >
>>> > Here's the bridge (OSL) also got from Sling:
>>> >
>>> > package org.openspotlight.core.loader;
>>> >
>>> > import java.util.ArrayList;
>>> > import java.util.HashMap;
>>> > import java.util.List;
>>> > import java.util.Map;
>>> > import java.util.concurrent.locks.ReadWriteLock;
>>> >
>>> > import org.apache.felix.framework.Felix;
>>> > import org.apache.felix.framework.Logger;
>>> > import org.apache.felix.framework.util.FelixConstants;
>>> > import org.eclipse.equinox.http.servlet.internal.Activator;
>>> > import org.osgi.framework.BundleActivator;
>>> > import org.osgi.framework.BundleContext;
>>> > import org.osgi.framework.BundleException;
>>> >
>>> > public class OSL implements BundleActivator {
>>> >
>>> >     private Felix felix;
>>> >     private ReadWriteLock felixLock;
>>> >     private ResourceProvider resourceProvider;
>>> >     private Logger logger;
>>> >     private BundleActivator httpServiceActivator;
>>> >
>>> >     public OSL(ResourceProvider rp, Map<String, String> props, Logger
>>> > logger){
>>> >         this.resourceProvider = rp;
>>> >         this.logger = logger;
>>> >         List<BundleActivator> activators = new
>>> ArrayList<BundleActivator>();
>>> >         activators.add(this);
>>> >         activators.add(new BootstrapInstaller(logger,rp));
>>> >         Map configMap = new HashMap();
>>> >         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>>> > activators);
>>> >         felix = new Felix(configMap);
>>> >         try {
>>> >             felix.start();
>>> >         } catch (Exception e) {
>>> >             e.printStackTrace();
>>> >         }
>>> >     }
>>> >
>>> >     public void start(BundleContext context) throws Exception {
>>> >         this.httpServiceActivator = new Activator();
>>> >         this.httpServiceActivator.start(context);
>>> >
>>> >     }
>>> >
>>> >     public void stop(BundleContext context) throws Exception {
>>> >         try {
>>> >             this.httpServiceActivator.stop(context);
>>> >         } catch (Exception e) {
>>> >             e.printStackTrace();
>>> >         }
>>> >         this.httpServiceActivator = null;
>>> >     }
>>> >
>>> >     public void destroy(){
>>> >         if (felix != null) {
>>> >             logger.log(Logger.LOG_INFO, "Shutting down OSL");
>>> >             try {
>>> >                 felix.stop();
>>> >             } catch (BundleException e) {
>>> >                 // TODO Auto-generated catch block
>>> >                 e.printStackTrace();
>>> >             }
>>> >             logger.log(Logger.LOG_INFO, "Sling stopped");
>>> >             felix = null;
>>> >         }
>>> >     }
>>> >
>>> > }
>>> >
>>> >
>>> > Well, I get this messages at console when starting up:
>>> >
>>> > 16:14:17,887 ERROR [STDERR] *DEBUG* Scheduling task ManagedService
>>> Update:
>>> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
>>> > 16:14:17,888 ERROR [STDERR] *DEBUG* Running task ManagedService Update:
>>> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
>>> >
>>> > But when I access: localhost:8080/osl/system/console It does not find
>>> the
>>> > service. Looking at the ServletProxy source I found that there was no
>>> > registrations in the class.
>>> >
>>> > Also, the first time I start the framework (after cleaning the cache
>>> dir) I
>>> > only find the system bundle. If I redeploy the war, it finds all the
>>> bundles
>>> > on the second time.
>>> >
>>> > Any ideas?
>>> >
>>> > Regards
>>> >
>>> >
>>> > On Fri, Jan 16, 2009 at 11:33 AM, Carsten Ziegeler <
>>> cziegeler@apache.org>wrote:
>>> >
>>> >> Vinicius Carvalho wrote:
>>> >>> Thanks Felix that really helped, just a couple of more questions :)
>>> >>>
>>> >>> 1- Do I need to launch the container from a servlet (I was doing from
>>> a
>>> >>> Listener)
>>> >>> 2- So, this servlet must be mapped to /* url, just like the Sling
>>> does?
>>> >>>
>>> >> You can map the servlet to any path, like /myosgi - the web console is
>>> >> then by default reachable at /myosgi/system/console.
>>> >>
>>> >> HTH
>>> >> Carsten
>>> >> --
>>> >> Carsten Ziegeler
>>> >> cziegeler@apache.org
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> >> For additional commands, e-mail: users-help@felix.apache.org
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>
>

Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well digging a little bit more, I found this:

I'm putting the equinox servlet as a bundle: so the class:

org.eclipse.equinox.http.servlet.internal.Activator gets started:
public void start(BundleContext context) throws Exception {
        startHttpServiceProxy(context);
    }
private static synchronized void startHttpServiceProxy(BundleContext
bundleContext) {
        context = bundleContext;
        Object[] proxyServlets = serviceRegistrations.keySet().toArray();
        for (int i = 0; i < proxyServlets.length; ++i) {
            ServiceRegistration registration =
registerHttpService((ProxyServlet) proxyServlets[i]);
            serviceRegistrations.put(proxyServlets[i], registration);
        }
    }

Well it assigns the bundlecontext to its internal variable, so far so good.
Problem is when I create the HTTPProxyServlet:

        this.delegatee = new HttpServiceServlet();
        this.delegatee.init(getServletConfig());

And it gets initiated:

public void init(ServletConfig config) throws ServletException {
        super.init(config);
        proxyContext = new ProxyContext(config.getServletContext());
        Activator.addProxyServlet(this);
    }

The Activator is called in a static way, the addProxyServlet methods checks
for a bundlecontext which is null :(, so it never calls the
registerHttpService, which in turns never triggers the Tracker from the
webconsole.

Anyone got a solution for this please?

Regards



On Mon, Jan 19, 2009 at 6:48 PM, Vinicius Carvalho <
vinicius@caravelatech.com> wrote:

> Well, I fixed the project a bit, removed the servlet-api and add a property
> org.osgi.framework.system.packages.extra = javax.servlet, javax.servlet.http
> to Felix startup properties.
>
> But still no success. So I decided to go to the source code.
>
> Well, it seems that the webconsole service tracker HttpServiceTracker never
> gets its addingService method called. So it does not bind itself.
>
> One thing I found my self lost (again) is that the Sling implementation
> starts an HttpService, what about the HttpServiceImpl which register the
> proxy servlet? Isn't this one the one to be instantiated?
>
> Regards
>
>
> On Fri, Jan 16, 2009 at 4:53 PM, Felix Meschberger <fm...@gmail.com>wrote:
>
>> Hi Vinicius,
>>
>> Vinicius Carvalho schrieb:
>> > Well, still can't get it to work :(
>>
>> To bad ...
>>
>> >
>> > Here's my web structure:
>> >
>> > web-inf/
>> >   -web.xml
>> >   -lib/
>> >     org.apache.felix.framework-1.4.1.jar
>> >     org.eclipse.osgi.services.jar
>> >     org.osgi.compendium.jar
>> >     org.osgi.core.jar
>> >     org.osgi.foundation.jar
>> >     org.eclipse.equinox.servlet-1.0.1.jar
>> >    -resources/
>> >     -bundles/
>> >        org.apache.felix.configadmin.jar
>> >        org.apache.felix.metatype.jar
>> >        org.apache.felix.webconsole.jar
>> >        org.eclipse.osgi.services.jar
>> >    -corebundles/
>> >        servlet-api.osg1-2.5.jar
>>
>> Notes: servlet-api is not required in a servlet container environment,
>> since this api is provided by the container and should be injected
>> through the system bundle. The osgi.services jar should probably not be
>> place in the lib and the bundles folder, one location should do it.
>>
>> I suggest to add an OSGi LogService implementation bundle, such that you
>> get logging of OSGi events as well as the web console itself (and others).
>>
>> From the classes below, I can unfortunately not tell you exactly, why
>> this does not work.
>>
>> If you could send me your web application directly (off-list), I could
>> try to find out, what exactly is going on here.
>>
>> Regards
>> Felix
>>
>> >
>> >
>> > Well, here's the serlvet that boots the system (got it from sling)
>> >
>> > package org.openspotlight.core.loader;
>> >
>> > import java.io.IOException;
>> > import java.net.MalformedURLException;
>> > import java.net.URL;
>> > import java.util.Collections;
>> > import java.util.HashMap;
>> > import java.util.Iterator;
>> > import java.util.Map;
>> > import java.util.Set;
>> >
>> > import javax.servlet.GenericServlet;
>> > import javax.servlet.Servlet;
>> > import javax.servlet.ServletContext;
>> > import javax.servlet.ServletException;
>> > import javax.servlet.ServletRequest;
>> > import javax.servlet.ServletResponse;
>> > import javax.servlet.http.HttpServletResponse;
>> >
>> > import org.apache.felix.framework.Logger;
>> > import org.eclipse.equinox.http.servlet.HttpServiceServlet;
>> > import org.osgi.framework.BundleException;
>> > import org.osgi.framework.ServiceReference;
>> >
>> > public class OSLServlet extends GenericServlet {
>> >
>> >     private OSL osl;
>> >     private Servlet delegatee;
>> >
>> >     @Override
>> >     public void service(ServletRequest req, ServletResponse res)
>> >             throws ServletException, IOException {
>> >          Servlet delegatee = getDelegatee();
>> >             if (delegatee == null) {
>> >                 ((HttpServletResponse)
>> > res).sendError(HttpServletResponse.SC_NOT_FOUND);
>> >             } else {
>> >                 delegatee.service(req, res);
>> >             }
>> >     }
>> >     @Override
>> >     public void init() throws ServletException {
>> >         ServletContextResourceProvider rp = new
>> > ServletContextResourceProvider(getServletContext());
>> >         Logger logger = new ServletContextLogger(getServletContext());
>> >         Map<String, String> props = new HashMap<String, String>();
>> >         this.osl = new OSL(rp,props,logger);
>> >         this.delegatee = new HttpServiceServlet();
>> >         this.delegatee.init(getServletConfig());
>> >         super.init();
>> >     }
>> >
>> >
>> >     @Override
>> >     public void destroy() {
>> >         if(this.delegatee != null){
>> >             this.delegatee.destroy();
>> >             this.delegatee = null;
>> >         }
>> >
>> >         if(this.osl != null){
>> >             osl.destroy();
>> >             this.osl = null;
>> >         }
>> >         super.destroy();
>> >     }
>> >
>> >     public Servlet getDelegatee(){
>> >         return this.delegatee;
>> >     }
>> >
>> >
>> >
>> > }
>> >
>> >
>> > Here's the bridge (OSL) also got from Sling:
>> >
>> > package org.openspotlight.core.loader;
>> >
>> > import java.util.ArrayList;
>> > import java.util.HashMap;
>> > import java.util.List;
>> > import java.util.Map;
>> > import java.util.concurrent.locks.ReadWriteLock;
>> >
>> > import org.apache.felix.framework.Felix;
>> > import org.apache.felix.framework.Logger;
>> > import org.apache.felix.framework.util.FelixConstants;
>> > import org.eclipse.equinox.http.servlet.internal.Activator;
>> > import org.osgi.framework.BundleActivator;
>> > import org.osgi.framework.BundleContext;
>> > import org.osgi.framework.BundleException;
>> >
>> > public class OSL implements BundleActivator {
>> >
>> >     private Felix felix;
>> >     private ReadWriteLock felixLock;
>> >     private ResourceProvider resourceProvider;
>> >     private Logger logger;
>> >     private BundleActivator httpServiceActivator;
>> >
>> >     public OSL(ResourceProvider rp, Map<String, String> props, Logger
>> > logger){
>> >         this.resourceProvider = rp;
>> >         this.logger = logger;
>> >         List<BundleActivator> activators = new
>> ArrayList<BundleActivator>();
>> >         activators.add(this);
>> >         activators.add(new BootstrapInstaller(logger,rp));
>> >         Map configMap = new HashMap();
>> >         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>> > activators);
>> >         felix = new Felix(configMap);
>> >         try {
>> >             felix.start();
>> >         } catch (Exception e) {
>> >             e.printStackTrace();
>> >         }
>> >     }
>> >
>> >     public void start(BundleContext context) throws Exception {
>> >         this.httpServiceActivator = new Activator();
>> >         this.httpServiceActivator.start(context);
>> >
>> >     }
>> >
>> >     public void stop(BundleContext context) throws Exception {
>> >         try {
>> >             this.httpServiceActivator.stop(context);
>> >         } catch (Exception e) {
>> >             e.printStackTrace();
>> >         }
>> >         this.httpServiceActivator = null;
>> >     }
>> >
>> >     public void destroy(){
>> >         if (felix != null) {
>> >             logger.log(Logger.LOG_INFO, "Shutting down OSL");
>> >             try {
>> >                 felix.stop();
>> >             } catch (BundleException e) {
>> >                 // TODO Auto-generated catch block
>> >                 e.printStackTrace();
>> >             }
>> >             logger.log(Logger.LOG_INFO, "Sling stopped");
>> >             felix = null;
>> >         }
>> >     }
>> >
>> > }
>> >
>> >
>> > Well, I get this messages at console when starting up:
>> >
>> > 16:14:17,887 ERROR [STDERR] *DEBUG* Scheduling task ManagedService
>> Update:
>> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
>> > 16:14:17,888 ERROR [STDERR] *DEBUG* Running task ManagedService Update:
>> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
>> >
>> > But when I access: localhost:8080/osl/system/console It does not find
>> the
>> > service. Looking at the ServletProxy source I found that there was no
>> > registrations in the class.
>> >
>> > Also, the first time I start the framework (after cleaning the cache
>> dir) I
>> > only find the system bundle. If I redeploy the war, it finds all the
>> bundles
>> > on the second time.
>> >
>> > Any ideas?
>> >
>> > Regards
>> >
>> >
>> > On Fri, Jan 16, 2009 at 11:33 AM, Carsten Ziegeler <
>> cziegeler@apache.org>wrote:
>> >
>> >> Vinicius Carvalho wrote:
>> >>> Thanks Felix that really helped, just a couple of more questions :)
>> >>>
>> >>> 1- Do I need to launch the container from a servlet (I was doing from
>> a
>> >>> Listener)
>> >>> 2- So, this servlet must be mapped to /* url, just like the Sling
>> does?
>> >>>
>> >> You can map the servlet to any path, like /myosgi - the web console is
>> >> then by default reachable at /myosgi/system/console.
>> >>
>> >> HTH
>> >> Carsten
>> >> --
>> >> Carsten Ziegeler
>> >> cziegeler@apache.org
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> >> For additional commands, e-mail: users-help@felix.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>

Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well, I fixed the project a bit, removed the servlet-api and add a property
org.osgi.framework.system.packages.extra = javax.servlet, javax.servlet.http
to Felix startup properties.

But still no success. So I decided to go to the source code.

Well, it seems that the webconsole service tracker HttpServiceTracker never
gets its addingService method called. So it does not bind itself.

One thing I found my self lost (again) is that the Sling implementation
starts an HttpService, what about the HttpServiceImpl which register the
proxy servlet? Isn't this one the one to be instantiated?

Regards

On Fri, Jan 16, 2009 at 4:53 PM, Felix Meschberger <fm...@gmail.com>wrote:

> Hi Vinicius,
>
> Vinicius Carvalho schrieb:
> > Well, still can't get it to work :(
>
> To bad ...
>
> >
> > Here's my web structure:
> >
> > web-inf/
> >   -web.xml
> >   -lib/
> >     org.apache.felix.framework-1.4.1.jar
> >     org.eclipse.osgi.services.jar
> >     org.osgi.compendium.jar
> >     org.osgi.core.jar
> >     org.osgi.foundation.jar
> >     org.eclipse.equinox.servlet-1.0.1.jar
> >    -resources/
> >     -bundles/
> >        org.apache.felix.configadmin.jar
> >        org.apache.felix.metatype.jar
> >        org.apache.felix.webconsole.jar
> >        org.eclipse.osgi.services.jar
> >    -corebundles/
> >        servlet-api.osg1-2.5.jar
>
> Notes: servlet-api is not required in a servlet container environment,
> since this api is provided by the container and should be injected
> through the system bundle. The osgi.services jar should probably not be
> place in the lib and the bundles folder, one location should do it.
>
> I suggest to add an OSGi LogService implementation bundle, such that you
> get logging of OSGi events as well as the web console itself (and others).
>
> From the classes below, I can unfortunately not tell you exactly, why
> this does not work.
>
> If you could send me your web application directly (off-list), I could
> try to find out, what exactly is going on here.
>
> Regards
> Felix
>
> >
> >
> > Well, here's the serlvet that boots the system (got it from sling)
> >
> > package org.openspotlight.core.loader;
> >
> > import java.io.IOException;
> > import java.net.MalformedURLException;
> > import java.net.URL;
> > import java.util.Collections;
> > import java.util.HashMap;
> > import java.util.Iterator;
> > import java.util.Map;
> > import java.util.Set;
> >
> > import javax.servlet.GenericServlet;
> > import javax.servlet.Servlet;
> > import javax.servlet.ServletContext;
> > import javax.servlet.ServletException;
> > import javax.servlet.ServletRequest;
> > import javax.servlet.ServletResponse;
> > import javax.servlet.http.HttpServletResponse;
> >
> > import org.apache.felix.framework.Logger;
> > import org.eclipse.equinox.http.servlet.HttpServiceServlet;
> > import org.osgi.framework.BundleException;
> > import org.osgi.framework.ServiceReference;
> >
> > public class OSLServlet extends GenericServlet {
> >
> >     private OSL osl;
> >     private Servlet delegatee;
> >
> >     @Override
> >     public void service(ServletRequest req, ServletResponse res)
> >             throws ServletException, IOException {
> >          Servlet delegatee = getDelegatee();
> >             if (delegatee == null) {
> >                 ((HttpServletResponse)
> > res).sendError(HttpServletResponse.SC_NOT_FOUND);
> >             } else {
> >                 delegatee.service(req, res);
> >             }
> >     }
> >     @Override
> >     public void init() throws ServletException {
> >         ServletContextResourceProvider rp = new
> > ServletContextResourceProvider(getServletContext());
> >         Logger logger = new ServletContextLogger(getServletContext());
> >         Map<String, String> props = new HashMap<String, String>();
> >         this.osl = new OSL(rp,props,logger);
> >         this.delegatee = new HttpServiceServlet();
> >         this.delegatee.init(getServletConfig());
> >         super.init();
> >     }
> >
> >
> >     @Override
> >     public void destroy() {
> >         if(this.delegatee != null){
> >             this.delegatee.destroy();
> >             this.delegatee = null;
> >         }
> >
> >         if(this.osl != null){
> >             osl.destroy();
> >             this.osl = null;
> >         }
> >         super.destroy();
> >     }
> >
> >     public Servlet getDelegatee(){
> >         return this.delegatee;
> >     }
> >
> >
> >
> > }
> >
> >
> > Here's the bridge (OSL) also got from Sling:
> >
> > package org.openspotlight.core.loader;
> >
> > import java.util.ArrayList;
> > import java.util.HashMap;
> > import java.util.List;
> > import java.util.Map;
> > import java.util.concurrent.locks.ReadWriteLock;
> >
> > import org.apache.felix.framework.Felix;
> > import org.apache.felix.framework.Logger;
> > import org.apache.felix.framework.util.FelixConstants;
> > import org.eclipse.equinox.http.servlet.internal.Activator;
> > import org.osgi.framework.BundleActivator;
> > import org.osgi.framework.BundleContext;
> > import org.osgi.framework.BundleException;
> >
> > public class OSL implements BundleActivator {
> >
> >     private Felix felix;
> >     private ReadWriteLock felixLock;
> >     private ResourceProvider resourceProvider;
> >     private Logger logger;
> >     private BundleActivator httpServiceActivator;
> >
> >     public OSL(ResourceProvider rp, Map<String, String> props, Logger
> > logger){
> >         this.resourceProvider = rp;
> >         this.logger = logger;
> >         List<BundleActivator> activators = new
> ArrayList<BundleActivator>();
> >         activators.add(this);
> >         activators.add(new BootstrapInstaller(logger,rp));
> >         Map configMap = new HashMap();
> >         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
> > activators);
> >         felix = new Felix(configMap);
> >         try {
> >             felix.start();
> >         } catch (Exception e) {
> >             e.printStackTrace();
> >         }
> >     }
> >
> >     public void start(BundleContext context) throws Exception {
> >         this.httpServiceActivator = new Activator();
> >         this.httpServiceActivator.start(context);
> >
> >     }
> >
> >     public void stop(BundleContext context) throws Exception {
> >         try {
> >             this.httpServiceActivator.stop(context);
> >         } catch (Exception e) {
> >             e.printStackTrace();
> >         }
> >         this.httpServiceActivator = null;
> >     }
> >
> >     public void destroy(){
> >         if (felix != null) {
> >             logger.log(Logger.LOG_INFO, "Shutting down OSL");
> >             try {
> >                 felix.stop();
> >             } catch (BundleException e) {
> >                 // TODO Auto-generated catch block
> >                 e.printStackTrace();
> >             }
> >             logger.log(Logger.LOG_INFO, "Sling stopped");
> >             felix = null;
> >         }
> >     }
> >
> > }
> >
> >
> > Well, I get this messages at console when starting up:
> >
> > 16:14:17,887 ERROR [STDERR] *DEBUG* Scheduling task ManagedService
> Update:
> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
> > 16:14:17,888 ERROR [STDERR] *DEBUG* Running task ManagedService Update:
> > pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
> >
> > But when I access: localhost:8080/osl/system/console It does not find the
> > service. Looking at the ServletProxy source I found that there was no
> > registrations in the class.
> >
> > Also, the first time I start the framework (after cleaning the cache dir)
> I
> > only find the system bundle. If I redeploy the war, it finds all the
> bundles
> > on the second time.
> >
> > Any ideas?
> >
> > Regards
> >
> >
> > On Fri, Jan 16, 2009 at 11:33 AM, Carsten Ziegeler <cziegeler@apache.org
> >wrote:
> >
> >> Vinicius Carvalho wrote:
> >>> Thanks Felix that really helped, just a couple of more questions :)
> >>>
> >>> 1- Do I need to launch the container from a servlet (I was doing from a
> >>> Listener)
> >>> 2- So, this servlet must be mapped to /* url, just like the Sling does?
> >>>
> >> You can map the servlet to any path, like /myosgi - the web console is
> >> then by default reachable at /myosgi/system/console.
> >>
> >> HTH
> >> Carsten
> >> --
> >> Carsten Ziegeler
> >> cziegeler@apache.org
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >> For additional commands, e-mail: users-help@felix.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Web console

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Vinicius,

Vinicius Carvalho schrieb:
> Well, still can't get it to work :(

To bad ...

> 
> Here's my web structure:
> 
> web-inf/
>   -web.xml
>   -lib/
>     org.apache.felix.framework-1.4.1.jar
>     org.eclipse.osgi.services.jar
>     org.osgi.compendium.jar
>     org.osgi.core.jar
>     org.osgi.foundation.jar
>     org.eclipse.equinox.servlet-1.0.1.jar
>    -resources/
>     -bundles/
>        org.apache.felix.configadmin.jar
>        org.apache.felix.metatype.jar
>        org.apache.felix.webconsole.jar
>        org.eclipse.osgi.services.jar
>    -corebundles/
>        servlet-api.osg1-2.5.jar

Notes: servlet-api is not required in a servlet container environment,
since this api is provided by the container and should be injected
through the system bundle. The osgi.services jar should probably not be
place in the lib and the bundles folder, one location should do it.

I suggest to add an OSGi LogService implementation bundle, such that you
get logging of OSGi events as well as the web console itself (and others).

>From the classes below, I can unfortunately not tell you exactly, why
this does not work.

If you could send me your web application directly (off-list), I could
try to find out, what exactly is going on here.

Regards
Felix

> 
> 
> Well, here's the serlvet that boots the system (got it from sling)
> 
> package org.openspotlight.core.loader;
> 
> import java.io.IOException;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.Collections;
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.Map;
> import java.util.Set;
> 
> import javax.servlet.GenericServlet;
> import javax.servlet.Servlet;
> import javax.servlet.ServletContext;
> import javax.servlet.ServletException;
> import javax.servlet.ServletRequest;
> import javax.servlet.ServletResponse;
> import javax.servlet.http.HttpServletResponse;
> 
> import org.apache.felix.framework.Logger;
> import org.eclipse.equinox.http.servlet.HttpServiceServlet;
> import org.osgi.framework.BundleException;
> import org.osgi.framework.ServiceReference;
> 
> public class OSLServlet extends GenericServlet {
> 
>     private OSL osl;
>     private Servlet delegatee;
> 
>     @Override
>     public void service(ServletRequest req, ServletResponse res)
>             throws ServletException, IOException {
>          Servlet delegatee = getDelegatee();
>             if (delegatee == null) {
>                 ((HttpServletResponse)
> res).sendError(HttpServletResponse.SC_NOT_FOUND);
>             } else {
>                 delegatee.service(req, res);
>             }
>     }
>     @Override
>     public void init() throws ServletException {
>         ServletContextResourceProvider rp = new
> ServletContextResourceProvider(getServletContext());
>         Logger logger = new ServletContextLogger(getServletContext());
>         Map<String, String> props = new HashMap<String, String>();
>         this.osl = new OSL(rp,props,logger);
>         this.delegatee = new HttpServiceServlet();
>         this.delegatee.init(getServletConfig());
>         super.init();
>     }
> 
> 
>     @Override
>     public void destroy() {
>         if(this.delegatee != null){
>             this.delegatee.destroy();
>             this.delegatee = null;
>         }
> 
>         if(this.osl != null){
>             osl.destroy();
>             this.osl = null;
>         }
>         super.destroy();
>     }
> 
>     public Servlet getDelegatee(){
>         return this.delegatee;
>     }
> 
> 
> 
> }
> 
> 
> Here's the bridge (OSL) also got from Sling:
> 
> package org.openspotlight.core.loader;
> 
> import java.util.ArrayList;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
> import java.util.concurrent.locks.ReadWriteLock;
> 
> import org.apache.felix.framework.Felix;
> import org.apache.felix.framework.Logger;
> import org.apache.felix.framework.util.FelixConstants;
> import org.eclipse.equinox.http.servlet.internal.Activator;
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> import org.osgi.framework.BundleException;
> 
> public class OSL implements BundleActivator {
> 
>     private Felix felix;
>     private ReadWriteLock felixLock;
>     private ResourceProvider resourceProvider;
>     private Logger logger;
>     private BundleActivator httpServiceActivator;
> 
>     public OSL(ResourceProvider rp, Map<String, String> props, Logger
> logger){
>         this.resourceProvider = rp;
>         this.logger = logger;
>         List<BundleActivator> activators = new ArrayList<BundleActivator>();
>         activators.add(this);
>         activators.add(new BootstrapInstaller(logger,rp));
>         Map configMap = new HashMap();
>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
> activators);
>         felix = new Felix(configMap);
>         try {
>             felix.start();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> 
>     public void start(BundleContext context) throws Exception {
>         this.httpServiceActivator = new Activator();
>         this.httpServiceActivator.start(context);
> 
>     }
> 
>     public void stop(BundleContext context) throws Exception {
>         try {
>             this.httpServiceActivator.stop(context);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         this.httpServiceActivator = null;
>     }
> 
>     public void destroy(){
>         if (felix != null) {
>             logger.log(Logger.LOG_INFO, "Shutting down OSL");
>             try {
>                 felix.stop();
>             } catch (BundleException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>             logger.log(Logger.LOG_INFO, "Sling stopped");
>             felix = null;
>         }
>     }
> 
> }
> 
> 
> Well, I get this messages at console when starting up:
> 
> 16:14:17,887 ERROR [STDERR] *DEBUG* Scheduling task ManagedService Update:
> pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
> 16:14:17,888 ERROR [STDERR] *DEBUG* Running task ManagedService Update:
> pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
> 
> But when I access: localhost:8080/osl/system/console It does not find the
> service. Looking at the ServletProxy source I found that there was no
> registrations in the class.
> 
> Also, the first time I start the framework (after cleaning the cache dir) I
> only find the system bundle. If I redeploy the war, it finds all the bundles
> on the second time.
> 
> Any ideas?
> 
> Regards
> 
> 
> On Fri, Jan 16, 2009 at 11:33 AM, Carsten Ziegeler <cz...@apache.org>wrote:
> 
>> Vinicius Carvalho wrote:
>>> Thanks Felix that really helped, just a couple of more questions :)
>>>
>>> 1- Do I need to launch the container from a servlet (I was doing from a
>>> Listener)
>>> 2- So, this servlet must be mapped to /* url, just like the Sling does?
>>>
>> You can map the servlet to any path, like /myosgi - the web console is
>> then by default reachable at /myosgi/system/console.
>>
>> HTH
>> Carsten
>> --
>> Carsten Ziegeler
>> cziegeler@apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
> 

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


Re: Circumvent -DremoteOBR=foo.xml argument?

Posted by Richard Feldman <rt...@bjc.org>.
Ah, great! <remoteOBR> worked...from the documentation it seemed like that declaration was supposed to go in <distributionManagement>, which obviously did not work, but in <configuration> it worked perfectly.

Thanks!

>>> "Felix Meschberger" <fm...@gmail.com> 1/16/2009 1:30 PM >>>
Hi Richard,

Richard Feldman schrieb:
> I now have most of my settings for a Felix bundle deployment set in my POM. However, it still seems that the only way to get it to execute is to not only include bundle:deploy in my arguments to Maven, but also to include -DremoteOBR=foo.xml
> 
> Is there any way to specify the location of the remote OBR in the POM, so that I can just run Maven with the bundle:deploy goal and no additional arguments? If so, how?

Have you tried with the remoteOBR element in the <configuration>:

   <configuration>
       <remoteOBR>foo.xml</remoteOBR>
       <instructions>
           ....
       </instructions>
   </configuration>

Alternatively you might want to try <obrRepository> instead of remoteOBR.

Regards
Felix


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

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





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


Re: Circumvent -DremoteOBR=foo.xml argument?

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Richard,

Richard Feldman schrieb:
> I now have most of my settings for a Felix bundle deployment set in my POM. However, it still seems that the only way to get it to execute is to not only include bundle:deploy in my arguments to Maven, but also to include -DremoteOBR=foo.xml
> 
> Is there any way to specify the location of the remote OBR in the POM, so that I can just run Maven with the bundle:deploy goal and no additional arguments? If so, how?

Have you tried with the remoteOBR element in the <configuration>:

   <configuration>
       <remoteOBR>foo.xml</remoteOBR>
       <instructions>
           ....
       </instructions>
   </configuration>

Alternatively you might want to try <obrRepository> instead of remoteOBR.

Regards
Felix


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

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


Circumvent -DremoteOBR=foo.xml argument?

Posted by Richard Feldman <rt...@bjc.org>.
I now have most of my settings for a Felix bundle deployment set in my POM. However, it still seems that the only way to get it to execute is to not only include bundle:deploy in my arguments to Maven, but also to include -DremoteOBR=foo.xml

Is there any way to specify the location of the remote OBR in the POM, so that I can just run Maven with the bundle:deploy goal and no additional arguments? If so, how?

Thanks,

-Richard



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


Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Well, still can't get it to work :(

Here's my web structure:

web-inf/
  -web.xml
  -lib/
    org.apache.felix.framework-1.4.1.jar
    org.eclipse.osgi.services.jar
    org.osgi.compendium.jar
    org.osgi.core.jar
    org.osgi.foundation.jar
    org.eclipse.equinox.servlet-1.0.1.jar
   -resources/
    -bundles/
       org.apache.felix.configadmin.jar
       org.apache.felix.metatype.jar
       org.apache.felix.webconsole.jar
       org.eclipse.osgi.services.jar
   -corebundles/
       servlet-api.osg1-2.5.jar


Well, here's the serlvet that boots the system (got it from sling)

package org.openspotlight.core.loader;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.GenericServlet;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

import org.apache.felix.framework.Logger;
import org.eclipse.equinox.http.servlet.HttpServiceServlet;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;

public class OSLServlet extends GenericServlet {

    private OSL osl;
    private Servlet delegatee;

    @Override
    public void service(ServletRequest req, ServletResponse res)
            throws ServletException, IOException {
         Servlet delegatee = getDelegatee();
            if (delegatee == null) {
                ((HttpServletResponse)
res).sendError(HttpServletResponse.SC_NOT_FOUND);
            } else {
                delegatee.service(req, res);
            }
    }
    @Override
    public void init() throws ServletException {
        ServletContextResourceProvider rp = new
ServletContextResourceProvider(getServletContext());
        Logger logger = new ServletContextLogger(getServletContext());
        Map<String, String> props = new HashMap<String, String>();
        this.osl = new OSL(rp,props,logger);
        this.delegatee = new HttpServiceServlet();
        this.delegatee.init(getServletConfig());
        super.init();
    }


    @Override
    public void destroy() {
        if(this.delegatee != null){
            this.delegatee.destroy();
            this.delegatee = null;
        }

        if(this.osl != null){
            osl.destroy();
            this.osl = null;
        }
        super.destroy();
    }

    public Servlet getDelegatee(){
        return this.delegatee;
    }



}


Here's the bridge (OSL) also got from Sling:

package org.openspotlight.core.loader;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReadWriteLock;

import org.apache.felix.framework.Felix;
import org.apache.felix.framework.Logger;
import org.apache.felix.framework.util.FelixConstants;
import org.eclipse.equinox.http.servlet.internal.Activator;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

public class OSL implements BundleActivator {

    private Felix felix;
    private ReadWriteLock felixLock;
    private ResourceProvider resourceProvider;
    private Logger logger;
    private BundleActivator httpServiceActivator;

    public OSL(ResourceProvider rp, Map<String, String> props, Logger
logger){
        this.resourceProvider = rp;
        this.logger = logger;
        List<BundleActivator> activators = new ArrayList<BundleActivator>();
        activators.add(this);
        activators.add(new BootstrapInstaller(logger,rp));
        Map configMap = new HashMap();
        configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
activators);
        felix = new Felix(configMap);
        try {
            felix.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void start(BundleContext context) throws Exception {
        this.httpServiceActivator = new Activator();
        this.httpServiceActivator.start(context);

    }

    public void stop(BundleContext context) throws Exception {
        try {
            this.httpServiceActivator.stop(context);
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.httpServiceActivator = null;
    }

    public void destroy(){
        if (felix != null) {
            logger.log(Logger.LOG_INFO, "Shutting down OSL");
            try {
                felix.stop();
            } catch (BundleException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            logger.log(Logger.LOG_INFO, "Sling stopped");
            felix = null;
        }
    }

}


Well, I get this messages at console when starting up:

16:14:17,887 ERROR [STDERR] *DEBUG* Scheduling task ManagedService Update:
pid=org.apache.felix.webconsole.internal.servlet.OsgiManager
16:14:17,888 ERROR [STDERR] *DEBUG* Running task ManagedService Update:
pid=org.apache.felix.webconsole.internal.servlet.OsgiManager

But when I access: localhost:8080/osl/system/console It does not find the
service. Looking at the ServletProxy source I found that there was no
registrations in the class.

Also, the first time I start the framework (after cleaning the cache dir) I
only find the system bundle. If I redeploy the war, it finds all the bundles
on the second time.

Any ideas?

Regards


On Fri, Jan 16, 2009 at 11:33 AM, Carsten Ziegeler <cz...@apache.org>wrote:

> Vinicius Carvalho wrote:
> > Thanks Felix that really helped, just a couple of more questions :)
> >
> > 1- Do I need to launch the container from a servlet (I was doing from a
> > Listener)
> > 2- So, this servlet must be mapped to /* url, just like the Sling does?
> >
> You can map the servlet to any path, like /myosgi - the web console is
> then by default reachable at /myosgi/system/console.
>
> HTH
> Carsten
> --
> Carsten Ziegeler
> cziegeler@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Web console

Posted by Carsten Ziegeler <cz...@apache.org>.
Vinicius Carvalho wrote:
> Thanks Felix that really helped, just a couple of more questions :)
> 
> 1- Do I need to launch the container from a servlet (I was doing from a
> Listener)
> 2- So, this servlet must be mapped to /* url, just like the Sling does?
> 
You can map the servlet to any path, like /myosgi - the web console is
then by default reachable at /myosgi/system/console.

HTH
Carsten
-- 
Carsten Ziegeler
cziegeler@apache.org

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


Re: Web console

Posted by Vinicius Carvalho <vi...@caravelatech.com>.
Thanks Felix that really helped, just a couple of more questions :)

1- Do I need to launch the container from a servlet (I was doing from a
Listener)
2- So, this servlet must be mapped to /* url, just like the Sling does?
3- If the 2 question is true, what happens to others servlets I got, I'm
also interested in using GWT, Bertrand from Sling gave a nice approach for
it, but I'm also trying other approaches as explained by Rob Walker

Regards

On Fri, Jan 16, 2009 at 4:26 AM, Felix Meschberger <fm...@gmail.com>wrote:

> Hi Vinicius,
>
> Vinicius Carvalho schrieb:
> > Hello there! I'm reading the webconsole docs, but I really did not get
> how
> > to get it working. I'm lauching felix inside a container. I've checked
> > Sling, and eclipse equinox-server site, but one thing that I can't figure
> is
> > what is needed to get the webconsole running?
> >
> > Just putting the equinox httpservice there won't work. From the examples
> > I've seen it seems that I need to register the servlets, but for web
> console
> > which one?
> >
> > Could someone help me on this?
>
> The WebConsole registers itself with the OSGi HttpService. That is, to
> get to the WebConsole, an instance of the OSGi HttpService must be
> registered.
>
> For this to be the case, there are mulitple options. In you case of
> running the framework inside a servlet conatainer, you might want to use
> a Http Service bridge, which is a small piece of code which bridges to
> the Servlet Container.
>
> So the servlet which launches the framework also has to start the Http
> Service bridge (as part of a BundleActivator given to the framework on
> startup similar to what Sling does in the SlingServlet). This registers
> the HttpService in the framework. The next step is, that the servlet has
> to forward requests to the Http Service bridge (see the
> SlingServlet.service method).
>
> The Equinox HttpService bridge is actually "Http Services Servlet". This
> must be included in the web application outside of the framework.
>
> Hope this helps.
>
> Regards
> Felix
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Web console

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Vinicius,

Vinicius Carvalho schrieb:
> Hello there! I'm reading the webconsole docs, but I really did not get how
> to get it working. I'm lauching felix inside a container. I've checked
> Sling, and eclipse equinox-server site, but one thing that I can't figure is
> what is needed to get the webconsole running?
> 
> Just putting the equinox httpservice there won't work. From the examples
> I've seen it seems that I need to register the servlets, but for web console
> which one?
> 
> Could someone help me on this?

The WebConsole registers itself with the OSGi HttpService. That is, to
get to the WebConsole, an instance of the OSGi HttpService must be
registered.

For this to be the case, there are mulitple options. In you case of
running the framework inside a servlet conatainer, you might want to use
a Http Service bridge, which is a small piece of code which bridges to
the Servlet Container.

So the servlet which launches the framework also has to start the Http
Service bridge (as part of a BundleActivator given to the framework on
startup similar to what Sling does in the SlingServlet). This registers
the HttpService in the framework. The next step is, that the servlet has
to forward requests to the Http Service bridge (see the
SlingServlet.service method).

The Equinox HttpService bridge is actually "Http Services Servlet". This
must be included in the web application outside of the framework.

Hope this helps.

Regards
Felix

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