mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@darose.net>
Subject Re: Odd Mina NPE
Date Tue, 07 Apr 2009 19:11:53 GMT
Hmmm .... I think I might have fixed it.

I was just dropping the connection on the client side when I was 
finished.  I changed it to issue a proper "close connection" command to 
the server and it looks like the problem's gone away.

DR

David Rosenstrauch wrote:
> And another similar error as well:
> 
> SEVERE: Error occurred during message handling
> org.apache.mina.filter.codec.ProtocolDecoderException: 
> java.lang.NullPointerException (Hexdump: 68 65 6C 70 0A 73 74 61 74 73 
> 0A 71 75 65 72 79 20 31 32 33 34 0A)
>     at 
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:234)

> 
>     at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)

> 
>     at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:48)

> 
>     at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:802)

> 
>     at 
> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:59)
>     at org.apache.mina.core.session.IoEvent.run(IoEvent.java:64)
>     at 
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:552)

> 
>     at 
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:544)

> 
>     at 
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:488)

> 
>     at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException
>     at 
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:224)

> 
>     ... 9 more
> 
> Thanks,
> 
> DR
> 
> David Rosenstrauch wrote:
>> Having a strange situation happening.
>>
>> I have a MINA-based server I've written that's up and running and 
>> works fine.  I recently added a new bit of functionality to it, 
>> however, and it's now throwing a NPE.
>>
>> The server uses a text-based protocol (using TextLineCodecFactory). 
>> I've added the capability to give the server a command line parm which 
>> is the name of a text file, containing startup commands that the 
>> server should execute after it starts up.  I'm doing this by having 
>> the server open a java socket to the server's port on localhost, read 
>> the text file and write (and flush) each command out to the socket.
>>
>> This is generally working, and the server is receiving and processing 
>> each command (not always in the order sent, but I'm guessing that's an 
>> outgrowth of my using a thread pool, and that's not a problem anyway). 
>> But from time to time, the server is spitting out this error:
>>
>> SEVERE: EXCEPTION :
>> org.apache.mina.filter.codec.ProtocolEncoderException: 
>> java.lang.NullPointerException
>>     at 
>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:312)

>>
>>     at 
>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:506)

>>
>>     at 
>> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1400(DefaultIoFilterChain.java:48)

>>
>>     at 
>> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:814)

>>
>>     at 
>> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:65) 
>>
>>     at org.apache.mina.core.session.IoEvent.run(IoEvent.java:64)
>>     at 
>> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:552)

>>
>>     at 
>> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:544)

>>
>>     at 
>> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:488)

>>
>>     at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.NullPointerException
>>     at 
>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:297)

>>
>>     ... 9 more
>>
>>
>> Noteworthy aspects of my configuration:
>>
>> * using the M4 release of MINA
>>
>> * I'm not pausing between sending commands; i.e., I'm write and 
>> flushing them down the socket as quickly as Java can send them
>>
>> * using both a read and a write thread pool
>>
>> * building my filter chain as follows:
>>     protocolAcceptor = new NioSocketAcceptor();
>>     protocolAcceptor.setDefaultLocalAddress(new 
>> InetSocketAddress(protocolPort));
>>     protocolAcceptor.setReuseAddress(true);
>>     DefaultIoFilterChainBuilder filterChainBuilder = 
>> protocolAcceptor.getFilterChain();
>>     filterChainBuilder.addLast("logger", new 
>> LoggingFilter(ProfileCacheServer.class));
>>     readerThreadPool = new OrderedThreadPoolExecutor();
>>     filterChainBuilder.addLast("readExecutor", new 
>> ExecutorFilter(readerThreadPool, IoEventType.MESSAGE_RECEIVED));
>>     filterChainBuilder.addLast("codec", new ProtocolCodecFilter(new 
>> TextLineCodecFactory(ParseConstants.UTF8_CHARSET)));
>>     writerThreadPool = new OrderedThreadPoolExecutor();
>>     filterChainBuilder.addLast("writeExecutor", new 
>> ExecutorFilter(writerThreadPool, IoEventType.WRITE));
>>     protocolAcceptor.setHandler(protocolHandler);
>>
>>
>> Anyone have any idea what this error could be?  I can't understand how 
>> ProtocolCodecFilter.filterWrite could be throwing a NPE.  It's 
>> basically saying that the encoder is null, but I don't see how that 
>> could be.
>>
>> Any help appreciated!
>>
>> TIA,
>>
>> DR
>>
> 


Mime
View raw message