>>>>> Steinar Bang <[email protected]>:
>> Once I've got that approach up and working I will look into reversing
>> the approach, ie. try to expose a service like in [2] above.
> This, on the other hand has turned out to be not so easy...:-)
> What I did, was:
> - Expose the shiro EventLoaderListener as an OSGi service
> - Expose the shiro filter as an OSGi service
> - Expose the servlet as an OSGi service
> This worked, as far as having all of the services start and be picked up
> by the pax whiteboard extender, e.g. like so:
[snip!]
> However, it didn't actually work.
> The problem is that the EventloaderListener has to be started first, and
> that it needs to receive an actual event, before the filter can be
> created. If not, I see this message in the karaf.log (as well as having
> nothing actually working):
> 2017-06-30T14:18:12,760 | ERROR | Thread-49 | WebApplication
> | 114 - org.ops4j.pax.web.pax-web-extender-whiteboard - 6.0.3 |
> Registration skipped for [FilterWebElement{mapping=DefaultFilterMapping
> [httpContextId=null,
> filter=org.ops4j.pax.web.service.spi.model.FilterModel-23, urlPatterns=[/*],
> servletNames=[ukelonn], initParams={service.id=179, servletNames=ukelonn,
> urlPatterns=[Ljava.lang.String;@14304ee, httpContext.path=/ukelonn,
> objectClass=[Ljava.lang.String;@6db98b5, service.scope=singleton,
> service.bundleid=72}, asyncSupported=false]}] due to error during registration
> java.lang.RuntimeException: javax.servlet.ServletException:
> java.lang.IllegalStateException: No WebEnvironment found: no
> EnvironmentLoaderListener registered?
[snip!]
> I've been scratching my head for a while figuring out how to best
> accomplish this, and haven't come up with something that works yet.
I ended up with a hybrid solution:
- The servlet and the shiro filter are exposed as OSGi services and
picked up by the pax whiteboard extender
- The shiro EnvironmentLoaderListener is created and registered with an
injected WebContainer (like in my first solution[1])
The code that handles the WebContainer injection is here:
https://github.com/steinarb/ukelonn/blob/scratch/using-vaadin-with-pax-whiteboard-extender/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/ShiroFilterProvider.java#L77
References:
[1]
<https://github.com/steinarb/ukelonn/blob/scratch/using-vaadin-jar-with-webcontainer-injection/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServiceProvider.java#L80>
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.