You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by AndreasH <hl...@bbp.ch> on 2006/10/20 15:39:14 UTC

ServiceMix.war and JSR181 context

Hi

I am trying to deploy a JSR181 endpoint in the servicemix.war and to inject
the component context. My applicationContext.xml looks as follows:

      <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
  xmlns:http="http://servicemix.apache.org/http/1.0"
  xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
  xmlns:my="http://servicemix.apache.org/demo/"
  xmlns:foo="http://servicemix.apache.org/cheese/">

...
      <sm:activationSpec>
	<sm:component>
	  <jsr181:component>
	    <jsr181:endpoints>
	      <jsr181:endpoint annotations="none" service="foo:filePoller"
endpoint="filePoller">
		<jsr181:pojo>
		  <bean class="test.FileLinkManager">
		    <property name="context" ref="context" />
		  </bean>
		</jsr181:pojo>
	      </jsr181:endpoint>
	    </jsr181:endpoints>
	  </jsr181:component>
	</sm:component>
      </sm:activationSpec>

...

Upon deploying I get the error that no bean with reference "context" can be
found:

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'test.FileLinkManager' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
'context' while setting bean property 'context'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'context' is defined
Caused by: 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'context' is defined
	at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:355)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:800)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
	at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
	at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
	at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:198)

Am I missing something? Incidentally, I am using ServiceMix3.1 from SVN.
According to the mailing list, injecting the context should have been added
for V3.0 already, so I assumed I should be fine.

Any help is greatly appreciated.

Regards

Andreas
-- 
View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6916913
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix.war and JSR181 context

Posted by robottaway <ro...@musiciansfriend.com>.
Thanks for taking interest, as this is a tough issue for me. As I've
mentioned I cannot use any bindings (objects => XML), and must pass the XML
as a String :( I would imagine that the http component should handle parsing
this SOAP request differently, before passing it into the jsr181 component.

Here is some XML stack trace. I am passing the String
<![CDATA[<ItemData></ItemData>]]>. You will see that the XML content is gone
in the message!

DEBUG - JettyContextManager            - Dispatching job:
HEP@4954293[d=true,io=0,w=true,b=0|0]
DEBUG - ConsumerProcessor              - Receiving HTTP request: POST
/AxDataGateway/ HTTP/1.1
Host: 172.16.10.243:8192
Content-Type: text/xml; charset=utf-8
Content-Length: 400
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: IBM Web Services Explorer
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Connection: close

INFO  - SoapHelper                     - SERVICE:
{http://www.musiciansfriend.com}AxDataGateway
INTERFACE: null
OPERATION: {http://www.musiciansfriend.com}releaseXmlDocument
INFO  - SoapHelper                     - CONTENT: null
DEBUG - DeliveryChannelImpl            - Send
ID:robert-ottaways-computer.local-61881-1162318278972-7:2 in
DeliveryChannel{servicemix-http}
DEBUG - DeliveryChannelImpl            - Sent: InOut[
  id: ID:robert-ottaways-computer.local-61881-1162318278972-7:2
  status: Active
  role: consumer
  service: {http://www.musiciansfriend.com}AxDataGateway
  endpoint: AxDataGateway
  operation: {http://www.musiciansfriend.com}releaseXmlDocument
  in: <?xml version="1.0" encoding="UTF-8"?><q0:releaseXmlDocument
xmlns:q0="http://www.musiciansfriend.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><q0:xmlDoc/></q0:releaseXmlDocument>
]
DEBUG - DefaultBroker                  - Routing exchange InOut[
  id: ID:robert-ottaways-computer.local-61881-1162318278972-7:2
  status: Active
  role: provider
  service: {http://www.musiciansfriend.com}AxDataGateway
  endpoint: AxDataGateway
  operation: {http://www.musiciansfriend.com}releaseXmlDocument
  in: <?xml version="1.0" encoding="UTF-8"?><q0:releaseXmlDocument
xmlns:q0="http://www.musiciansfriend.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><q0:xmlDoc/></q0:releaseXmlDocument>
] to:
ServiceEndpoint[service={http://www.musiciansfriend.com}AxDataGateway,endpoint=AxDataGateway]

You can see that the 'in' message parameter is empty = </xmlDoc>
I sent in the following <![CDATA[<ItemData></ItemData>]]>

If I pass in a simple String like 'bob' you will see it in the 'in' message!
Here is a trace:

INFO  - SoapHelper                     - SERVICE:
{http://www.musiciansfriend.com}AxDataGateway
INTERFACE: null
OPERATION: {http://www.musiciansfriend.com}releaseXmlDocument
INFO  - SoapHelper                     - CONTENT: null
DEBUG - DeliveryChannelImpl            - Send
ID:robert-ottaways-computer.local-61881-1162318278972-7:3 in
DeliveryChannel{servicemix-http}
DEBUG - DeliveryChannelImpl            - Sent: InOut[
  id: ID:robert-ottaways-computer.local-61881-1162318278972-7:3
  status: Active
  role: consumer
  service: {http://www.musiciansfriend.com}AxDataGateway
  endpoint: AxDataGateway
  operation: {http://www.musiciansfriend.com}releaseXmlDocument
  in: <?xml version="1.0" encoding="UTF-8"?><q0:releaseXmlDocument
xmlns:q0="http://www.musiciansfriend.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><q0:xmlDoc>bob</q0:xmlDoc></q0:releaseXmlDocument>
]

You can see the String 'bob' is in there! I have been going through the
servicemix-http and servicemix-soap code to find where the disappeerence
occurs. I've dug as deep as the readSoapUsingStax method in the SoapReader
class. A new StaxSource is created and set on a SoapMessage (as
javax.xml.transform.Source). Im guessing this StaxSource is close to the
problem. I will do a little more digging.
-- 
View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a7102949
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix.war and JSR181 context

Posted by Guillaume Nodet <gn...@gmail.com>.
Could you post a log file at DEBUG level ?
I'd like to understand where the xml is "lost".

On 10/31/06, robottaway <ro...@musiciansfriend.com> wrote:
>
> Using a CDATA section will not work. I'm not able to find why but it will be
> erased between the http component and the jsr181 component. What is the
> Source that you are speaking of? I found info on the XFire project pages
> about this but nothing on how to configure it.
> --
> View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a7097339
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: ServiceMix.war and JSR181 context

Posted by robottaway <ro...@musiciansfriend.com>.
Using a CDATA section will not work. I'm not able to find why but it will be
erased between the http component and the jsr181 component. What is the
Source that you are speaking of? I found info on the XFire project pages
about this but nothing on how to configure it.
-- 
View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a7097339
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix.war and JSR181 context

Posted by Guillaume Nodet <gn...@gmail.com>.
If you want to retrieve the full document (content of the message)
in your pojo, you may want to try with a single Source parameter
(instead of a string).  Else, i guess you will need to embed your
xml data inside a CDATA.

On 10/26/06, robottaway <ro...@musiciansfriend.com> wrote:
>
> I'm attaching a project which uses SU based jsr181 in a SA. It almost works.
> The jsr181 POJO does not get the XML I send across but that should be easy
> to fix :) It will at least get running and allow you to see how to do
> something like what you would like.
>
> http://www.nabble.com/file/3867/example.zip example.zip
> --
> View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a7014478
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: ServiceMix.war and JSR181 context

Posted by robottaway <ro...@musiciansfriend.com>.
I'm attaching a project which uses SU based jsr181 in a SA. It almost works.
The jsr181 POJO does not get the XML I send across but that should be easy
to fix :) It will at least get running and allow you to see how to do
something like what you would like.

http://www.nabble.com/file/3867/example.zip example.zip 
-- 
View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a7014478
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix.war and JSR181 context

Posted by AndreasH <hl...@bbp.ch>.
Hi Guillaume

Thanks for the quick answer. I id indeed try your first suggestion, by
adding the following method to my pojo:

	public void setContext(javax.jbi.component.ComponentContext context) throws
JBIException {
		log.info("FileLinkManager: setContext started");
		this.context = context;
		log.info("FileLinkManager: setContext started1");
	}

However, this gives the following problem in my trace:

2006-10-20 16:05:57,184 DEBUG [org.apache.servicemix.jsr181.Jsr181Component]
Querying service description for
ServiceEndpoint[service={http://servicemix.apache.org/cheese/}filePoller,endpoint=filePoller]
2006-10-20 16:05:57,199 DEBUG [org.apache.servicemix.jsr181.Jsr181Component]
Unable to inject ComponentContext:
test.FileLinkManager.setContext(javax.jbi.component.ComponentContext)
2006-10-20 16:05:57,199 DEBUG [org.apache.servicemix.jsr181.Jsr181Component]
Component started

and the context is never set. Alas, I will now also try your second
suggestion.

Thanks for your help!

Regards

Andreas


gnodet wrote:
> 
> You do not use SU, right ? The context bean is created
> when you deploy an SU with the xbean.xml config file.
> 
> If you want to configure the context on the pojo directly,
> you can just add a
>    public void setContext(ComponentContext context)
> method to your pojo.
> It should be called.
> 
> If you use a static configuration file (no SUs), you can
> also create a client:
>    <bean ...>
>      <property name="client">
>        <sm:client container="#jbi" />
>     </property>
> and defining the following method on your pojo:
>     public void setClient(ServiceMixClient client)
> 
> 
> 
> On 10/20/06, AndreasH <hl...@bbp.ch> wrote:
>>
>> Hi
>>
>> I am trying to deploy a JSR181 endpoint in the servicemix.war and to
>> inject
>> the component context. My applicationContext.xml looks as follows:
>>
>>       <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>>   xmlns:http="http://servicemix.apache.org/http/1.0"
>>   xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
>>   xmlns:my="http://servicemix.apache.org/demo/"
>>   xmlns:foo="http://servicemix.apache.org/cheese/">
>>
>> ...
>>       <sm:activationSpec>
>>         <sm:component>
>>           <jsr181:component>
>>             <jsr181:endpoints>
>>               <jsr181:endpoint annotations="none"
>> service="foo:filePoller"
>> endpoint="filePoller">
>>                 <jsr181:pojo>
>>                   <bean class="test.FileLinkManager">
>>                     <property name="context" ref="context" />
>>                   </bean>
>>                 </jsr181:pojo>
>>               </jsr181:endpoint>
>>             </jsr181:endpoints>
>>           </jsr181:component>
>>         </sm:component>
>>       </sm:activationSpec>
>>
>> ...
>>
>> Upon deploying I get the error that no bean with reference "context" can
>> be
>> found:
>>
>> org.springframework.beans.factory.BeanCreationException: Error creating
>> bean
>> with name 'test.FileLinkManager' defined in ServletContext resource
>> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
>> 'context' while setting bean property 'context'; nested exception is
>> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
>> named 'context' is defined
>> Caused by:
>> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
>> named 'context' is defined
>>         at
>> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:355)
>>         at
>> org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:800)
>>         at
>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
>>         at
>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
>>         at
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
>>         at
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
>>         at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
>>         at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
>>         at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
>>         at
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:198)
>>
>> Am I missing something? Incidentally, I am using ServiceMix3.1 from SVN.
>> According to the mailing list, injecting the context should have been
>> added
>> for V3.0 already, so I assumed I should be fine.
>>
>> Any help is greatly appreciated.
>>
>> Regards
>>
>> Andreas
>> --
>> View this message in context:
>> http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6916913
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6917514
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix.war and JSR181 context

Posted by AndreasH <hl...@bbp.ch>.
Hi Guillaume

Thanks for your suggestions, still I was not able to get it to work.
However, what I did notice so far is that my problems mostly seem to be
classloading issues. Somehow, I do not seem to have fully understood the
classloading mechanism behind the WAR deployment. Just to give you a brief
overview, I am deploying the servicemix WAR file inside our custom EAR file
to JBoss. This looks as follows:

ourProject.ear --- many_libs.jar
                      |- filelink_lib.jar
                      |- servicemix.war

where my class FileLinkManager is placed in filelink_lib.jar. I can solve
some of my problems by including filelink_lib.jar in servicemix.war,
however, this is not what I want! If I don't include it, I cannot inject the
context! I get similar classloading problems if I try to deploy
FileLinkManager dynamically from an SU; whereas such a scenario works with
the JBoss deployer. Basically what I don't understand are the differences in
classloading between the JBoss deployer and the WAR deployment. If you could
shed some light on this I would be eternally rateful.

Regards

Andreas


gnodet wrote:
> 
> You can always use the basic following method:
> 
> <bean class="test.FileLinkManager">
>   <property name="client">
>     <bean class="org.apache.servicemix.client.DefaultServiceMixClient">
>       <constructor-arg ref="jbi" />
>     </bean>
>   </property>
> </bean>
> 
> On 10/23/06, AndreasH <hl...@bbp.ch> wrote:
>>
>> Hi
>>
>> I was now able to test both your suggestions, however, without much luck.
>> First of all, as you rightly observed, I am not using SU's, rather I am
>> working with a static configuration in my WAR file
>> (applicationContext.xml).
>> Now I get the following problems:
>>
>> 1) On injecting the context, I get no exception and no stack trace, but
>> the
>> following message in my trace log:
>>
>> 2006-10-20 16:05:57,184 DEBUG
>> [org.apache.servicemix.jsr181.Jsr181Component]
>> Querying service description for
>> ServiceEndpoint[service={http://servicemix.apache.org/cheese/}filePoller,endpoint=filePoller]
>> 2006-10-20 16:05:57,199 DEBUG
>> [org.apache.servicemix.jsr181.Jsr181Component]
>> Unable to inject ComponentContext:
>> test.FileLinkManager.setContext(javax.jbi.component.ComponentContext)
>> 2006-10-20 16:05:57,199 DEBUG
>> [org.apache.servicemix.jsr181.Jsr181Component]
>> Component started
>>
>> and the context is never set!
>>
>> 2) On trying out the client approach, I get the following stack trace:
>>
>> org.springframework.beans.factory.BeanCreationException: Error creating
>> bean
>> with name '(inner bean)#4': FactoryBean threw exception on object
>> creation;
>> nested exception is java.lang.NullPointerException
>>
>> Caused by:
>>
>> java.lang.NullPointerException
>>
>>         at
>> org.apache.servicemix.client.DefaultServiceMixClient.<init>(DefaultServiceMixClient.java:79)
>>
>>         at
>> org.apache.servicemix.client.DefaultServiceMixClient.<init>(DefaultServiceMixClient.java:67)
>>
>>         at
>> org.apache.servicemix.jbi.framework.ClientFactory.createClient(ClientFactory.java:58)
>>
>>         at
>> org.apache.servicemix.client.ClientFactoryBean.getObject(ClientFactoryBean.java:103)
>>
>>         at
>> org.springframework.beans.factory.support.AbstractBeanFactory.getObjectFromFactoryBean(AbstractBeanFactory.java:994)
>>
>>         at
>> org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:966)
>>
>>         at
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:202)
>>
>>         at
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:116)
>>
>>         at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
>>
>>         at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
>>
>>         at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
>>
>> i.e., the container reference has not been set somehow, and is leading to
>> a
>> NPE!
>>
>> If I look further up in my trace log, I find the following entry, which
>> might be of interest in this context:
>>
>> 2006-10-23 09:05:51,453 WARN
>> [org.apache.servicemix.jbi.framework.ClientFactory] Cound not start
>> ClientFactory: javax.naming.CommunicationException [Root exception is
>> java.io.NotSerializableException:
>> org.apache.servicemix.jbi.framework.ClientFactory]
>>
>>
>> My applicationConetxt.xml looks as follows:
>>
>> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>>   xmlns:http="http://servicemix.apache.org/http/1.0"
>>   xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
>>   xmlns:my="http://servicemix.apache.org/demo/"
>>   xmlns:foo="http://servicemix.apache.org/cheese/">
>>
>>   <!-- the JBI container -->
>>   <sm:container id="jbi"
>>       rootDir="#rootDir"
>>       useMBeanServer="false"
>>                   createMBeanServer="false"
>>       installationDirPath="#installDir"
>>       deploymentDirPath="#deployDir"
>>                   monitorInstallationDirectory="true"
>>       dumpStats="true"
>>                   statsInterval="10"
>>       transactionManager="#transactionManager"
>>       depends-on="broker"
>>       createJmxConnector="false">
>>
>>     <sm:activationSpecs>
>>
>>       <sm:activationSpec>
>>         <sm:component>
>>           <jsr181:component>
>>             <jsr181:endpoints>
>>               <jsr181:endpoint annotations="none"
>> service="foo:filePoller"
>> endpoint="filePoller">
>>                 <jsr181:pojo>
>>                   <bean class="test.FileLinkManager">
>>                     <property name="client">
>>                       <sm:client container="#jbi" />
>>                     </property>
>>                       </bean>
>>                 </jsr181:pojo>
>>               </jsr181:endpoint>
>>             </jsr181:endpoints>
>>           </jsr181:component>
>>         </sm:component>
>>       </sm:activationSpec>
>>
>>      ....
>>
>> Any help is as always greatly appreciatd.
>>
>> Regards
>>
>> Andreas
>>
>>
>>
>>
>>
>> gnodet wrote:
>> >
>> > You do not use SU, right ? The context bean is created
>> > when you deploy an SU with the xbean.xml config file.
>> >
>> > If you want to configure the context on the pojo directly,
>> > you can just add a
>> >    public void setContext(ComponentContext context)
>> > method to your pojo.
>> > It should be called.
>> >
>> > If you use a static configuration file (no SUs), you can
>> > also create a client:
>> >    <bean ...>
>> >      <property name="client">
>> >        <sm:client container="#jbi" />
>> >     </property>
>> > and defining the following method on your pojo:
>> >     public void setClient(ServiceMixClient client)
>> >
>> >
>> >
>> > On 10/20/06, AndreasH <hl...@bbp.ch> wrote:
>> >>
>> >> Hi
>> >>
>> >> I am trying to deploy a JSR181 endpoint in the servicemix.war and to
>> >> inject
>> >> the component context. My applicationContext.xml looks as follows:
>> >>
>> >>       <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>> >>   xmlns:http="http://servicemix.apache.org/http/1.0"
>> >>   xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
>> >>   xmlns:my="http://servicemix.apache.org/demo/"
>> >>   xmlns:foo="http://servicemix.apache.org/cheese/">
>> >>
>> >> ...
>> >>       <sm:activationSpec>
>> >>         <sm:component>
>> >>           <jsr181:component>
>> >>             <jsr181:endpoints>
>> >>               <jsr181:endpoint annotations="none"
>> >> service="foo:filePoller"
>> >> endpoint="filePoller">
>> >>                 <jsr181:pojo>
>> >>                   <bean class="test.FileLinkManager">
>> >>                     <property name="context" ref="context" />
>> >>                   </bean>
>> >>                 </jsr181:pojo>
>> >>               </jsr181:endpoint>
>> >>             </jsr181:endpoints>
>> >>           </jsr181:component>
>> >>         </sm:component>
>> >>       </sm:activationSpec>
>> >>
>> >> ...
>> >>
>> >> Upon deploying I get the error that no bean with reference "context"
>> can
>> >> be
>> >> found:
>> >>
>> >> org.springframework.beans.factory.BeanCreationException: Error
>> creating
>> >> bean
>> >> with name 'test.FileLinkManager' defined in ServletContext resource
>> >> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
>> >> 'context' while setting bean property 'context'; nested exception is
>> >> org.springframework.beans.factory.NoSuchBeanDefinitionException: No
>> bean
>> >> named 'context' is defined
>> >> Caused by:
>> >> org.springframework.beans.factory.NoSuchBeanDefinitionException: No
>> bean
>> >> named 'context' is defined
>> >>         at
>> >>
>> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:355)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:800)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
>> >>         at
>> >>
>> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:198)
>> >>
>> >> Am I missing something? Incidentally, I am using ServiceMix3.1 from
>> SVN.
>> >> According to the mailing list, injecting the context should have been
>> >> added
>> >> for V3.0 already, so I assumed I should be fine.
>> >>
>> >> Any help is greatly appreciated.
>> >>
>> >> Regards
>> >>
>> >> Andreas
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6916913
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6949411
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6967934
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix.war and JSR181 context

Posted by Guillaume Nodet <gn...@gmail.com>.
You do not use SU, right ? The context bean is created
when you deploy an SU with the xbean.xml config file.

If you want to configure the context on the pojo directly,
you can just add a
   public void setContext(ComponentContext context)
method to your pojo.
It should be called.

If you use a static configuration file (no SUs), you can
also create a client:
   <bean ...>
     <property name="client">
       <sm:client container="#jbi" />
    </property>
and defining the following method on your pojo:
    public void setClient(ServiceMixClient client)



On 10/20/06, AndreasH <hl...@bbp.ch> wrote:
>
> Hi
>
> I am trying to deploy a JSR181 endpoint in the servicemix.war and to inject
> the component context. My applicationContext.xml looks as follows:
>
>       <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>   xmlns:http="http://servicemix.apache.org/http/1.0"
>   xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
>   xmlns:my="http://servicemix.apache.org/demo/"
>   xmlns:foo="http://servicemix.apache.org/cheese/">
>
> ...
>       <sm:activationSpec>
>         <sm:component>
>           <jsr181:component>
>             <jsr181:endpoints>
>               <jsr181:endpoint annotations="none" service="foo:filePoller"
> endpoint="filePoller">
>                 <jsr181:pojo>
>                   <bean class="test.FileLinkManager">
>                     <property name="context" ref="context" />
>                   </bean>
>                 </jsr181:pojo>
>               </jsr181:endpoint>
>             </jsr181:endpoints>
>           </jsr181:component>
>         </sm:component>
>       </sm:activationSpec>
>
> ...
>
> Upon deploying I get the error that no bean with reference "context" can be
> found:
>
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'test.FileLinkManager' defined in ServletContext resource
> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
> 'context' while setting bean property 'context'; nested exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'context' is defined
> Caused by:
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'context' is defined
>         at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:355)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:800)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:198)
>
> Am I missing something? Incidentally, I am using ServiceMix3.1 from SVN.
> According to the mailing list, injecting the context should have been added
> for V3.0 already, so I assumed I should be fine.
>
> Any help is greatly appreciated.
>
> Regards
>
> Andreas
> --
> View this message in context: http://www.nabble.com/ServiceMix.war-and-JSR181-context-tf2480516.html#a6916913
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet