I'm running on Red Hat Linux 3 and using g++ compiler.

Here is the C++ code that I'm running (it's taken from the
HelloWorldProducer example from activemq-cpp). The line in bold is causing
the NullPointerException in ActiveMQ.

        cms::Connection* connection;
        Session* session;
        Destination* destination;
        MessageProducer* producer;
        int numMessages;
        bool useTopic = false;
        std::string brokerURI = "tcp://localhost:61616?wireFormat=openwire";
                
        try {
            // Create a ConnectionFactory
            ActiveMQConnectionFactory* connectionFactory =
                new ActiveMQConnectionFactory();
            connectionFactory->setBrokerURL( brokerURI );
                        
                        
            // Create a Connection
            connection = connectionFactory->createConnection();
            connection->start();

            // free the factory, we are done with it.
            delete connectionFactory;

            // Create a Session
            session = connection->createSession( Session::AUTO_ACKNOWLEDGE
);

            // Create the destination (Topic or Queue)
            if( useTopic ) {
                destination = session->createTopic( "TEST.FOO" );
            } else {
                destination = session->createQueue( "TEST.FOO" );
            }
                        
            // Create a MessageProducer from the Session to the Topic or
Queue
            producer = session->createProducer( destination );
            producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );

            // Create the Thread Id String
            string threadIdStr = Integer::toString(
activemq::concurrent::Thread::getId() );

            // Create a messages
            string text = (string)"Hello world! from thread ";
                        
           for( int ix=0; ix<1; ix++ ){
                TextMessage* message = session->createTextMessage( text );

                message->setIntProperty( "Integer", ix );

                // Tell the producer to send the message
                printf( "Sent message #%d from thread %s\n", ix,
threadIdStr.c_str() );
                producer->send( message );
                                
                delete message;
            }

        }catch ( CMSException& e ) {
            e.printStackTrace();
        }


Tim Bish wrote:
> 
> Could you provide the C++ code?  Also what platform and compiler?
> 
> Rob Davies wrote:
>> the c++ code must be passing in a null value for the destination name
>>
>> On Jul 21, 2007, at 4:16 PM, seamuskerrigan wrote:
>>
>>>
>>> I have succesfully set-up and ran the activemq-cpp example. However, 
>>> when I
>>> try integrating the HelloWorldProducer into an existing C++ process, 
>>> I've
>>> been running into problems creating the TEST.FOO queue. I have tested 
>>> this
>>> using ActiveMQ 4.1.1 and 5.0 on Red Hat Linux with the same exception.
>>>
>>> I have started ActiveMQ succesfully and connect to
>>> "tcp://localhost:61616?wireFormat=openwire". But when the C++ code 
>>> attemps
>>> the queue creation of TEST.FOO, I get the following exception in the
>>> ActiveMQ console window (using 5.0):
>>>
>>> Exception in thread "ActiveMQ Transport: tcp:///localhost:49120"
>>> java.lang.NullPointerException
>>>         at
>>> org.apache.activemq.command.ActiveMQDestination.setPhysicalName(ActiveMQDestination.java:204)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.v2.ActiveMQDestinationMarshaller.looseUnmarshal(ActiveMQDestinationMarshaller.java:98)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.v2.ActiveMQQueueMarshaller.looseUnmarshal(ActiveMQQueueMarshaller.java:101)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.OpenWireFormat.looseUnmarshalNestedObject(OpenWireFormat.java:450)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.v2.BaseDataStreamMarshaller.looseUnmarsalCachedObject(BaseDataStreamMarshaller.java:454)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.v2.ProducerInfoMarshaller.looseUnmarshal(ProducerInfoMarshaller.java:134)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.OpenWireFormat.doUnmarshal(OpenWireFormat.java:351)
>>>  
>>>
>>>         at
>>> org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:275)
>>>  
>>>
>>>         at
>>> org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:156)
>>>  
>>>
>>>         at
>>> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:136) 
>>>
>>>         at java.lang.Thread.run(Thread.java:595)
>>>
>>>
>>> The port number in the above trace is 49120 but this varies between 
>>> runs of
>>> ActiveMQ.
>>>
>>> The executing C++ reports the following exception:
>>> free(): invalid pointer 0xb54ca26c!
>>> response from futureResponse was invalid
>>>         FILE: activemq/transport/ResponseCorrelator.cpp, LINE: 145
>>>         FILE: activemq/transport/ResponseCorrelator.cpp, LINE: 152
>>>         FILE: activemq/connector/openwire/OpenWireFormatNegotiator.cpp,
>>> LINE: 105
>>>         FILE: activemq/connector/openwire/OpenWireConnector.cpp, 
>>> LINE: 1468
>>>         FILE: activemq/connector/openwire/OpenWireConnector.cpp, 
>>> LINE: 757
>>>         FILE: activemq/core/ActiveMQSession.cpp, LINE: 376
>>>
>>>
>>> I'm not sure what is causing this issue. Any help would be appreciated.
>>>
>>> -- 
>>> View this message in context: 
>>> http://www.nabble.com/NullPointerException-from-ActiveMQDestination-tf4122144s2354.html#a11723114
>>>  
>>>
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/NullPointerException-from-ActiveMQDestination-tf4122144s2354.html#a11740179
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to