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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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.