[ 
https://issues.apache.org/jira/browse/DIRMINA-684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12709411#action_12709411
 ] 

David Rosenstrauch edited comment on DIRMINA-684 at 5/14/09 7:27 AM:
---------------------------------------------------------------------

> A second look make me thing that the problem is not in the user code, as the 
> NPE might be generated by the encoder being null on line 297 :
>
> encoder.encode(session, message, encoderOut); 

Problem's clearly not in user code - just look at the stack trace:  none of my 
code is in the stack.  But also because the NPE is clearly occurring in MINA 
framework code objects.

In any case, I don't think I'm going to be able to retest this after the fix, 
as my code has since changed and no longer triggers the error condition.  
(Which was intermittent anyway.)

Hopefully the OrderedThreadPoolExecutor fix will clear up the problem.

Thanks for looking into this though.

      was (Author: darose):
    A second look make me thing that the problem is not in the user code, as 
the NPE might be generated by the encoder being null on line 297 :

encoder.encode(session, message, encoderOut);> A second look make me thing that 
the problem is not in the user code, as the NPE might be generated by the 
encoder being null on line 297 :
>
> encoder.encode(session, message, encoderOut); 

Problem's clearly not in user code - just look at the stack trace:  none of my 
code is in the stack.  But also because the NPE is clearly occurring in MINA 
framework code objects.

In any case, I don't think I'm going to be able to retest this after the fix, 
as my code has since changed and no longer triggers the error condition.  
(Which was intermittent anyway.)

Hopefully the OrderedThreadPoolExecutor fix will clear up the problem.

Thanks for looking into this though.
  
> NullPointerException when opening socket to localhost
> -----------------------------------------------------
>
>                 Key: DIRMINA-684
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-684
>             Project: MINA
>          Issue Type: Bug
>    Affects Versions: 2.0.0-M5
>         Environment: Linux
>            Reporter: David Rosenstrauch
>            Priority: Minor
>             Fix For: 2.0.0-RC1
>
>
> 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 NullPointerExceptions intermittently.
> 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
> Or sometimes 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 
> 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
> * I'm 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); 
> I actually did find a way to "fix" this problem but someone on the mailing 
> list suggested that MINA shouldn't be throwing NPE's regardless.  Fix is as 
> follows:   I was originally just dropping the connection on the client side 
> when I was finished.  But after changing my code to issue a proper "close 
> connection" command to the server before disconnecting, it looks like the 
> NPE's go away. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to