You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Willem.Jiang" <wi...@gmail.com> on 2010/07/02 11:05:05 UTC

Re: Apache Camel 2.3.0 - required property bundleContext has not been set

Hi,

You can't just run the OSGi service with below command
"mvn -e compile exec:java -PCamelServer"

You need to deploy your bundle into OSGi plate form, or use some other OSGi
test tool like PaxExam to run.

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang 


Mpizo wrote:
> 
> Hi,
> 
> I am having trouble setting up OSGI services to run in the Apache Camel
> Server.
> 
> I am using Apache Camel 2.3.0. Below is my spring config file, pom.xml and
> the stacktrace that i am using in my project. Please help.
> 
> ----------------------------------CAMEL-SERVER.XML--------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> 	<!-- Configures the Camel Context-->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:context="http://www.springframework.org/schema/context"
> 	xmlns:camel="http://camel.apache.org/schema/spring"
> 	xmlns:amq="http://activemq.apache.org/schema/core"
> 	xmlns:osgi="http://www.springframework.org/schema/osgi"
> 	xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>         http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd 
>         http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring-2.3.0.xsd
>         http://activemq.apache.org/schema/core
> http://activemq.apache.org/schema/activemq-core-5.3.2.xsd
>         http://camel.apache.org/schema/osgi
> http://camel.apache.org/schema/osgi/camel-osgi-2.3.0.xsd
>         http://www.springframework.org/schema/osgi
> http://www.springframework.org/schema/osgi/spring-osgi.xsd
>         ">
> 
> 	<!-- let Spring do its IoC stuff in this package -->
> 	<context:component-scan base-package="com.reedhousesystems.routing" />
> 
> 	<!--
> 		declare a camel context that scans for classes that is RouteBuilder in
> 		the package com.reedhousesystems.routing
> 	-->
> 	<camel:camelContext id="camel">
> 		<camel:package>com.reedhousesystems.routing</camel:package>
> 		<!--
> 			enable JMX connector so we can connect to the server and browse
> 			mbeans
> 		-->
> 		<!--
> 			Camel will log at INFO level the service URI to use for connecting
> 			with jconsole
> 		-->
> 		<camel:jmxAgent id="agent" createConnector="true" />
> 		
> 	</camel:camelContext>
> 
> 	<!-- This creates an embedded ActiveMQ Broker -->
> 	<bean id="broker" class="org.apache.activemq.xbean.XBeanBrokerService">
>         <property name="transportConnectorURIs">
>             <list>
>                 <value>tcp://localhost:61610</value>
>             </list>
>         </property>
>         <property name="useJmx" value="false"/>
>         <property name="persistent" value="false"/>
>     </bean>
> 
> 	<!--
> 		Lets connect the Camel ActiveMQ component to the embedded broker. See
> 		http://camel.apache.org/activemq.html for more information.
> 	-->
> 	<bean id="jms"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> 		<property name="brokerURL" value="tcp://localhost:61610" />
> 	</bean>
>   
>   <bean id="genericMessagingService"
> class="com.reedhousesystems.routing.MessageServiceImpl">
>   </bean>
> 	
> 	<osgi:service ref="genericMessagingService">
> 		<osgi:interfaces>
> 			<value>com.reedhousesystems.routing.GenericMessagingService</value>
> 		</osgi:interfaces>
> 	</osgi:service>
> 	
> </beans>
> 
> -----------------------------------POM.XML---------------------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> 
> 	<modelVersion>4.0.0</modelVersion>
> 
> 	<groupId>com.reedhousesystems</groupId>
> 	<artifactId>jms</artifactId>
> 	<packaging>bundle</packaging>
> 	<version>0.0.1-SNAPSHOT</version>
> 
> 	<name>A Camel Route</name>
> 	<url>http://www.myorganization.org</url>
> 	<description>An example using Spring XML to talk to the JMS server from
> different kind of client techniques
>         and having AOP aspect to perform audit trails in the Camel Server
>     </description>
> 	<properties>
> 	
> <camel.osgi.export.pkg>org.apache.camel.example.server.*</camel.osgi.export.pkg>
> 	
> <camel.osgi.import.additional>org.apache.activemq.xbean,org.apache.activemq.broker,org.apache.activemq.pool</camel.osgi.import.additional>
> 		<camel-version>2.3.0</camel-version>
> 		<activemq-version>5.3.2</activemq-version>
> 		<xbean-spring-version>3.6</xbean-spring-version>
> 		<log4j-version>1.2.14</log4j-version>
> 		<spring-version>3.0.2.RELEASE</spring-version>
> 	</properties>
> 
> 	<dependencies>
> 		<dependency>
> 			<groupId>org.sonatype.tycho</groupId>
> 			<artifactId>org.eclipse.osgi</artifactId>
> 			<version>3.5.2.R35x_v20100126</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-beans</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-context</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-context-support</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-tx</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-core</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-web</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-jms</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-asm</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-expression</artifactId>
> 			<version>${spring-version}</version>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>org.springframework.web
> 			</artifactId>
> 			<version>${spring-version}</version>
> 			<exclusions>
> 				<exclusion>
> 					<groupId>aopalliance</groupId>
> 					<artifactId>aopalliance</artifactId>
> 				</exclusion>
> 			</exclusions>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.camel</groupId>
> 			<artifactId>camel-osgi</artifactId>
> 			<version>${camel-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.activemq</groupId>
> 			<artifactId>activemq-core</artifactId>
> 			<version>${activemq-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.activemq</groupId>
> 			<artifactId>activemq-camel</artifactId>
> 			<version>${activemq-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.camel</groupId>
> 			<artifactId>camel-core</artifactId>
> 			<version>${camel-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.camel</groupId>
> 			<artifactId>camel-jms</artifactId>
> 			<version>${camel-version}</version>
> 		</dependency><dependency>
> 			<groupId>org.apache.camel</groupId>
> 			<artifactId>camel-spring</artifactId>
> 			<version>${camel-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.xbean</groupId>
> 			<artifactId>xbean-spring</artifactId>
> 			<version>${xbean-spring-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>log4j</groupId>
> 			<artifactId>log4j</artifactId>
> 			<version>${log4j-version}</version>
> 		</dependency>
> 		
> 		<!-- required jars for aspectj AOP support -->
> 		<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-aop</artifactId>
> 			<version>${spring-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.aspectj</groupId>
> 			<artifactId>aspectjrt</artifactId>
> 			<version>1.6.2</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.aspectj</groupId>
> 			<artifactId>aspectjweaver</artifactId>
> 			<version>1.6.2</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>cglib</groupId>
> 			<artifactId>cglib-nodep</artifactId>
> 			<version>2.1_3</version>
> 		</dependency>
> 
> 		<!-- Camel bindy  -->
> 		<dependency>
> 			<groupId>org.apache.camel</groupId>
> 			<artifactId>camel-bindy</artifactId>
> 			<version>${camel-version}</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.apache.commons</groupId>
> 			<artifactId>com.springsource.org.apache.commons.lang</artifactId>
> 			<version>2.4.0</version>
> 		</dependency>
> 
> 		
> 	</dependencies>
> 	<profiles>
> 		<profile>
> 			<id>CamelServer</id>
> 			<properties>
> 				<!--
> 					we use Camel spring Main class as the server got all what it needs
> 					to start in the camel-server.xml file
> 				-->
> 				<target.main.class>org.apache.camel.spring.Main</target.main.class>
> 				<target.cmd.args>-ac
> META-INF/spring/camel-server.xml</target.cmd.args>
> 			</properties>
> 		</profile>
> 		<profile>
> 			<id>CamelMessagingClientRemoting</id>
> 			<properties>
> 				<!-- we start using our own class to control what we do in the main
> -->
> 			
> <target.main.class>com.reedhousesystems.routing.client.CamelMessagingClientRemoting</target.main.class>
> 			</properties>
> 		</profile>
> 	</profiles>
> 
> 	<build>
> 		<defaultGoal>install</defaultGoal>
> 
> 		<plugins>
> 			<plugin>
> 				<groupId>org.codehaus.mojo</groupId>
> 				<artifactId>exec-maven-plugin</artifactId>
> 				<version>1.1.1</version>
> 				<configuration>
> 					<mainClass>${target.main.class}</mainClass>
> 					<includePluginDependencies>false</includePluginDependencies>
> 					<commandlineArgs>${target.cmd.args}</commandlineArgs>
> 				</configuration>
> 			</plugin>
> 
> 			<plugin>
> 				<groupId>org.apache.maven.plugins</groupId>
> 				<artifactId>maven-compiler-plugin</artifactId>
> 				<configuration>
> 					<source>1.5</source>
> 					<target>1.5</target>
> 				</configuration>
> 			</plugin>
> 
> 			<!-- allows the route to be ran via 'mvn camel:run' -->
> 			<plugin>
> 				<groupId>org.apache.camel</groupId>
> 				<artifactId>camel-maven-plugin</artifactId>
> 				<version>${camel-version}</version>
> 			</plugin>
> 
> 			<!-- to generate the MANIFEST-FILE of the bundle -->
> 			<plugin>
> 				<groupId>org.apache.felix</groupId>
> 				<artifactId>maven-bundle-plugin</artifactId>
> 				<version>2.1.0</version>
> 				<extensions>true</extensions>
> 
> 				<configuration>
> 					<manifestLocation>META-INF</manifestLocation>
> 					<instructions>
> 						<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
> 
> 						<!-- STEP 3 -->
> 						<Export-Package>
> 							'=META-INF.com.reedhousesystems.routing',
> 							com.reedhousesystems.routing
> 						</Export-Package>
> 						<Import-Package>*,org.apache.camel.osgi</Import-Package>
> 						<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
> 					
> <Bundle-Activator>com.reedhousesystems.osgiutil.CamelRoutingActivator</Bundle-Activator>
> 					
> <Export-Service>com.reedhousesystems.routing.GenericMessagingService</Export-Service>
> 						<_failok>true</_failok>
> 					</instructions>
> 				</configuration>
> 			</plugin>
> 
> 		</plugins>
> 	</build>
> </project>
> 
> -----------------------------------------STACKTRACE------------------------------------
> 
> [user@machine:~/project] $ mvn -e compile exec:java -PCamelServer
> [pache.camel.spring.Main.main()] MainSupport                    INFO 
> Apache Camel 2.3.0 starting
> [pache.camel.spring.Main.main()] CamelNamespaceHandler          INFO 
> camel-osgi.jar/camel-spring-osgi.jar detected in classpath
> [pache.camel.spring.Main.main()] OsgiCamelContextHelper         WARN 
> BundleContext not set, cannot run in OSGI container
> [pache.camel.spring.Main.main()] CamelContextFactoryBean        INFO 
> JMXAgent enabled: CamelJMXAgent[usePlatformMBeanServer=true,
> createConnector=true, statisticsLevel=All]
> Configuring Camel routes.....
> [pache.camel.spring.Main.main()] BrokerService                  INFO 
> Using Persistence Adapter: MemoryPersistenceAdapter
> [pache.camel.spring.Main.main()] BrokerService                  INFO 
> ActiveMQ 5.3.2 JMS Message Broker (localhost) is starting
> [pache.camel.spring.Main.main()] BrokerService                  INFO  For
> help or more information please see: http://activemq.apache.org/
> [pache.camel.spring.Main.main()] TransportServerThreadSupport   INFO 
> Listening for connections at: tcp://localhost:61610
> [pache.camel.spring.Main.main()] TransportConnector             INFO 
> Connector tcp://localhost:61610 Started
> [pache.camel.spring.Main.main()] BrokerService                  INFO 
> ActiveMQ JMS Message Broker (localhost,
> ID:ekhayaict1-50308-1277978470275-0:0) started
> [pache.camel.spring.Main.main()] BrokerService                  INFO 
> ActiveMQ Message Broker (localhost, ID:ekhayaict1-50308-1277978470275-0:0)
> is shutting down
> [pache.camel.spring.Main.main()] TransportConnector             INFO 
> Connector tcp://localhost:61610 Stopped
> [pache.camel.spring.Main.main()] BrokerService                  INFO 
> ActiveMQ JMS Message Broker (localhost,
> ID:ekhayaict1-50308-1277978470275-0:0) stopped
> [pache.camel.spring.Main.main()] MainSupport                    INFO 
> Apache Camel 2.3.0 stopping
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] An exception occured while executing the Java class. null
> 
> required property 'bundleContext' has not been set
> [INFO]
> ------------------------------------------------------------------------
> [DEBUG] Trace
> org.apache.maven.lifecycle.LifecycleExecutionException: An exception
> occured while executing the Java class. null
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
> 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
> 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
> 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
> 	at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
> 	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:597)
> 	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
> 	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> 	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
> 	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: org.apache.maven.plugin.MojoExecutionException: An exception
> occured while executing the Java class. null
> 	at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:338)
> 	at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
> 	at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
> 	... 17 more
> Caused by: java.lang.reflect.InvocationTargetException
> 	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:597)
> 	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name
> 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0':
> Invocation of init method failed; nested exception is
> java.lang.IllegalArgumentException: required property 'bundleContext' has
> not been set
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
> 	at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
> 	at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> 	at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
> 	at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
> 	at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
> 	at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
> 	at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
> 	at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> 	at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
> 	at
> org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:219)
> 	at org.apache.camel.spring.Main.doStart(Main.java:173)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
> 	at org.apache.camel.impl.MainSupport.run(MainSupport.java:114)
> 	at org.apache.camel.impl.MainSupport.run(MainSupport.java:291)
> 	at org.apache.camel.spring.Main.main(Main.java:97)
> 	... 6 more
> Caused by: java.lang.IllegalArgumentException: required property
> 'bundleContext' has not been set
> 	at org.springframework.util.Assert.notNull(Assert.java:112)
> 	at
> org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean.afterPropertiesSet(OsgiServiceFactoryBean.java:150)
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
> 	... 23 more
> 
> 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-2-3-0-required-property-bundleContext-has-not-been-set-tp512348p512604.html
Sent from the Camel - Users mailing list archive at Nabble.com.