L.S.,
You should make the RouteBuilder a class on its own inside the com.davidsonwiki.examples package - there's no need to write a main() method to bootstrap the CamelContext, with the Spring XML file, that will happen automatically as soon as the RouteBuilder class is found inside the package. cfr. http://servicemix.apache.org/docs/4.4.x/camel/deployment/osgi-bundle-spring.htmlfor an example of the Spring XML file Regards, Gert On Tue, Nov 6, 2012 at 3:44 AM, Davidson, Justin < [email protected]> wrote: > Claus, > > > > Here is the servicemix message I am getting after I deployed that > CamelDSL-routes.xml that references my Java DSL package > com.davidsonwiki.examples. > > > > > > Symbolic Name > > CamelDSL-routes.xml > > Version > > 0.0.0 > > Bundle Location > > spring:file:/C:/Apache/apache-servicemix-4.4.2/deploy/CamelDSL-routes.xm > l > > Last Modification > > Mon Nov 05 21:40:54 EST 2012 > > Start Level > > 60 > > Imported Packages > > com.davidsonwiki.examples.CamelDSLFileIO -- Cannot be resolved > > Manifest Headers > > Bundle-ManifestVersion: 2 > Bundle-SymbolicName: CamelDSL-routes.xml > Bundle-Version: 0.0.0 > DynamicImport-Package: * > Import-Package: com.davidsonwiki.examples.CamelDSLFileIO > Manifest-Version: 2 > Spring-Context: *; publish-context:=false; create-asynchronously:=true > > > > > > > > ################ CamelDSL-routes.xml #################### > > <beans > > xmlns="http://www.springframework.org/schema/beans" > > xmlns:amq="http://activemq.apache.org/schema/core" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xmlns:osgi="http://www.springframework.org/schema/osgi" > > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd > > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd > > http://www.springframework.org/schema/osgi > http://www.springframework.org/schema/osgi/spring-osgi.xsd"> > > > > <camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring"> > > <routeBuilder ref="myBuilder" /> > > <packageScan> > > <package>com.davidsonwiki.examples</package> > > </packageScan> > > </camelContext> > > > > <bean id="myBuilder" > class="com.davidsonwiki.examples.CamelDSLFileIO.builder"/> > > </beans> > > > > > > ######## Java DSL Example (Does not start) ############ > > ######## File: CamelDSLFileIO.java ############ > > package com.davidsonwiki.examples; > > > > import org.apache.camel.CamelContext; > > import org.apache.camel.builder.RouteBuilder; > > import org.apache.camel.impl.DefaultCamelContext; > > > > > > public class CamelDSLFileIO { > > public static void main(String args[]) throws Exception { > > System.out.println("testing.."); > > > > RouteBuilder builder = new RouteBuilder() { > > public void configure() { > > > from("file://c:/temp/indir/?noop=false&delay=2000").to("file://C:/temp/o > utdir/"); > > System.out.println("I am inside the configure.."); > > } > > }; > > CamelContext context = new DefaultCamelContext(); > > context.addRoutes(builder); > > context.start(); > > System.out.println("finished..."); > > > > } > > > > > > } > > > > > > > > > > Justin > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > From: Claus Ibsen [mailto:[email protected]] > Sent: Monday, November 05, 2012 10:54 AM > To: [email protected] > Subject: Re: ServiceMix - Java DSL vs. Spring XML DSL (File IO) > > > > The Java class with the RouteBuilder must be in the package you > specified > > <package>org.foo.bar</package> > > > > Do you have that? > > > > > > On Mon, Nov 5, 2012 at 4:45 PM, Davidson, Justin > > <[email protected]> wrote: > > > All, > > > > > > > > > > > > I am fairly new to ServiceMix and with that I am just testing the > basic > > > Camel examples to move files from one directory to another. The first > > > one I did with Spring and ensured it was in the ActiveMQ > > > activemq-broker.xml and it starts and works as advertised. Then I > > > disable it and try to Java example. The second one in java appears to > > > deploy fine and shows up in the bundles list and is active in > > > servicemix, but does not start to do its work. > > > > > > > > > > > > ####### Spring XML Example (Works) ################ > > > > > > <beans > > > > > > xmlns="http://www.springframework.org/schema/beans" > > > > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > > > > xsi:schemaLocation="http://camel.apache.org/schema/spring > > > http://camel.apache.org/schema/spring/camel-spring.xsd > > > > > > http://www.springframework.org/schema/beans > > > http://www.springframework.org/schema/beans/spring-beans.xsd"> > > > > > > > > > > > > <camelContext id="camel" > > > xmlns="http://camel.apache.org/schema/spring"> > > > > > > <packageScan> > > > > > > <package>org.foo.bar</package> > > > > > > </packageScan> > > > > > > > > > > > > <route id="fileinout"> > > > > > > <description>Example Camel Route</description> > > > > > > <from uri="file://c:/temp/indir/"/> > > > > > > <to uri="file://c:/temp/outdir/"/> > > > > > > </route> > > > > > > </camelContext> > > > > > > </beans> > > > > > > > > > > > > ######## Java DSL Example (Does not start) ############ > > > > > > First, I deploy the JAR to this directory: > > > C:\Apache\apache-servicemix-4.4.2\deploy. Yes, camel-core OSGI is > > > installed and started. > > > > > > > > > package com.davidsonwiki.examples; > > > import org.apache.camel.CamelContext; > > > > > > import org.apache.camel.builder.RouteBuilder; > > > > > > import org.apache.camel.impl.DefaultCamelContext; > > > > > > > > > > > > > > > > > > public class CamelDSLFileIO { > > > > > > public static void main(String args[]) throws Exception { > > > > > > > > > > > > > > > RouteBuilder builder = new RouteBuilder() { > > > > > > public void configure() { > > > > > > > > > > from("file://c:/temp/indir/?noop=false&delay=2000").to("file://C:/temp/o > > > utdir/"); > > > > > > } > > > > > > }; > > > > > > CamelContext context = new > > > DefaultCamelContext(); > > > > > > context.addRoutes(builder); > > > > > > context.start(); > > > > > > > > > > > > } > > > > > > > > > > > > } > > > > > > #################################################### > > > > > > > > > > > > What am I missing? > > > > > > > > > > > > > > > > > > Justin > > > > > > > > > > > > > > > > > -- > > Claus Ibsen > > ----------------- > > Red Hat, Inc. > > FuseSource is now part of Red Hat > > Email: [email protected] > > Web: http://fusesource.com > > Twitter: davsclaus > > Blog: http://davsclaus.com > > Author of Camel in Action: http://www.manning.com/ibsen > >
