Hi

When you use the codec Camel will look for a spring bean with the given id. But 
I guess you have tried with the bean id = lcf

You can enable DEBUG logging in Camel and it will output a bit more how it 
configures the mina component.

BTW: What version of Camel are you using?


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Conrad Pilloud [mailto:[EMAIL PROTECTED] 
Sent: 5. september 2008 01:50
To: camel-user@activemq.apache.org
Subject: Camel won't invoke my custom MINA codec


Hi,
After my attempts to serialize objects, push them over a socket to camel and
deserialize them using the default MINA codec failed (ref 
http://www.nabble.com/MINA-Deserialization-fails-with-Negative-dataLength-td19318349s22882.html
MINA Deserialization fails with Negative dataLength  ), I went down the path
of writing a custom MINA codec to implement a length protocol.  The length
protocol sends chunks of bytes over the socket, prepending them with an int
bytecount.  Outside the Camel environment, my new codec works great, sending
byte arrays over the socket as happy as you please.

However, when I try to get my Camel route to use the codec per the 
http://activemq.apache.org/camel/mina.html MINA Component Documentation , it
appears that Camel isn't using my custom codec.   I get the following: 
(note how com.foo.sir.LengthCodecDecoder isn't mentioned below in the stack
trace)

C:\workspace\camel-arb>mvn camel:run
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'camel'.
[INFO]
------------------------------------------------------------------------
[INFO] Building A Camel Route
[INFO]    task-segment: [camel:run]
[INFO]
------------------------------------------------------------------------
[INFO] Preparing camel:run
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 9 source files to C:\workspace\camel-arb\target\classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [camel:run]
Sep 4, 2008 5:31:05 PM org.apache.camel.spring.Main doStart
INFO: Apache Camel 1.4.0 starting
Sep 4, 2008 5:31:05 PM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing
[EMAIL PROTECTED]:
display name [org.springfra
[EMAIL PROTECTED]; startup date
[Thu Sep 04 17:31:05 MDT 2008]; root of con
text hierarchy
Sep 4, 2008 5:31:05 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from file
[C:\workspace\camel-arb\target\classes\META-INF\spring\camel-context.xml]
Sep 4, 2008 5:31:06 PM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[EMAIL PROTECTED]:

[EMAIL PROTECTED]
Sep 4, 2008 5:31:06 PM org.apache.camel.impl.DefaultCamelContext <init>
INFO: JMX enabled. Using InstrumentationLifecycleStrategy.
Sep 4, 2008 5:31:06 PM
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProce
ssAfterInitialization
INFO: Bean 'com.foo.sir.MyRouteBuilder' is not eligible for getting
processed by all BeanPostProcessors (for example: no
t eligible for auto-proxying)
Sep 4, 2008 5:31:06 PM
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProce
ssAfterInitialization
INFO: Bean 'camelContext' is not eligible for getting processed by all
BeanPostProcessors (for example: not eligible for
 auto-proxying)
Sep 4, 2008 5:31:06 PM
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProce
ssAfterInitialization
INFO: Bean 'camelContext' is not eligible for getting processed by all
BeanPostProcessors (for example: not eligible for
 auto-proxying)
Sep 4, 2008 5:31:06 PM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
[EMAIL PROTECTED]:
defi
ning beans [camelContext:beanPostProcessor,camelContext]; root of factory
hierarchy
Sep 4, 2008 5:31:06 PM org.apache.camel.spring.Main generateDot
INFO: Generating DOT file for routes:
C:\workspace\camel-arb\target/site/cameldoc for:
org.apache.camel.spring.SpringCam
[EMAIL PROTECTED] with name: camelContext
13297 [AnonymousIoService-2] WARN
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler -
[/127.0.0.1:3540] Unexpe
cted exception from exceptionCaught handler.
org.apache.camel.CamelException:
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.common.BufferDat
aException: java.io.EOFException (Hexdump: 00 00 00 B5 AC ED 00 05 73 72 00
18 63 6F 6D 2E 66 6F 6F 2E 73 69 72 2E 44 6F
 6D 61 69 6E 4F 62 6A 65 63 74 05 3C E6 61 EE C4 B8 10 02 00 09 49 00 03 63
49 64 4A 00 08 64 74 67 5F 6D 73 65 63 43 00
 04 65 78 65 72 44 00 01 66 4A 00 02 69 64 4A 00 02 6C 61 4A 00 02 6C 6F 4C
00 02 63 63 74 00 12 4C 6A 61 76 61 2F 6C 61
 6E 67 2F 53 74 72 69 6E 67 3B 4C 00 03 73 49 64 71 00 7E 00 01 78 70 00 00
03 E8 00 00 01 1C 2F B4 A5 52 00 00 40 6F 40
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00
00 00 00 01 74 00 02 41 41 71 00 7E 00 03 00
 00 00 B5 AC ED 00 05 73 72 00 18 63 6F 6D 2E 66 6F 6F 2E 73 69 72 2E 44 6F
6D 61 69 6E 4F 62 6A 65 63 74 05 3C E6 61 EE
 C4 B8 10 02 00 09 49 00 03 63 49 64 4A 00 08 64 74 67 5F 6D 73 65 63 43 00
04 65 78 65 72 44 00 01 66 4A 00 02 69 64 4A
 00 02 6C 61 4A 00 02 6C 6F 4C 00 02 63 63 74 00 12 4C 6A 61 76 61 2F 6C 61
6E 67 2F 53 74 72 69 6E 67 3B 4C 00 03 73 49
 64 71 00 7E 00 01 78 70 00 00 03 E9 00 00 01 1C 2F B4 A5 62 00 00 40 6F 40
00 00 00 00 00 00 00 00 00 00 00 00 01 00 00
 00 00 00 00 00 01 00 00 00 00 00 00 00 01 74 00 02 42 42 71 00 7E 00 03 00
00 00 B5 AC ED 00 05 73 72 00 18 63 6F 6D 2E
 66 6F 6F 2E 73 69 72 2E 44 6F 6D 61 69 6E 4F 62 6A 65 63 74 05 3C E6 61 EE
C4 B8 10 02 00 09 49 00 03 63 49 64 4A 00 08
 64 74 67 5F 6D 73 65 63 43 00 04 65 78 65 72 44 00 01 66 4A 00 02 69 64 4A
00 02 6C 61 4A 00 02 6C 6F 4C 00 02 63 63 74
 00 12 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B 4C 00 03 73 49
64 71 00 7E 00 01 78 70 00 00 03 EA 00 00 01
 1C 2F B4 A5 62 00 00 40 6F 40 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00
00 00 00 00 00 01 00 00 00 00 00 00 00 01 74
 00 02 43 43 71 00 7E 00 03 00 00 00 B5 AC ED 00 05 73 72 00 18 63 6F 6D 2E
66 6F 6F 2E 73 69 72 2E 44 6F 6D 61 69 6E 4F
 62 6A 65 63 74 05 3C E6 61 EE C4 B8 10 02 00 09 49 00 03 63 49 64 4A 00 08
64 74 67 5F 6D 73 65 63 43 00 04 65 78 65 72
 44 00 01 66 4A 00 02 69 64 4A 00 02 6C 61 4A 00 02 6C 6F 4C 00 02 63 63 74
00 12 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74
 72 69 6E 67 3B 4C 00 03 73 49 64 71 00 7E 00 01 78 70 00 00 03 EB 00 00 01
1C 2F B4 A5 62 00 00 40 6F 40 00 00 00 00 00
 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 74
00 02 44 44 71 00 7E 00 03 00 00 00 B5 AC ED
 00 05 73 72 00 18 63 6F 6D 2E 66 6F 6F 2E 73 69 72 2E 44 6F 6D 61 69 6E 4F
62 6A 65 63 74 05 3C E6 61 EE C4 B8 10 02 00
 09 49 00 03 63 49 64 4A 00 08 64 74 67 5F 6D 73 65 63 43 00 04 65 78 65 72
44 00 01 66 4A 00 02 69 64 4A 00 02 6C 61 4A
 00 02 6C 6F 4C 00 02 63 63 74 00 12 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74
72 69 6E 67 3B 4C 00 03 73 49 64 71 00 7E 00
 01 78 70 00 00 03 EC 00 00 01 1C 2F B4 A5 62 00 00 40 6F 40 00 00 00 00 00
00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
 01 00 00 00 00 00 00 00 01 74 00 02 45 45 71 00 7E 00 03)
        at
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught(MinaConsumer.java:85)
        at
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCaught(AbstractIoFilterChain.java:56
4)
        at
org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345)
        at
org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53)
        at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:6
43)
        at
org.apache.mina.common.IoFilterAdapter.exceptionCaught(IoFilterAdapter.java:75)
        at
org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345)
        at
org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53)
        at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:6
43)
        at
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:224)
        at
org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.common.BufferDataException: java.io.EO
FException (Hexdump: 00 00 00 B5 AC ED 00 05 73 72 00 18 63 6F 6D 2E 66 6F
6F 2E 73 69 72 2E 44 6F 6D 61 69 6E 4F 62 6A
65 63 74 05 3C E6 61 EE C4 B8 10 02 00 09 49 00 03 63 49 64 4A 00 08 64 74
67 5F 6D 73 65 63 43 00 04 65 78 65 72 44 00
01 66 4A 00 02 69 64 4A 00 02 6C 61 4A 00 02 6C 6F 4C 00 02 63 63 74 00 12
4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69
6E 67 3B 4C 00 03 73 49 64 71 00 7E 00 01 78 70 00 00 03 E8 00 00 01 1C 2F
B4 A5 52 00 00 40 6F 40 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 74 00 02
41 41 71 00 7E 00 03 00 00 00 B5 AC ED 00 05
73 72 00 18 63 6F 6D 2E 66 6F 6F 2E 73 69 72 2E 44 6F 6D 61 69 6E 4F 62 6A
65 63 74 05 3C E6 61 EE C4 B8 10 02 00 09 49
00 03 63 49 64 4A 00 08 64 74 67 5F 6D 73 65 63 43 00 04 65 78 65 72 44 00
01 66 4A 00 02 69 64 4A 00 02 6C 61 4A 00 02
6C 6F 4C 00 02 63 63 74 00 12 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69
6E 67 3B 4C 00 03 73 49 64 71 00 7E 00 01 78
70 00 00 03 E9 00 00 01 1C 2F B4 A5 62 00 00 40 6F 40 00 00 00 00 00 00 00
00 00 00 00 00 01 00 00 00 00 00 00 00 01 00
00 00 00 00 00 00 01 74 00 02 42 42 71 00 7E 00 03 00 00 00 B5 AC ED 00 05
73 72 00 18 63 6F 6D 2E 66 6F 6F 2E 73 69 72
2E 44 6F 6D 61 69 6E 4F 62 6A 65 63 74 05 3C E6 61 EE C4 B8 10 02 00 09 49
00 03 63 49 64 4A 00 08 64 74 67 5F 6D 73 65
63 43 00 04 65 78 65 72 44 00 01 66 4A 00 02 69 64 4A 00 02 6C 61 4A 00 02
6C 6F 4C 00 02 63 63 74 00 12 4C 6A 61 76 61
2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B 4C 00 03 73 49 64 71 00 7E 00 01 78
70 00 00 03 EA 00 00 01 1C 2F B4 A5 62 00 00
40 6F 40 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 01 00
00 00 00 00 00 00 01 74 00 02 43 43 71 00 7E
00 03 00 00 00 B5 AC ED 00 05 73 72 00 18 63 6F 6D 2E 66 6F 6F 2E 73 69 72
2E 44 6F 6D 61 69 6E 4F 62 6A 65 63 74 05 3C
E6 61 EE C4 B8 10 02 00 09 49 00 03 63 49 64 4A 00 08 64 74 67 5F 6D 73 65
63 43 00 04 65 78 65 72 44 00 01 66 4A 00 02
69 64 4A 00 02 6C 61 4A 00 02 6C 6F 4C 00 02 63 63 74 00 12 4C 6A 61 76 61
2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B 4C 00
03 73 49 64 71 00 7E 00 01 78 70 00 00 03 EB 00 00 01 1C 2F B4 A5 62 00 00
40 6F 40 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 74 00 02 44 44 71 00 7E
00 03 00 00 00 B5 AC ED 00 05 73 72 00 18 63
6F 6D 2E 66 6F 6F 2E 73 69 72 2E 44 6F 6D 61 69 6E 4F 62 6A 65 63 74 05 3C
E6 61 EE C4 B8 10 02 00 09 49 00 03 63 49 64
4A 00 08 64 74 67 5F 6D 73 65 63 43 00 04 65 78 65 72 44 00 01 66 4A 00 02
69 64 4A 00 02 6C 61 4A 00 02 6C 6F 4C 00 02
63 63 74 00 12 4C 6A 61 76 61 2F 6C 61 6E 67 2F 53 74 72 69 6E 67 3B 4C 00
03 73 49 64 71 00 7E 00 01 78 70 00 00 03 EC
00 00 01 1C 2F B4 A5 62 00 00 40 6F 40 00 00 00 00 00 00 00 00 00 00 00 00
04 00 00 00 00 00 00 00 01 00 00 00 00 00 00
00 01 74 00 02 45 45 71 00 7E 00 03)
        at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:165)
        at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
        at
org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
        at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:6
48)
        at
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220)
        ... 5 more
Caused by: org.apache.mina.common.BufferDataException: java.io.EOFException
        at org.apache.mina.common.ByteBuffer.getObject(ByteBuffer.java:1539)
        at
org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.jav
a:92)
        at
org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:133)
        at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:158)
        ... 9 more
Caused by: java.io.EOFException
        at
java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
        at
java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:3019)
        at
java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2820)
        at java.io.ObjectInputStream.readUTF(ObjectInputStream.java:1051)
        at
java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:616)
        at
java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:809)
        at
org.apache.mina.common.ByteBuffer$3.readClassDescriptor(ByteBuffer.java:1515)
        at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1565)
        at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
        at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
        at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at org.apache.mina.common.ByteBuffer.getObject(ByteBuffer.java:1537)
        ... 12 more

Here's my CamelContext
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd";>

  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring";>
    <package>com.foo.sir</package>
  </camelContext>

 <!-- 
  <bean name="lcf" class="com.foo.sir.LengthCodecFactory">
  </bean>
-->

</beans>

Here's my endpoint config
    public void configure() {


        from("mina:tcp://localhost:9860?codec=lcf").process(new Processor()
{
                public void process(Exchange exchange) throws Exception {
                        byte[] body =
exchange.getIn().getBody(byte[].class);
                        ByteArrayInputStream bais = new
ByteArrayInputStream(body);
                        ObjectInputStream ois = new ObjectInputStream(bais);
                        DomainObject d = (DomainObject) ois.readObject();
                        System.out.println("Got a Domain Object " +
d.toString());
                }
        });

What am I doing wrong?  (Besides posting huge chunks of error output to the
forum?)
Cheers
Conrad

-- 
View this message in context: 
http://www.nabble.com/Camel-won%27t-invoke-my-custom-MINA-codec-tp19322279s22882p19322279.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to