You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Jan K (JIRA)" <ji...@apache.org> on 2007/02/06 20:49:02 UTC

[jira] Created: (AMQ-1155) "Object reference not set to an instance of an object." exception when closing connection.

"Object reference not set to an instance of an object." exception when closing connection.
------------------------------------------------------------------------------------------

                 Key: AMQ-1155
                 URL: https://issues.apache.org/activemq/browse/AMQ-1155
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker, NMS (C# client)
    Affects Versions: 4.1.0
         Environment: WINXP SP2 
            Reporter: Jan K


   at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
   at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
   at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
   at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
   at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

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


[jira] Moved: (AMQNET-21) "Object reference not set to an instance of an object." exception when closing connection.

Posted by "james strachan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQNET-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

james strachan moved AMQ-1155 to AMQNET-21:
-------------------------------------------

        Fix Version/s: 1.0
          Component/s:     (was: Broker)
                           (was: NMS (C# client))
    Affects Version/s:     (was: 4.1.0)
                  Key: AMQNET-21  (was: AMQ-1155)
              Project: ActiveMQ .Net  (was: ActiveMQ)

> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-21
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-21
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>         Environment: WINXP SP2 
>            Reporter: Jan K
>             Fix For: 1.0
>
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

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


[jira] Commented: (AMQNET-21) "Object reference not set to an instance of an object." exception when closing connection.

Posted by "james strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQNET-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38610 ] 

james strachan commented on AMQNET-21:
--------------------------------------

Jan K: you can use the wiki notation from confluence in comments. e.g. for code you can do \{code\} around blocks of code. e.g.

{code}
if (foo) { 
  doSomething();
}
{code}

> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-21
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-21
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>         Environment: WINXP SP2 
>            Reporter: Jan K
>             Fix For: 1.0
>
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

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


[jira] Resolved: (AMQNET-21) "Object reference not set to an instance of an object." exception when closing connection.

Posted by "james strachan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQNET-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

james strachan resolved AMQNET-21.
----------------------------------

    Resolution: Fixed

Patch applied with thanks.

Dennis, there have been some issues inthe ActiveMQ broker with not cleaning down connections nicely which have now been resolved in 4.1.0 and a couple more in 4.1.1

> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-21
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-21
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>         Environment: WINXP SP2 
>            Reporter: Jan K
>             Fix For: 1.0
>
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

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


[jira] Commented: (AMQ-1155) "Object reference not set to an instance of an object." exception when closing connection.

Posted by "Jan K (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38476 ] 

Jan K commented on AMQ-1155:
----------------------------

Ouch! The formmating! Its too bad you can't edit your comments... I should have used the preview. 
try
\{ 
   if (command != null)   //<---To prevent an exception when the command is null  
        this.commandHandler(this, command); 
\} 


> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQ-1155
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1155
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, NMS (C# client)
>    Affects Versions: 4.1.0
>         Environment: WINXP SP2 
>            Reporter: Jan K
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

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


[jira] Commented: (AMQ-1155) "Object reference not set to an instance of an object." exception when closing connection.

Posted by "Dennis Loktionov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38480 ] 

Dennis Loktionov commented on AMQ-1155:
---------------------------------------

Adding the if-statement helps, there is no exception being thrown anymore, but there is another problem: connection is not properly disposed.
I was monitoring ActiveMQ broker in JConsole running example given on the NMS webpage on the ActiveMQ website, the Connection is still registered in JConsole after the code is executed. 
I tried to call Dispose() and Close() methods on the connection object, but that didn't help.

> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQ-1155
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1155
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, NMS (C# client)
>    Affects Versions: 4.1.0
>         Environment: WINXP SP2 
>            Reporter: Jan K
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

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


[jira] Commented: (AMQ-1155) "Object reference not set to an instance of an object." exception when closing connection.

Posted by "Jan K (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38475 ] 

Jan K commented on AMQ-1155:
----------------------------

I wanted to provide more information in the description, but it was too late after the "Create" button. 

When the ActiveMQ connection is being closed, on line 133 in Connection.cs we call  transport.Dispose();. That calls the Close method in TcpTransport.cs : 

        public void Close()
        {
            if (closed.compareAndSet(false, true))
            {
                socket.Close();
                if (System.Threading.Thread.CurrentThread != readThread)
                    readThread.Join();   //<--- exception is occuring here 
                socketWriter.Close();
                socketReader.Close();
            }
        }

As can be seen from the StackTrace above (in the description), the exception is occuring in ReadLoop. The line that is failing is :
                try
                {
                    this.commandHandler(this, command);   //<-- the command is null and this generates the exception
                }


As I understand this, by the time that transport.Dispose() is called (on line 133 in Connection.cs) , we have already closed the session and the connection to the broker. So, when command = (Command) Wireformat.Unmarshal(socketReader) is called (on line 131 in TcpTransport.cs) the command is returned as null but no exception is generated by the Unmarshall call.

My suggestion is to change the code to
                try
                { 
	if (command != null)  //<--- To prevent an exception when the command is null
	         this.commandHandler(this, command);
                }



> "Object reference not set to an instance of an object." exception when closing connection.
> ------------------------------------------------------------------------------------------
>
>                 Key: AMQ-1155
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1155
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, NMS (C# client)
>    Affects Versions: 4.1.0
>         Environment: WINXP SP2 
>            Reporter: Jan K
>
>    at ActiveMQ.TestMain.connection_ExceptionListener(Exception exception) in D:\activemq-dotnet\src\test\csharp\ActiveMQ\TestMain.cs:line 80
>    at ActiveMQ.Connection.OnException(ITransport sender, Exception exception) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Connection.cs:line 334
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.TransportFilter.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\TransportFilter.cs:line 44
>    at ActiveMQ.Transport.WireFormatNegotiator.OnException(ITransport sender, Exception command) in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\WireFormatNegotiator.cs:line 102
>    at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in D:\activemq-dotnet\src\main\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 150
>    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>    at System.Threading.ThreadHelper.ThreadStart()

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