Code
---------------------------
public void sendMessages(Source sc) throws MessagingException {
try{
getClientFactory();
ServiceMixClient clientNoRouting = (ServiceMixClient)
context.getBean("clientWithRouting");
Map properties = new HashMap();
properties.put("name", "James");
clientNoRouting.send(null, null, properties, "<hello>world</hello>");
}catch(Throwable e){
e.printStackTrace();
}
}
protected void getClientFactory() throws Exception {
context = createBeanFactory();
client = getClient();
SpringJBIContainer jbi = (SpringJBIContainer) getBean("jbi");
}
protected ServiceMixClient getClient() throws Exception {
return (ServiceMixClient) getBean("client");
}
protected Object getBean(String name) {
Object answer = context.getBean(name);
return answer;
}
protected AbstractXmlApplicationContext createBeanFactory() {
return new ClassPathXmlApplicationContext("resources/servicemix.xml");
}
-------------------------------------------------------------------------------------------------
ServiceMix.xml
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:jms="http://servicemix.apache.org/jms/1.0"
xmlns:amq="http://activemq.org/config/1.0"
xmlns:test2="http://servicemix.apache.org/test2"
xmlns:test5="http://servicemix.apache.org/test5"
xmlns:sub2="http://subp" >
<sm:container id="jbi" embedded="true">
<sm:activationSpecs>
<!-- JMS POLLER - CONSUMER -->
<sm:activationSpec componentName="MyConsumer" service="sub2:MyConsumer">
<sm:component>
<jms:component>
<jms:endpoints>
<jms:endpoint service="sub2:MyConsumer"
endpoint="MyConsumer"
targetService="sub2:receiver"
targetEndpoint="receiver"
role="consumer"
destinationStyle="topic"
jmsProviderDestinationName="topic.sample"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
connectionFactory="#connectionFactory" />
</jms:endpoints>
</jms:component>
</sm:component>
</sm:activationSpec>
<!-- JMS SENDER - PROVIDER -->
<sm:activationSpec componentName="MyProvider" service="sub2:MyProvider">
<sm:component>
<jms:component>
<jms:endpoints>
<jms:endpoint service="sub2:MyProvider"
endpoint="MyProvider"
role="provider"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
destinationStyle="topic"
jmsProviderDestinationName="sample.rebuplish.topic"
connectionFactory="#connectionFactory" />
</jms:endpoints>
</jms:component>
</sm:component>
</sm:activationSpec>
<sm:activationSpec componentName="MySecondConsumer"
service="sub2:MySecondConsumer">
<sm:component>
<jms:component>
<jms:endpoints>
<jms:endpoint service="sub2:MySecondConsumer"
endpoint="MySecondConsumer"
targetService="sub2:receiver2"
targetEndpoint="receiver2"
role="consumer"
destinationStyle="topic"
jmsProviderDestinationName="sample.rebuplish.topic"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
connectionFactory="#connectionFactory" />
</jms:endpoints>
</jms:component>
</sm:component>
</sm:activationSpec>
<sm:activationSpec id="receiver" service="sub2:receiver">
<sm:component><bean
class="org.apache.servicemix.practice.poc.MyBean"/></sm:component>
</sm:activationSpec>
<sm:activationSpec id="receiver2" service="sub2:receiver2">
<sm:component><bean
class="org.apache.servicemix.practice.poc.MyBean2"/></sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<amq:connectionFactory id="connectionFactory"
brokerURL="tcp://localhost:61616" />
<bean id="client"
class="org.apache.servicemix.client.DefaultServiceMixClient">
<constructor-arg ref="jbi" />
</bean>
<bean id="clientWithRouting"
class="org.apache.servicemix.client.DefaultServiceMixClient">
<constructor-arg ref="jbi" />
<constructor-arg>
<sm:activationSpec destinationService="http://subp:MyProvider"/>
</constructor-arg>
</bean>
</beans>
---------------------------------------------------------------------------------------------------
Error
--------------
<msg-loc-info>
<loc-token/>
<loc-message>Could not deploy xbean service unit</loc-message>
</msg-loc-info>
</task-status-msg>
<exception-info>
<nesting-level>1</nesting-level>
<msg-loc-info>
<loc-token/>
<loc-message>Can not find 'jbi' bean</loc-message>
<stack-trace><![CDATA[java.lang.RuntimeException: Can not find 'jbi' bean
at
org.apache.servicemix.lwcontainer.LwContainerXBeanDeployer.getServices(LwContainerXBeanDeployer.java:5
Caused by: java.lang.ClassCastException:
org.apache.servicemix.jbi.container.SpringJBIContainer cannot be cast to
org.apache.servicemix.jbi.container.SpringServiceUnitContainer
at
org.apache.servicemix.lwcontainer.LwContainerXBeanDeployer.getServices(LwContainerXBeanDeployer.java:42)
... 37 more
]]></stack-trace>
</msg-loc-info>
</exception-info>
Bruce Snyder <[EMAIL PROTECTED]> wrote:
On 9/13/07, kumar k wrote:
> I have a lw component where I am using servicemix clientWithRouting . But I
> am getting an error "can not find jbi bean" caused by SpringJBIContainer
> cannot be cast to
> org.apache.servicemix.jbi.container.SpringServiceUnitContainer. Pls suggest.
>
>
>
> 1
>
>
> Can not find 'jbi' bean
> > at
> > org.apache.servicemix.lwcontainer.LwContainerXBeanDeployer.getServices(LwContainerXBeanDeployer.java:50)
> at
> org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:85)
>
> Caused by: java.lang.ClassCastException:
> org.apache.servicemix.jbi.container.SpringJBIContainer cannot be cast to
> org.apache.servicemix.jbi.container.SpringServiceUnitContainer
> at
> org.apache.servicemix.lwcontainer.LwContainerXBeanDeployer.getServices(LwContainerXBeanDeployer.java:42)
> ... 37 more
> ]]>
>
Is this being caused by your code? I'm confused about what exactly is
causing this error. If this is being caused by your code, please post
it.
Bruce
--
perl -e 'print unpack("u30","D0G)[EMAIL PROTECTED]&5R\"F)R=6-E+G-N>61E);'
Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Castor - http://castor.org/
---------------------------------
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings,
and more!