camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Whiteside (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-4537) Support for Spring DM 2.0
Date Thu, 13 Oct 2011 21:19:12 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-4537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13126937#comment-13126937
] 

Aaron Whiteside commented on CAMEL-4537:
----------------------------------------

OK,

So here is my real problems with Camel, maybe you have a solution...

* Camel JMS Component depends on Spring.
* Camel Blueprint support depends on the Aries implementation.
* Camel Spring+OSGi support only works with Spring DM 1.2 not Spring DM 2.0.

So while I can manually create an OSGiCamelContext instance in a non-Aries-Blueprint-implementation,
I have no way of configuring the JMS Component's ConnectionFactory or TransactionManager.
As the JMS Component uses the spring's ApplicationContext to look them up.

If I manually can create the JMSComponent in the Blueprint context and register it as a service
but the CamelContext cannot see that instance.

This is my blueprint context and keep in mind this is running on JBoss 7.0.2 using it's own
Blueprint implementation.

{code:language=xml}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <!-- Setup Spring's JTA Transaction Manager -->
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManagerName" value="java:jboss/TransactionManager"/>
    </bean>

    <!-- Use JNDI -->
    <bean id="initialContext" class="javax.naming.InitialContext"/>

    <!-- Lookup the JMS connection factory from the container -->
    <bean id="connectionFactory" factory-ref="initialContext" factory-method="lookup">
        <argument value="java:/JmsXA"/>
    </bean>

    <!-- Create and Register JmsComponent -->
    <bean id="jmsComponent" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="transactionManager" ref="transactionManager"/>
    </bean>
    <service ref="jmsComponent" interface="org.apache.camel.Component"/>

    <!-- Setup a Camel Context instance -->
    <bean id="camelContext" class="org.apache.camel.core.osgi.OsgiDefaultCamelContext"
init-method="start" destroy-method="stop" scope="singleton">
        <argument ref="blueprintBundleContext"/>
    </bean>

</blueprint>

{code}


With Spring DM 2.0 or Gemini this is much easier to do, the only problem being that Camel
will not detect it's in an OSGi environment and will not find the various component bundles.
So it cannot even find the JMSComponent.

This is a copy of the Spring DM 2.0 context I was using:

{code:language=xml}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
                           http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
                           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!-- Setup Spring's JTA Transaction Manager -->
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManagerName" value="java:jboss/TransactionManager"/>
    </bean>

    <!-- Lookup the JMS connection factory from the container -->
    <jee:jndi-lookup id="connectionFactory" jndi-name="java:/JmsXA" lookup-on-startup="true"
expected-type="javax.jms.ConnectionFactory"/>

    <!-- Create and Register JmsComponent -->
    <!--<bean id="jmsComponent" class="org.apache.camel.component.jms.JmsComponent">-->
        <!--<property name="connectionFactory" ref="connectionFactory"/>-->
        <!--<property name="transactionManager" ref="transactionManager"/>-->
    <!--</bean>-->
    <!--<osgi:service ref="jmsComponent" interface="org.apache.camel.Component"/>-->

    <!-- Setup a Camel Context instance -->
    <camel:camelContext id="camelContext" autoStartup="true" shutdownRunningTask="CompleteAllTasks">
        <camel:jmxAgent id="jmxAgent" disabled="false" usePlatformMBeanServer="true" createConnector="false"/>
    </camel:camelContext>

</beans>

{code}


So how to use JMS in OSGi without using Spring or Aries for Blueprint?
                
> Support for Spring DM 2.0
> -------------------------
>
>                 Key: CAMEL-4537
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4537
>             Project: Camel
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.9.0
>         Environment: JBoss 7.0.2 - OSGi
>            Reporter: Aaron Whiteside
>            Assignee: Jean-Baptiste Onofré
>            Priority: Critical
>              Labels: OSGi, Spring
>
> The camel-spring-2.9-SNAPSHOT.jar bundle imports 
> org.springframework.osgi.context;version="[1.2,2)";resolution:=optional,
> Which obviously excludes Spring DM 2.0.0M1
> I am not sure if Spring DM 2.0 breaks anything Camel is trying to use, but the class
org.springframework.osgi.context.BundleContextAware it is searching for on startup does exist
in spring-osgi-core-2.0.0.M1.jar.
> Currently when I deploy Camel 2.9-SNAPSHOT in JBoss 7.0.2 with Spring DM 2.0.0M1 I get
the following error, and I am unable to resolve any Components from the OSGi Service registry
- obviously because Camel is not trying to use it.
> {code}
> 18:04:32,347 WARN  [org.jboss.modules] (SpringOsgiExtenderThread-1) Failed to define
class org.apache.camel.osgi.CamelContextFactoryBean in Module "deployment.org.apache.camel.camel-spring:2.9.0.SNAPSHOT"
from Service Module Loader: java.lang.LinkageError: Failed to link org/apache/camel/osgi/CamelContextFactoryBean
(Module "deployment.org.apache.camel.camel-spring:2.9.0.SNAPSHOT" from Service Module Loader)
> 	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:401) [jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:261) [jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:76) [jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.Module.loadModuleClass(Module.java:590) [jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:183) [jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
[jboss-modules.jar:1.0.2.GA]
> 	at java.lang.Class.forName0(Native Method) [:1.7.0]
> 	at java.lang.Class.forName(Class.java:186) [:1.7.0]
> 	at org.apache.camel.spring.handler.CamelNamespaceHandler.init(CamelNamespaceHandler.java:133)
> 	at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:130)
> 	at org.springframework.osgi.extender.internal.support.NamespacePlugins$Plugin.resolve(NamespacePlugins.java:78)
> 	at org.springframework.osgi.extender.internal.support.NamespacePlugins$5.operate(NamespacePlugins.java:210)
> 	at org.springframework.osgi.extender.internal.support.NamespacePlugins$5.operate(NamespacePlugins.java:206)
> 	at org.springframework.osgi.extender.internal.support.LazyBundleRegistry.apply(LazyBundleRegistry.java:161)
> 	at org.springframework.osgi.extender.internal.support.NamespacePlugins.doResolve(NamespacePlugins.java:206)
> 	at org.springframework.osgi.extender.internal.support.NamespacePlugins.resolve(NamespacePlugins.java:170)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0]
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[:1.7.0]
> 	at java.lang.reflect.Method.invoke(Method.java:601) [:1.7.0]
> 	at org.springframework.osgi.context.support.TrackingUtil$OsgiServiceHandler.invoke(TrackingUtil.java:108)
> 	at $Proxy12.resolve(Unknown Source)	at org.springframework.osgi.context.support.DelegatedNamespaceHandlerResolver.resolve(DelegatedNamespaceHandlerResolver.java:57)
> 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1333)
> 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1328)
> 	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
> 	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
> 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
> 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
> 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
> 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
> 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
> 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
> 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
> 	at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:172)
> 	at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:142)
> 	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
> 	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:62)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:244)
> 	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:87)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:222)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:225)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:178)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:159)
> 	at org.springframework.osgi.extender.internal.activator.LifecycleManager$1.run(LifecycleManager.java:223)
> 	at java.lang.Thread.run(Thread.java:722) [:1.7.0]
> Caused by: java.lang.NoClassDefFoundError: org/springframework/osgi/context/BundleContextAware
> 	at java.lang.ClassLoader.defineClass1(Native Method) [:1.7.0]
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [:1.7.0]
> 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [:1.7.0]
> 	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397) [jboss-modules.jar:1.0.2.GA]
> 	... 50 more
> Caused by: java.lang.ClassNotFoundException: org.springframework.osgi.context.BundleContextAware
from [Module "deployment.org.apache.camel.camel-spring:2.9.0.SNAPSHOT" from Service Module
Loader]
> 	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191) [jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
[jboss-modules.jar:1.0.2.GA]
> 	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
[jboss-modules.jar:1.0.2.GA]
> 	... 54 more
> 18:04:32,368 INFO  [org.apache.camel.spring.handler.CamelNamespaceHandler] (SpringOsgiExtenderThread-1)
OSGi environment not detected.
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message