2012-03-19 8 views
0

私はminaコンポーネントを使用して非常に単純なラクダルートを作成しました。このルートは実際にカスタムコーデックを使用し、osgiバンドルとしてパッケージ化されています。 servicemix(apache-servicemix-4.4.1-fuse-03-06)にデプロイするたびに、バンドルはアクティブ状態にならず、インストールされます。もちろん、私はそれを起動しようとすると、コンソールから "java.lang.NullPointerExceptionコマンドを実行中にエラーが発生しました"が表示されますが、ログには何も表示されません...Mina route on servicemix - エラー実行コマンド:java.lang.NullPointerException

誰かが私にできること何が起こっているのか理解していない...これはパッケージ化の問題ですか?私はそれが私のコーデックの読み込みと関係があると思いますが、私は今ここで立ち往生しています。

ここに私のXMLルートここ

<?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&amp;codec=#myCodec" /> 
      <to uri="log:IncomingMsg" /> 
     </route> 
    </camelContext> 
</beans> 

は私のコーデックの工場

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 { 

      } 
     }; 
    } 
} 

私のコーデックの実装です:

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); 
    } 
} 

そして、私の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> 

ご協力いただきありがとうございます。 フランソワ

答えて

関連する問題