Try to start the bundle like this , check if there is missing in the imports ;
Start bundle-id Check what error it raises . Also when you start servimix you can check log Log:display Or under servicemix dirextory/data/log Let me know results you get . For error executing command , this is shell issue , wait till servicemix is up then do what I mentioned up. Thanks, Omar atia Sent via BlackBerry® -----Original Message----- From: Claus Ibsen <[email protected]> Date: Tue, 20 Mar 2012 07:46:10 To: <[email protected]> Reply-To: <[email protected]> Subject: Re: Mina route on servicemix - Error executing command: java.lang.NullPointerException Hi First of all I suggest to make sure it works *outside* OSGi. eg create a small unit test that tests that it works as expected. Then when its working, you knows its an OSGi deployment issue, which can be a beast by itself to tame. On Mon, Mar 19, 2012 at 11:42 PM, Francois Eyl <[email protected]> wrote: > Hi guys, > > I've created a very simple camel route using the mina component. This route > actually uses a custom Codec and is packaged as osgi bundle. Whenever I > deploy it to servicemix (apache-servicemix-4.4.1-fuse-03-06) the bundle is > not getting the Active state but Installed. And of course when I try to > start it I'm getting a "Error executing command: > java.lang.NullPointerException" from the console, but nothing in the logs... > > Can somebody help me make this work I can't figure out what's happening... > Is this a packaging issue? I guess it has something to do with my codec > loading, but I'm stuck here now. > > Here is my XML route: > > <?xml version="1.0" encoding="UTF-8"?> > <beans> > <bean id="myCodec" class="test.net.mina.codec.MyMinaCodec" /> > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <route> > <from uri="mina:tcp://localhost:9000?sync=true&codec=#myCodec" /> > <to uri="log:IncomingMsg" /> > </route> > </camelContext> > </beans> > > > Here is my codecfactory (removed imports): > > package test.net.mina.codec; > public class MyMinaCodec implements > ProtocolCodecFactory { > > public ProtocolDecoder getDecoder(IoSession session) throws Exception { > return new MyMinaDecoder(); > } > > public ProtocolEncoder getEncoder(IoSession session) throws Exception { > return new ProtocolEncoder() { > > public void encode(IoSession arg0, Object arg1, > ProtocolEncoderOutput arg2) throws Exception { > > } > > public void dispose(IoSession arg0) throws Exception { > > } > }; > } > } > > And here is my decoder implementation (removed imports) : > package test.net.mina.codec; > public class MyMinaDecoder extends CumulativeProtocolDecoder { > > public static final int MSG_HEADER_SIZE = 14; > > @Override > protected boolean doDecode(IoSession session, IoBuffer in, > ProtocolDecoderOutput out) throws Exception { > // try to read the message header > if (in.remaining() >= MSG_HEADER_SIZE) { > out.write(readsUnsignedBytesToString(in, MSG_HEADER_SIZE)); > return true; > } else { > // not enough data > return false; > } > } > > private String readsUnsignedBytesToString(IoBuffer in, int length) { > char[] unsignedChars = new char[length]; > for (int i = 0; i < length; i++) { > unsignedChars[i] = (char) in.getUnsigned(); > } > return new String(unsignedChars); > } > } > > And here is my 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/xsd/maven-4.0.0.xsd"> > > <modelVersion>4.0.0</modelVersion> > <parent> > <groupId>org.apache.servicemix.features</groupId> > <artifactId>features</artifactId> > <version>4.4.1-fuse-03-06</version> > </parent> > > <groupId>test</groupId> > <artifactId>mina-test</artifactId> > <packaging>bundle</packaging> > <name>My MINA Test</name> > <version>0.1.6</version> > > <dependencies> > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-core</artifactId> > </dependency> > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-spring</artifactId> > </dependency> > <dependency> > <groupId>org.apache.camel</groupId> > <artifactId>camel-mina</artifactId> > </dependency> > </dependencies> > > <build> > <plugins> > <plugin> > <groupId>org.apache.felix</groupId> > <artifactId>maven-bundle-plugin</artifactId> > <configuration> > <instructions> > <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> > <Bundle-Description>${project.description}</Bundle-Description> > <Import-Package>*</Import-Package> > <Require-Bundle>org.apache.servicemix.bundles.mina</Require-Bundle> > <Export-Package>test.net.*</Export-Package> > <DynamicImport-Package></DynamicImport-Package> > </instructions> > </configuration> > </plugin> > </plugins> > </build> > </project> > > > Thanks for your help, > Francois > -- Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
