Thanks Freeman for the idea of another approach... I have not worked with
osgi fragments, so was not aware how they work. This sounds like an
approach that could work in many situations where other osgi classloader
issues arise in 3rd-party libraries.

-Jeff

On Mon, Jan 16, 2012 at 8:46 PM, Freeman-2 [via CXF] <
ml-node+s547215n515048...@n5.nabble.com> wrote:

> Hi,
>
> Another general solution to workaround this class.forname issue in
> OSGi world is create your customer bundle as a fragment bundle, and
> attach it to the cxf bundle(cxf bundle play the role as a host
> bundle), so that all fragment bundle resource is available for host
> bundle.
> We usually use it to resolve the issue in JDBC driver bundle,  which
> has similar situation you encountered here, some bundle(like spring-
> jdbc or commons-dbcp) need use class.forname to init  driver classes
> from JDBC driver bundle, but there's no way that can import such
> package beforehand(as jdbc driver can from any provider and there's no
> way to know the package name beforehand), so make jdbc driver as
> fragment bundle and attach it to spring-jdbc or commons-dbcp can
> resolve it.
> This is actually a legacy class.forname issue before we have OSGi
> concept and I totally agree that in CXF we should get rid of the
> class.forname as much as possible.
>
> Freeman
> On 2012-1-17, at 上午9:28, gaygeek wrote:
>
> > Dan and Sergey-
> >
> > Thanks for your responses. I locally modified the cxf 2.5.2-SNAPSHOT
> > AnnotationInterceptors class and the interceptor annotations to
> > allow class
> > objects to be set in the annotations as Dan suggested and that will
> > work
> > very well. Instead of needing the classloader to find the classes by
> > name,
> > you just need to do clazz.newInstance(). I prefer using annotations
> > for
> > setting the interceptors, but I also think having the option in DOSGi
> > configuration is also a great idea. Do you think this change could
> > make it
> > into the 2.5.2 cxf release?
> >
> > Thanks,
> > Jeff
> >
> > On Mon, Jan 16, 2012 at 5:22 PM, Sergey Beryozkin-5 [via CXF] <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=5150485&i=0>>
> wrote:
> >
> >> Dan, thanks for the fix/enhancement, I also updated DOSGi
> >> to check for custom interceptors & features passed along during the
> >> registration/lookup, possibly already instantiated, and also from
> >> Declarative Services...for WS & RS
> >>
> >> Just stopped short of also starting the trackers, may be later :-)
> >>
> >> Sergey
> >> On 16/01/12 16:03, Daniel Kulp wrote:
> >>
> >>> On Monday, January 16, 2012 7:33:45 AM gaygeek wrote:
> >>>> Yes--as you said, the export is there in my custom bundle, but
> >>>> the cxf
> >>>> bundle has no way to import it to create the interceptor instance.
> >>>>
> >>>> Are you saying there is currently a way to do this, or that DOSGi
> >>>> will
> >> need
> >>>> to be modified to allow custom interceptors? I think you are
> >>>> saying it
> >> is
> >>>> not available currently, but that it would probably need to be a
> >> property
> >>>> on the osgi service export configuration.
> >>>
> >>> One thing we COULD try doing is updating the Annotations we have to
> >> actually
> >>> support using Class objects.  Right now, we have:
> >>>
> >>> public @interface InInterceptors {
> >>>     String[] interceptors();
> >>> }
> >>>
> >>> which means we need to do Class.forName things.   We could expand
> >>> this
> >> to:
> >>>
> >>> public @interface InInterceptors {
> >>>     String[] interceptors();
> >>>     Class<? extends Interceptor>[]  classes();
> >>> }
> >>>
> >>> or similar so that you could annotate with the actual class
> >>> objects and
> >> not
> >>> have to deal with the classloaders in OSGi.
> >>>
> >>> Dan
> >>>
> >>>
> >>>
> >>>>
> >>>> Thanks,
> >>>> Jeff
> >>>>
> >>>> On Mon, Jan 16, 2012 at 8:37 AM, Sergey Beryozkin-5 [via CXF]<
> >>>>
> >>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=5150169&i=0
>
> >>>> >>
> >> wrote:
> >>>>> Ignore that please, keeping forgetting the cxf bundle does not
> >>>>> import
> >>>>> custom classes/
> >>>>>
> >>>>> I think in DOSGi case, a new property would have to be
> >>>>> introduced in
> >>>>> time for custom CXF interceptors be picked up
> >>>>>
> >>>>> Cheers, Sergey
> >>>>>
> >>>>> On 16/01/12 12:25, Sergey Beryozkin wrote:
> >>>>>> Does the custom bundle export
> >>>>>> "com.uhg.upm.webservice.interceptor" ?
> >>>>>>
> >>>>>> Sergey
> >>>>>>
> >>>>>> On 13/01/12 22:36, gaygeek wrote:
> >>>>>>> I am trying to configure a custom interceptor for a web service
> >>>>>>> I'm
> >>>>>>> exposing
> >>>>>>> with DOSGi. However, it seems that the interceptor cannot be
> >>>>>>> initialized via
> >>>>>>> annotation, as the org.apache.cxf.bundle-minimal does not have
> >>>>>>> access
> >>>>>>> to my
> >>>>>>> custom interceptor class from its bundle classloader. I get the
> >>>>>
> >>>>> following
> >>>>>
> >>>>>>> error when starting my bundle with the service in it (which DOES
> >>>>>>> have
> >>>>>>> access
> >>>>>>> to the package that my SoapFaultInterceptor is in). It seems
> >>>>>>> like
> >>>>>>> the
> >>>>>>> only
> >>>>>>> way to make it work would be to hack the MANIFEST.MF for the
> >>>>>>> org.apache.cxf.bundle-minimal to import my bundle with the
> >>>>>>> custom
> >>>>>>> interceptor.
> >>>>>>>
> >>>>>>> Is there a different way to configure custom interceptors with
> >>>>>>> DOSGi?
> >>>>>>> Or am
> >>>>>>> I missing something in order to allow the annotations to work?
> >>>>>>>
> >>>>>>> Annotations for the WebService interface:
> >>>>>>> @WebService(name = "HelloService", targetNamespace =
> >>>>>>> "http://upm.uhc.com/example/hello";)
> >>>>>>> @OutFaultInterceptors(interceptors =
> >>>>>>> {"com.uhg.upm.webservice.interceptor.SoapFaultInterceptor"})
> >>>>>>> public interface HelloService
> >>>>>>>
> >>>>>>> Exception when starting my bundle with the HelloService in it:
> >>>>>>> Exception in thread "pool-1-thread-4"
> >>>>>>> org.apache.cxf.interceptor.Fault: Could not create annotation
> >>>>>>> object:
> >>>>>>> com.uhg.upm.webservice.interceptor.SoapFaultInterceptor
> >>>>>>> at
> >>>>>
> >>>>>
> >> org
> >> .apache.cxf.interceptor.AnnotationInterceptors.initializeAnnotationOb
> >>>>> jects(AnnotationInterceptors.java:79)>
> >>>>>>> at
> >>>>>
> >>>>>
> >> org
> >> .apache.cxf.interceptor.AnnotationInterceptors.getAnnotationObject(An
> >>>>> notationInterceptors.java:48)>
> >>>>>>> at
> >>>>>
> >>>>>
> >> org
> >> .apache.cxf.interceptor.AnnotationInterceptors.getAnnotationIntercept
> >>>>> orList(AnnotationInterceptors.java:102)>
> >>>>>>> at
> >>>>>
> >>>>>
> >> org
> >> .apache.cxf.interceptor.AnnotationInterceptors.getOutFaultInterceptor
> >>>>> s(AnnotationInterceptors.java:122)>
> >>>>>>> ...
> >>>>>>> Caused by: java.lang.ClassNotFoundException:
> >>>>>>> com.uhg.upm.webservice.interceptor.SoapFaultInterceptor not
> >>>>>>> found
> >>>>>>> by
> >>>>>>> org.apache.cxf.bundle-minimal [57]
> >>>>>>> at
> >>>>>
> >>>>>
> >> org
> >> .apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(Mo
> >>>>> duleImpl.java:812)>
> >>>>>>> at
> >>>>>>> org.apache.felix.framework.ModuleImpl.access
> >>>>>>> $400(ModuleImpl.java:
> >>>>>>> 72)
> >>>>>>>
> >>>>>>> Thank you for any insight into this issue.
> >>>>>>>
> >>>>>>> -Jeff
> >>>>>>>
> >>>>>>> --
> >>>>>
> >>>>>>> View this message in context:
> >>>>>
> >>
> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924
> >>>>> p5143924.html>
> >>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
> >>>>>
> >>>>> --
> >>>>> Sergey Beryozkin
> >>>>>
> >>>>> Talend Community Coders
> >>>>> http://coders.talend.com/
> >>>>>
> >>>>> Blog: http://sberyozkin.blogspot.com
> >>>>>
> >>>>>
> >>>>> ------------------------------
> >>>>>
> >>>>>  If you reply to this email, your message will be added to the
> >>>>>  discussion
> >>>>>
> >>>>> below:
> >>>>>
> >>>>>
> >>
> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924
> >>>>> p5148873.html>
> >>>>>  To unsubscribe from Custom interceptors with DOSGi, click
> >>>>>  here<
> >> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=u
> >>>>>
> >> nsubscribe_by_code
> >> &node=5143924&code=am1lbGJ5QGdtYWlsLmNvbXw1MTQzOTI0f
> >>>>>  C02NTQzMjczNTA=>>
> >>>>> .
> >>>>> NAML<
> >> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macr
> >>>>>
> >> o_viewer&id=instant_html%21nabble
> >> %3Aemail.naml&base=nabble.naml.namespac
> >>>>>
> >> es.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view
> >> .w
> >>>>>
> >> eb.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble
> >> %3Ae
> >>>>>
> >> mail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email
> >> %21nabb
> >>>>> le%3Aemail.naml>
> >>>> --
> >>>> View this message in context:
> >>>>
> >>
> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p51
> >>>> 49014.html Sent from the cxf-user mailing list archive at
> >>>> Nabble.com.
> >>
> >>
> >> --
> >> Sergey Beryozkin
> >>
> >> Talend Community Coders
> >> http://coders.talend.com/
> >>
> >> Blog: http://sberyozkin.blogspot.com
> >>
> >>
> >> ------------------------------
> >> If you reply to this email, your message will be added to the
> >> discussion
> >> below:
> >>
> >>
>
> >> >
> >> .
> >> NAML<
> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>
> >> >
> >>
> >
> >
> > --
> > View this message in context:
> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p5150350.html
>
> > Sent from the cxf-user mailing list archive at Nabble.com.
>
> ---------------------------------------------
> Freeman Fang
>
> FuseSource
> Email:[hidden email]<http://user/SendEmail.jtp?type=node&node=5150485&i=1>
> Web: fusesource.com
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p5150485.html
>  To unsubscribe from Custom interceptors with DOSGi, click 
> here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5143924&code=am1lbGJ5QGdtYWlsLmNvbXw1MTQzOTI0fC02NTQzMjczNTA=>
> .
> NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: 
http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p5151611.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to