title: Mina route on servicemix - Error executing command: java.lang.NullPointerException
body: <p>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...</p>
  
  <p>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.</p>
  
  <p>Here is my XML route</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans&gt;
      &lt;bean id="myCodec" class="test.net.mina.codec.MyMinaCodec" /&gt;
      &lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;
          &lt;route&gt;
              &lt;from uri="mina:tcp://localhost:9000?sync=true&amp;amp;codec=#myCodec" /&gt;
              &lt;to uri="log:IncomingMsg" /&gt;
          &lt;/route&gt;
      &lt;/camelContext&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Here is my codec factory</p>
  
  <pre><code>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 {
  
              }
          };
      }
  }
  </code></pre>
  
  <p>My codec implementation:</p>
  
  <pre><code>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() &gt;= 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 &lt; length; i++) {
              unsignedChars[i] = (char) in.getUnsigned();
          }
          return new String(unsignedChars);
      }
  }
  </code></pre>
  
  <p>And my pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.apache.servicemix.features&lt;/groupId&gt;
          &lt;artifactId&gt;features&lt;/artifactId&gt;
          &lt;version&gt;4.4.1-fuse-03-06&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;test&lt;/groupId&gt;
      &lt;artifactId&gt;mina-test&lt;/artifactId&gt;
      &lt;packaging&gt;bundle&lt;/packaging&gt;
      &lt;name&gt;My MINA Test&lt;/name&gt;
      &lt;version&gt;0.1.6&lt;/version&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-spring&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-mina&lt;/artifactId&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;instructions&gt;
                          &lt;Bundle-SymbolicName&gt;${project.artifactId}&lt;/Bundle-SymbolicName&gt;
                          &lt;Bundle-Description&gt;${project.description}&lt;/Bundle-Description&gt;
                          &lt;Import-Package&gt;*&lt;/Import-Package&gt;
                          &lt;Require-Bundle&gt;org.apache.servicemix.bundles.mina&lt;/Require-Bundle&gt;
                          &lt;Export-Package&gt;test.net.*&lt;/Export-Package&gt;
                          &lt;DynamicImport-Package&gt;&lt;/DynamicImport-Package&gt;
                      &lt;/instructions&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Thanks for your help.
  Francois</p>