You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by David Uttley <du...@democracysystems.com> on 2009/05/08 09:16:39 UTC
Null values
Hi There,
I am using version 2.1 of CFX integrated with Tapestry 5. I am trying
to get the IoC container of Tapestry to inject values into the classes
that are being used by CXF.
HelloWorldImpl implementor = new HelloWorldImpl();
implementor.setUserDAO(userDAO);
ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setServiceClass(HelloWorld.class);
svrFactory.setAddress("http://localhost:9000/services/helloWorld");
svrFactory.setServiceBean(implementor);
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
Server server = svrFactory.create();
I have the UserDAO at the point I create the CXF server so I try and
set it on the implementer but the factory seems to reset the
implementer back to default values when it supplies an instance. I am
not trying to pass the DAO over the service I just want to access the
database from the implementer to pass a user across the web service.
Any help would be appreciated it feels like I am missing something
obvious.
Thanks
David Uttley
duttley@democracysystems.com
Tel: +447525909341
*Disclaimer*
*Confidentiality: *This e-mail and its attachments are intended for
the above named only and may be confidential. If they have come to you
in error you must take no action based on them, nor must you copy or
show them to anyone; please reply to this e-mail and highlight the
error. *Security Warning: *Please note that this e-mail has been
created in the knowledge that Internet e-mail is not a 100% secure
communications medium. We advise that you understand and observe this
lack of security when e-mailing us. *Viruses: *Although we have taken
steps to ensure that this e-mail and attachments are free from any
virus, we advise that in keeping with good computing practice the
recipient should ensure they are actually virus free.
Re: Null values
Posted by Daniel Kulp <dk...@apache.org>.
Any chance you could extract this out into a small "main method" type test
case? Maybe try injecting a "Foo" bean or something? If I can get a small
test case, that would be a big help.
I'm really not sure why your resolver isn't being called though. That's the
really bizarre thing. Almost like the wrong bus is getting used or something.
That wouldn't be a good thing.
Dan
On Mon May 11 2009 8:56:14 am David Uttley wrote:
> Thanks for the reply,
>
> I have placed an @Resource annotation on the UserDAO and created a
> TapestryResolver but I still get a null value on the instance of the
> UserDAO.
>
> After running it through the debugger I can see that
> JaxWsServerFactoryBean injectResouces method does populate the the DAO
> on the object but I still get the following messages from the
> visitField method of the resource injector.
>
> 11-May-2009 13:44:25 org.apache.cxf.common.injection.ResourceInjector
> visitField
> INFO: failed to resolve resource org.demsys.webservices.HelloWorldImpl/
> userDAO
>
> I am getting this because the resourceResolvers list does not contain
> my resolver. Therefore, when I run the client the injectResources
> method does not get run and my object is not populated. However, the
> visit field method is called and gives the above error because my
> resolver is not in the list.
>
> I am adding the resolver as follows;
>
> logger.info("\n\n-----------------Starting Web
> Services------------------\n\n" + userDAO);
> HelloWorldImpl implementor = new HelloWorldImpl();
> logger.info("DAO " + userDAO);
> TapestryTypeResolver obj = new TapestryTypeResolver(userDAO);
> JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
>
> svrFactory
> .getBus().getExtension(ResourceManager.class).addResourceResolver(obj);
> svrFactory.setAddress("http://localhost:9000/services/helloWorld");
> svrFactory.setServiceBean(implementor);
> svrFactory.getInInterceptors().add(new LoggingInInterceptor());
> svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
> Server server = svrFactory.create();
>
> Its almost like there is some threading issue that stops the resolver
> being added to the thread that is calling the visitField method as the
> resolver is just not added until after this method is finished.
>
> This is on version 2.2.1, I upgraded to see if there was any difference.
>
> Any ideas?
> Thanks
> Dave
>
> On 8 May 2009, at 19:19, Daniel Kulp wrote:
> > Does the setUserDAO have an @Resource annotation on it. (or the
> > field) I
> > think the resource injection and stuff is kicking in and thus it's
> > injecting a
> > new UserDAO thing in there, but it happens to be null cause CXF
> > doesn't know
> > about it.
> >
> > What MAY make sense for you is to try and write a new subclass of
> > org.apache.cxf.resource.ResourceResolver
> > that could callback into the Tapestry container or similar to get
> > the stuff it
> > needs.
> >
> > Register that on the Bus's ResourceManager either via spring or
> > programatically via:
> >
> > bus.getExtension(ResourceManager.class).addResourceResolver(...)
> >
> >
> > Dan
> >
> > On Fri May 8 2009 3:16:39 am David Uttley wrote:
> >> Hi There,
> >>
> >> I am using version 2.1 of CFX integrated with Tapestry 5. I am trying
> >> to get the IoC container of Tapestry to inject values into the
> >> classes
> >> that are being used by CXF.
> >>
> >> HelloWorldImpl implementor = new HelloWorldImpl();
> >> implementor.setUserDAO(userDAO);
> >>
> >> ServerFactoryBean svrFactory = new ServerFactoryBean();
> >> svrFactory.setServiceClass(HelloWorld.class);
> >> svrFactory.setAddress("http://localhost:9000/services/helloWorld");
> >> svrFactory.setServiceBean(implementor);
> >> svrFactory.getInInterceptors().add(new LoggingInInterceptor());
> >> svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
> >> Server server = svrFactory.create();
> >>
> >>
> >> I have the UserDAO at the point I create the CXF server so I try and
> >> set it on the implementer but the factory seems to reset the
> >> implementer back to default values when it supplies an instance. I
> >> am
> >> not trying to pass the DAO over the service I just want to access the
> >> database from the implementer to pass a user across the web service.
> >>
> >> Any help would be appreciated it feels like I am missing something
> >> obvious.
> >>
> >> Thanks
> >> David Uttley
> >> duttley@democracysystems.com
> >> Tel: +447525909341
> >>
> >> *Disclaimer*
> >>
> >> *Confidentiality: *This e-mail and its attachments are intended for
> >> the above named only and may be confidential. If they have come to
> >> you
> >> in error you must take no action based on them, nor must you copy or
> >> show them to anyone; please reply to this e-mail and highlight the
> >> error. *Security Warning: *Please note that this e-mail has been
> >> created in the knowledge that Internet e-mail is not a 100% secure
> >> communications medium. We advise that you understand and observe this
> >> lack of security when e-mailing us. *Viruses: *Although we have taken
> >> steps to ensure that this e-mail and attachments are free from any
> >> virus, we advise that in keeping with good computing practice the
> >> recipient should ensure they are actually virus free.
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog
>
> David Uttley
> duttley@democracysystems.com
> Tel: +447525909341
>
> *Disclaimer*
>
> *Confidentiality: *This e-mail and its attachments are intended for
> the above named only and may be confidential. If they have come to you
> in error you must take no action based on them, nor must you copy or
> show them to anyone; please reply to this e-mail and highlight the
> error. *Security Warning: *Please note that this e-mail has been
> created in the knowledge that Internet e-mail is not a 100% secure
> communications medium. We advise that you understand and observe this
> lack of security when e-mailing us. *Viruses: *Although we have taken
> steps to ensure that this e-mail and attachments are free from any
> virus, we advise that in keeping with good computing practice the
> recipient should ensure they are actually virus free.
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: Null values
Posted by David Uttley <du...@democracysystems.com>.
Thanks for the reply,
I have placed an @Resource annotation on the UserDAO and created a
TapestryResolver but I still get a null value on the instance of the
UserDAO.
After running it through the debugger I can see that
JaxWsServerFactoryBean injectResouces method does populate the the DAO
on the object but I still get the following messages from the
visitField method of the resource injector.
11-May-2009 13:44:25 org.apache.cxf.common.injection.ResourceInjector
visitField
INFO: failed to resolve resource org.demsys.webservices.HelloWorldImpl/
userDAO
I am getting this because the resourceResolvers list does not contain
my resolver. Therefore, when I run the client the injectResources
method does not get run and my object is not populated. However, the
visit field method is called and gives the above error because my
resolver is not in the list.
I am adding the resolver as follows;
logger.info("\n\n-----------------Starting Web
Services------------------\n\n" + userDAO);
HelloWorldImpl implementor = new HelloWorldImpl();
logger.info("DAO " + userDAO);
TapestryTypeResolver obj = new TapestryTypeResolver(userDAO);
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory
.getBus().getExtension(ResourceManager.class).addResourceResolver(obj);
svrFactory.setAddress("http://localhost:9000/services/helloWorld");
svrFactory.setServiceBean(implementor);
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
Server server = svrFactory.create();
Its almost like there is some threading issue that stops the resolver
being added to the thread that is calling the visitField method as the
resolver is just not added until after this method is finished.
This is on version 2.2.1, I upgraded to see if there was any difference.
Any ideas?
Thanks
Dave
On 8 May 2009, at 19:19, Daniel Kulp wrote:
>
> Does the setUserDAO have an @Resource annotation on it. (or the
> field) I
> think the resource injection and stuff is kicking in and thus it's
> injecting a
> new UserDAO thing in there, but it happens to be null cause CXF
> doesn't know
> about it.
>
> What MAY make sense for you is to try and write a new subclass of
> org.apache.cxf.resource.ResourceResolver
> that could callback into the Tapestry container or similar to get
> the stuff it
> needs.
>
> Register that on the Bus's ResourceManager either via spring or
> programatically via:
>
> bus.getExtension(ResourceManager.class).addResourceResolver(...)
>
>
> Dan
>
>
> On Fri May 8 2009 3:16:39 am David Uttley wrote:
>> Hi There,
>>
>> I am using version 2.1 of CFX integrated with Tapestry 5. I am trying
>> to get the IoC container of Tapestry to inject values into the
>> classes
>> that are being used by CXF.
>>
>> HelloWorldImpl implementor = new HelloWorldImpl();
>> implementor.setUserDAO(userDAO);
>>
>> ServerFactoryBean svrFactory = new ServerFactoryBean();
>> svrFactory.setServiceClass(HelloWorld.class);
>> svrFactory.setAddress("http://localhost:9000/services/helloWorld");
>> svrFactory.setServiceBean(implementor);
>> svrFactory.getInInterceptors().add(new LoggingInInterceptor());
>> svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
>> Server server = svrFactory.create();
>>
>>
>> I have the UserDAO at the point I create the CXF server so I try and
>> set it on the implementer but the factory seems to reset the
>> implementer back to default values when it supplies an instance. I
>> am
>> not trying to pass the DAO over the service I just want to access the
>> database from the implementer to pass a user across the web service.
>>
>> Any help would be appreciated it feels like I am missing something
>> obvious.
>>
>> Thanks
>> David Uttley
>> duttley@democracysystems.com
>> Tel: +447525909341
>>
>> *Disclaimer*
>>
>> *Confidentiality: *This e-mail and its attachments are intended for
>> the above named only and may be confidential. If they have come to
>> you
>> in error you must take no action based on them, nor must you copy or
>> show them to anyone; please reply to this e-mail and highlight the
>> error. *Security Warning: *Please note that this e-mail has been
>> created in the knowledge that Internet e-mail is not a 100% secure
>> communications medium. We advise that you understand and observe this
>> lack of security when e-mailing us. *Viruses: *Although we have taken
>> steps to ensure that this e-mail and attachments are free from any
>> virus, we advise that in keeping with good computing practice the
>> recipient should ensure they are actually virus free.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
David Uttley
duttley@democracysystems.com
Tel: +447525909341
*Disclaimer*
*Confidentiality: *This e-mail and its attachments are intended for
the above named only and may be confidential. If they have come to you
in error you must take no action based on them, nor must you copy or
show them to anyone; please reply to this e-mail and highlight the
error. *Security Warning: *Please note that this e-mail has been
created in the knowledge that Internet e-mail is not a 100% secure
communications medium. We advise that you understand and observe this
lack of security when e-mailing us. *Viruses: *Although we have taken
steps to ensure that this e-mail and attachments are free from any
virus, we advise that in keeping with good computing practice the
recipient should ensure they are actually virus free.
Re: Null values
Posted by Daniel Kulp <dk...@apache.org>.
Does the setUserDAO have an @Resource annotation on it. (or the field) I
think the resource injection and stuff is kicking in and thus it's injecting a
new UserDAO thing in there, but it happens to be null cause CXF doesn't know
about it.
What MAY make sense for you is to try and write a new subclass of
org.apache.cxf.resource.ResourceResolver
that could callback into the Tapestry container or similar to get the stuff it
needs.
Register that on the Bus's ResourceManager either via spring or
programatically via:
bus.getExtension(ResourceManager.class).addResourceResolver(...)
Dan
On Fri May 8 2009 3:16:39 am David Uttley wrote:
> Hi There,
>
> I am using version 2.1 of CFX integrated with Tapestry 5. I am trying
> to get the IoC container of Tapestry to inject values into the classes
> that are being used by CXF.
>
> HelloWorldImpl implementor = new HelloWorldImpl();
> implementor.setUserDAO(userDAO);
>
> ServerFactoryBean svrFactory = new ServerFactoryBean();
> svrFactory.setServiceClass(HelloWorld.class);
> svrFactory.setAddress("http://localhost:9000/services/helloWorld");
> svrFactory.setServiceBean(implementor);
> svrFactory.getInInterceptors().add(new LoggingInInterceptor());
> svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
> Server server = svrFactory.create();
>
>
> I have the UserDAO at the point I create the CXF server so I try and
> set it on the implementer but the factory seems to reset the
> implementer back to default values when it supplies an instance. I am
> not trying to pass the DAO over the service I just want to access the
> database from the implementer to pass a user across the web service.
>
> Any help would be appreciated it feels like I am missing something
> obvious.
>
> Thanks
> David Uttley
> duttley@democracysystems.com
> Tel: +447525909341
>
> *Disclaimer*
>
> *Confidentiality: *This e-mail and its attachments are intended for
> the above named only and may be confidential. If they have come to you
> in error you must take no action based on them, nor must you copy or
> show them to anyone; please reply to this e-mail and highlight the
> error. *Security Warning: *Please note that this e-mail has been
> created in the knowledge that Internet e-mail is not a 100% secure
> communications medium. We advise that you understand and observe this
> lack of security when e-mailing us. *Viruses: *Although we have taken
> steps to ensure that this e-mail and attachments are free from any
> virus, we advise that in keeping with good computing practice the
> recipient should ensure they are actually virus free.
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog