Forum Home » Fuse Distributions » Fuse ESB

Thread: Mina Route: Error executing command: java.lang.NullPointerException

 

Permlink Replies: 15 - Last Post: Apr 26, 2012 10:45 AM Last Post By: glennboschmans Threads: [ Previous | Next ]
feyl

Posts: 11
Registered: 03/09/12
Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 16, 2012 2:52 PM
  Click to reply to this thread Reply
Attachment servicemix.log (979.8 KB)
Attachment MyMinaDecoder.java (933 bytes)
Attachment MyMinaCodec.java (757 bytes)
Attachment beans.xml (793 bytes)
Attachment pom.xml (2.8 KB)
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, it's been a day I'm fighting against that, and can't figure out what's happening...

I guess it has something to do with my codec loading, but I'm stuck here now. I've attached all the necessary pieces to this post.

Thanks for your help!
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 19, 2012 2:07 PM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
Any idea? really?
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 20, 2012 5:14 AM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
Is all you see on the console: Error executing command: NullPointerException? There is nothing about this in log file in data/logs ?
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 20, 2012 3:15 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
Yep, that's all I get from the console. And nothing from the logs except this :

15:34:08,787 | INFO | l Console Thread | Console | 36 - org.apache.karaf.shell.console - 2.2.2.fuse-04-06 | Exception caught while executing command
java.lang.NullPointerException

Thanks
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 20, 2012 3:26 PM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
And just to be sure you have installed the camel-mina feature beforehand. And you are using the mina 1.x version in your maven project?
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 20, 2012 3:49 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
I have the camel-mina feature installed and active :

karaf@root> osgi:list | grep mina
214 Active [ ] [ ] 50 camel-mina (2.8.0.fuse-03-06)
215 Active [ ] [ ] 50 Apache ServiceMix :: Bundles :: mina (1.1.7.5)

Actually I haven't set the camel-mina version in my pom.xml. Do you think this can be the problem?

Thanks
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 20, 2012 4:35 PM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
My maven project is using the mina-core-2.0.1.jar
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 20, 2012 4:38 PM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
Yes you need to use the Mina 1.x, I think its 1.1.7.

Camel 2.10 will include a camel-mina2 component, that supports Mina2 API. Until then you will have to wait and use the Mina 1.x API, which is what Camel 2.9.x and older requires.
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 21, 2012 3:01 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
How can I do that? I mean, my pom.xml has as parent the fuse feature :

<parent>
<groupId>org.apache.servicemix.features</groupId>
<artifactId>features</artifactId>
<version>4.4.1-fuse-03-06</version>
</parent>

So my dependecy to mina is defined like :

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mina</artifactId>
<version>2.8.0-fuse-03-06</version>
</dependency>

I'm pretty new on that stuff, and I'm a little confused about how should I operate to depend on mina 1.x since it looks like this dependency sounds to be the one provided by Fuse and seems to be linked to mina 2.x?

Thank you for your precious help ;)
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 21, 2012 6:00 PM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
Why do you use that parent dependency (org.apache.servicemix.features)?
You should not do that.

The mina version that Fuse Camel 2.8 uses is defined in this pom.xml file, that have the versions:
http://repo.fusesource.com/nexus/content/repositories/releases/org/apache/camel/camel-parent/2.8.0-fuse-03-06/camel-parent-2.8.0-fuse-03-06.pom
njiang

Posts: 572
Registered: 09/17/07
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 22, 2012 12:37 AM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
No, the feature file is just for Fuse ESB to install or uninstall the bundles for you.
You pom should not have any relationship of it.

Willem
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Mar 22, 2012 11:08 AM   in response to: njiang in response to: njiang
  Click to reply to this thread Reply
I think I just missunderstoud the feature stuff... I'm starting to see my mistake, and things are getting clearer for me.

So, I changed my pom.xml, removed the parent, put the right version along with my dependencies, updated my code for 1.1.7 compliance and packaged the bundle... And get the same result at deployment. Here is my pom :

<?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>
<groupId>test</groupId>
<artifactId>mina-test</artifactId>
<packaging>bundle</packaging>
<name>My MINA Test</name>
<version>0.1.8</version>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.8.0-fuse-03-06</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.8.0-fuse-03-06</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mina</artifactId>
<version>2.8.0-fuse-03-06</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<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>
<Private-Package>test.net.*</Private-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<!-- FuseSource maven repositories -->
<repository>
<id>fusesource.releases</id>
<name>FuseSoure releases repository</name>
<url>http://repo.fusesource.com/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>fusesource.snapshots</id>
<name>FuseSource Snapshot Repository</name>
<url>http://repo.fusesource.com/maven2-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<pluginRepositories>
<!-- FuseSource maven repositories -->
<pluginRepository>
<id>fusesource.releases</id>
<name>FuseSoure releases repository</name>
<url>http://repo.fusesource.com/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>fusesource.snapshots</id>
<name>FuseSource Snapshot Repository</name>
<url>http://repo.fusesource.com/maven2-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>

</project>

Now I don't see what I'm doing wrong. Any clue?
Thanks
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Apr 6, 2012 3:01 PM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
Can somebody help me on this please?
glennboschmans

Posts: 2
Registered: 04/26/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Apr 26, 2012 10:03 AM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
I have the same issue. Did you find a solution yet?
feyl

Posts: 11
Registered: 03/09/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Apr 26, 2012 10:16 AM   in response to: glennboschmans in response to: glennboschmans
  Click to reply to this thread Reply
Unfortunately no. I've created a unit test in order to test my route with a simpler codec, but still does not work. I'll post my short unit test maybe somebody can help us.
glennboschmans

Posts: 2
Registered: 04/26/12
Re: Mina Route: Error executing command: java.lang.NullPointerException
Posted: Apr 26, 2012 10:45 AM   in response to: feyl in response to: feyl
  Click to reply to this thread Reply
I think it has nothing to do with the route itself, but rather with the bundle. My set-up is a bit different. I have a bundle for the codec. My route is an xml file with Spring DSL which resides directly in the deploy folder. I do this because multiple routes will use the same codec.

When I build my codec bundle with <Require-Bundle>org.apache.servicemix.bundles.mina</Require-Bundle> in pom.xml then the NPE is thrown while starting the bundle in Servicemix. If I remove the require-bundle element, the bundle starts but I get another exception when deploying the route.

Exception in thread "SpringOsgiExtenderThread-44" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route28: Route[[From[mina:tcp://localhost:4040?sync=false&disconnect=... because of Failed to resolve endpoint: mina://tcp://localhost:4040?codec=%23IntrionCodec&disconnect=true&minaLogger=true&sync=false due to: Could not find a
suitable setter for property: codec as there isn't a setter method with same type: com.realdolmen.intrion.poc.IntrionCodec nor type conversion possible: No type converter available to convert from type: com.realdolmen.intrion.poc.IntrionCodec to the required type: org.apache.mina.filter.codec.ProtocolCodecFactory with value com.realdolmen.intrion.poc.IntrionCodec@342409f8