> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]]
> Sent: Thursday, October 14, 2010 10:39 AM
> To: [email protected]
> Subject: Re: Annotation to self-register service bean?
> 
> Hi
> 
> > > >  About the only reason I'm still defining the
> > > > bean in the XML config is that I have to put the bean into the
> > > > "jaxrs:serviceBeans" list, and I don't like to specify bean
names
> in
> > > > annotations.  It might be reasonable if I could have an
> annotation
> > > like
> > > > the following on my Controller:
> > > >
> > > > @JAXRSRegister("MyJAXRSServerName")
> > > >
> > > > On the other hand, perhaps I'm mistaken about what I need to
> > > configure
> > > > here.  In the documentation, I found the following statement:
> > > >
> > > >    "Note that when registering a model from Spring you do not
> need
> > to
> > > > declare a jaxrs server serviceBeans section - the runtime will
> > > > instantiate the beans itself."
> > > >
> > >
> > > The external model can refer to a service bean class. One only
> needs
> > to
> > > add
> > > a serviceBeans section if the external
> > > model refers to an interface (which one or more concrete service
> beans
> > > will
> > > implement).
> >
> > I don't understand what you mean here.  Are you saying that I could
> > leave out the "serviceBeans" section in my "jaxrs:server" element,
> and
> > component scanning will automatically find my service bean
> components?
> >
> > > If you do not want to use an xml configuration (Spring beans) at
> all
> > > then
> > > may be you may want to try CXFNonSpringJAXRSServlet ?
> >
> > I don't want to go that far.  I like specifying the root server
> address
> > in XML, and I have some providers that I want to specify here.
> >
> > If you use an external model (and I do not refer to the Spring
> configuration file but to the user models used with the no-annotation
> feature) then you have to specify a class name for every root resource
> this
> model describes.
> If this class a concrete class then CXF will create it and thus you do
> not
> need to declare it in the spring configuration file. But even in this
> case
> you can still explicitly create a service bean in the Spring config
and
> set
> some properties on it, etc. If you do it then it will be used instead
> of the
> one created by CXF when the model was being processed.
> 
> Now, if the class declared in the model is an interface then at the
> moment
> you need to additionally specify concrete classes in the serviceBeans
> section. This is not needed in DOSGI case as OSFI runtime will provide
> instances implementing the interfaces described in the external model

I'm still unsure what I can do here.  I tried commenting out my
"serviceBeans" section and the explicit bean definition.  My Controller
has a "@Controller" annotation, and my "component-scan" element
specifies the parent package of the Controller's package.

When I start up now, I see the following:

-----------------------------
Oct 14, 2010 10:51:13 AM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
checkResources
SEVERE: No resource classes found
[main] WARN
org.springframework.beans.factory.support.DisposableBeanAdapter -
Invocation of destroy method 'shutdown' failed on bean with name 'cxf':
org.springframework.beans.factory.BeanCreationNotAllowedException: Error
creating bean with name
'org.apache.cxf.buslifecycle.BusLifeCycleManager': Singleton bean
creation not allowed while the singletons of this factory are in
destruction (Do not request a bean from a BeanFactory in a destroy
method implementation!)
[main] ERROR org.springframework.web.context.ContextLoader - Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'SunlightDataServer': Invocation of init method failed;
nested exception is
org.apache.cxf.service.factory.ServiceConstructionException
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
...
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBea
n.java:132)
...
Caused by: javax.ws.rs.WebApplicationException
        at
org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAX
RSFactoryBean.java:270)
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBea
n.java:87)
...
Oct 14, 2010 10:51:13 AM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: Exception sending context initialized event to listener instance
of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'SunlightDataServer': Invocation of init method failed;
nested exception is
org.apache.cxf.service.factory.ServiceConstructionException
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
tory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
...
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBea
n.java:132)
...
Caused by: javax.ws.rs.WebApplicationException
        at
org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAX
RSFactoryBean.java:270)
        at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBea
n.java:87)
...
Oct 14, 2010 10:51:13 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Oct 14, 2010 10:51:13 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/SunlightDataService] startup failed due to previous
errors
------------------------

None of this happens if I have the "serviceBeans" section.

Reply via email to