You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Sebastian Gomez (JIRA)" <ji...@apache.org> on 2008/05/30 13:54:01 UTC
[jira] Created: (SM-1378) JBI endpoints not available from Camel
when using Embedded ServiceMix
JBI endpoints not available from Camel when using Embedded ServiceMix
---------------------------------------------------------------------
Key: SM-1378
URL: https://issues.apache.org/activemq/browse/SM-1378
Project: ServiceMix
Issue Type: Bug
Components: servicemix-camel
Affects Versions: 3.2.2
Reporter: Sebastian Gomez
Attachments: attachments.zip
When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
I attach the files that reproduce the problem, and here is the stack trace I get:
[org.springframework.web.context.ContextLoader] - Context
initialization failed
org.apache.camel.NoSuchEndpointException: No endpoint could be found
for: jbi:service:http://my.namespace.com//tracker
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (SM-1378) JBI endpoints not available
from Camel when using Embedded ServiceMix
Posted by "Łukasz Dywicki (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45560#action_45560 ]
splatch edited comment on SM-1378 at 9/9/08 2:08 AM:
------------------------------------------------------------
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 48:
{{Object value = applicationContext.getBean(name);}}
If we use prefix "jbi" camel will lookup for bean named jbi in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
was (Author: splatch):
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 39:
{{Object value = applicationContext.getBean(name, type);}}
If we use prefix "jbi" camel will lookup for bean named jbi in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (SM-1378) JBI endpoints not available from Camel
when using Embedded ServiceMix
Posted by "Łukasz Dywicki (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45560#action_45560 ]
Łukasz Dywicki commented on SM-1378:
------------------------------------
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 39:
{{Object value = applicationContext.getBean(name, type);}}
If we use prefix "jbi" camel will lookup for bean named jbi in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (SM-1378) JBI endpoints not available from Camel
when using Embedded ServiceMix
Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Nodet resolved SM-1378.
---------------------------------
Resolution: Won't Fix
Great stuff. I'm not sure there is a better workaround.
I've documented that on the wiki at http://cwiki.apache.org/SM/servicemix-camel.html
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (SM-1378) JBI endpoints not available
from Camel when using Embedded ServiceMix
Posted by "Łukasz Dywicki (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45560#action_45560 ]
splatch edited comment on SM-1378 at 9/9/08 2:09 AM:
------------------------------------------------------------
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 48:
{{return applicationContext.getBean(name);}}
If we use prefix *jbi* in route uri camel will lookup for bean named *jbi* in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
was (Author: splatch):
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 48:
{{Object value = applicationContext.getBean(name);}}
If we use prefix *jbi* in route uri camel will lookup for bean named *jbi* in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (SM-1378) JBI endpoints not available from Camel
when using Embedded ServiceMix
Posted by "Sebastian Gomez (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43126#action_43126 ]
Sebastian Gomez commented on SM-1378:
-------------------------------------
I found a solution to this issue, but if there is no other workaround to it, I think it should be at least documented somewhere to prevent people getting stuck in the same place as I have.
When creating a route to a jbi:service, the camel context factory looks for a bean called "jbi" (because of the prefix of the service). This bean must be a Component. So the first part of the workaround is to declare such bean (of class org.apache.servicemix.camel.CamelJbiComponent) in the servicemix.xml file. The problem comes when the message is about to be delivered: as it has been declared outside the jbi container, the component has no context. To fix this, the way to go is to declare a component inside the jbi container referencing the declared bean. So finally the servicemix.xml file should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xbean.org/schemas/spring/1.0"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:bean="http://servicemix.apache.org/bean/1.0"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:myproject="http://my.namespace.com/">
<!-- the JBI container -->
<sm:container id="jbiContainer" embedded="true">
<sm:activationSpecs>
<sm:activationSpec id="bean">
<sm:component>
<bean:component>
<bean:endpoints>
<bean:endpoint service="myproject:tracker" endpoint="tracker" bean="#tracker" />
</bean:endpoints>
</bean:component>
</sm:component>
</sm:activationSpec>
<sm:activationSpec id="camel" service="camel:camel" endpoint="camelEndpoint">
<sm:component>
<ref bean="jbi" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<bean id="jbi" class="org.apache.servicemix.camel.CamelJbiComponent" />
<camelContext id="camelContext" useJmx="true" xmlns="http://activemq.apache.org/camel/schema/spring">
<package>my.project.routeBuilders</package>
</camelContext>
<bean id="client"
class="org.apache.servicemix.client.DefaultServiceMixClient">
<constructor-arg ref="jbiContainer" />
</bean>
<bean id="tracker" class="my.project.Tracker" />
</beans>
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (SM-1378) JBI endpoints not available
from Camel when using Embedded ServiceMix
Posted by "Łukasz Dywicki (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45560#action_45560 ]
splatch edited comment on SM-1378 at 9/9/08 2:09 AM:
------------------------------------------------------------
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 48:
{{Object value = applicationContext.getBean(name);}}
If we use prefix *jbi* in route uri camel will lookup for bean named *jbi* in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
was (Author: splatch):
Problem source - SpringCamelContext created by camel namespace handler use ApplicationContextRegistry.
There is line 48:
{{Object value = applicationContext.getBean(name);}}
If we use prefix "jbi" camel will lookup for bean named jbi in ApplicationContext. Longer workaround based on own Registry implementation. At this moment I have a problem with correct test for camel execution, but i think this code can be base for issue resolution.
*context.xml*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:test="http://servicemix.apache.org/test"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
<bean id="camel" class="org.apache.servicemix.camel.CamelJbiComponent" />
<sm:container id="jbi" rootDir="target/data">
<sm:activationSpecs>
<sm:activationSpec service="test:camel" endpoint="endpoint">
<sm:component>
<ref bean="camel" />
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:echo" endpoint="endpoint">
<sm:component>
<bean class="org.apache.servicemix.components.util.EchoComponent" />
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
<camelContext id="camelContext" useJmx="false" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="timer://myTimer?fixedRate=true&delay=0&period=1000" />
<to uri="jbi:service:http://servicemix.apache.org/test/echo" />
</route>
</camelContext>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="camelContext"
lazy-init="false">
<property name="targetObject" ref="camelContext" />
<property name="targetMethod" value="setRegistry" />
<property name="arguments">
<bean class="org.apache.servicemix.camel.HackedRegistry">
<property name="component" ref="camel" />
</bean>
</property>
</bean>
</beans>
{quote}
*HackedRegistry.java*
package org.apache.servicemix.camel;
import org.apache.camel.spi.Registry;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class HackedRegistry implements Registry, ApplicationContextAware {
private CamelJbiComponent component;
private ApplicationContext applicationContext;
public Object lookup(String name) {
System.out.println("lookup for " + name);
return name.equals("jbi") ? getComponent() : applicationContext.getBean(name);
}
public <T> T lookup(String name, Class<T> type) {
System.out.println("lookup for " + name + " type " + type.getCanonicalName());
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
} catch (NoSuchBeanDefinitionException e) {
return null;
}
}
public CamelJbiComponent getComponent() {
return component;
}
public void setComponent(CamelJbiComponent component) {
this.component = component;
}
public void setApplicationContext(ApplicationContext arg0)
throws BeansException {
applicationContext = arg0;
}
}
Expected result:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.camel.CamelJbiComponent@.....
In place where previous was:
DEBUG DefaultComponentResolver - Found component: jbi in registry: org.apache.servicemix.jbi.container.SpringJbiContainer@.....
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (SM-1378) JBI endpoints not available from Camel
when using Embedded ServiceMix
Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/SM-1378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43164#action_43164 ]
Guillaume Nodet commented on SM-1378:
-------------------------------------
The attached zip file seems to be corrupted ...
> JBI endpoints not available from Camel when using Embedded ServiceMix
> ---------------------------------------------------------------------
>
> Key: SM-1378
> URL: https://issues.apache.org/activemq/browse/SM-1378
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-camel
> Affects Versions: 3.2.2
> Reporter: Sebastian Gomez
> Attachments: attachments.zip
>
>
> When declaring an embedded JBI container and a CamelContext, Camel is unable to reference JBI endpoints, throwing a "NoSuchEndpointException".
> I attach the files that reproduce the problem, and here is the stack trace I get:
> [org.springframework.web.context.ContextLoader] - Context
> initialization failed
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: jbi:service:http://my.namespace.com//tracker
> at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:92)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:95)
> at org.apache.camel.impl.RouteContext.resolveEndpoint(RouteContext.java:104)
> at org.apache.camel.model.ToType.resolveEndpoint(ToType.java:78)
> at org.apache.camel.model.ToType.createProcessor(ToType.java:72)
> at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:1387)
> at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:95)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:189)
> at org.apache.camel.model.RouteType.addRoutes(RouteType.java:83)
> at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:438)
> at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:430)
> at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:148)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:102)
> at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
> at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
> at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
> at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
> at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
> at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.