HTTPClientSession.sendRequest(request) throws NullException

Please post support and help requests here.
Posts: 1
Joined: 24 Feb 2009, 12:27

HTTPClientSession.sendRequest(request) throws NullException

Postby Wouterke » 24 Feb 2009, 14:22

I'm trying to connect to Google Apps using this code (Google Apps requires a HTTPS connection to log in):

Code: Select all

   URI uri("");
   string path = uri.getPathAndQuery();
   HTTPSClientSession session(uri.getHost(), uri.getPort());
   HTTPRequest request(HTTPRequest::HTTP_POST, path ); //, HTTPMessage::HTTP_1_1);
   request.setContentType("text/xml; charset=\"iso-8859-1\"");
   HTMLForm form (request);
   form.set("accountType", "HOSTED_OR_GOOGLE");
   form.set("Email", username);
   form.set("Passwd", password);
   form.set("service", "xapi");
   form.set("source", GDataSource);

   stringstream data;
   form.write(data, HTMLForm::ENCODING_URL);

   ostream &out = session.sendRequest(request);

   HTTPResponse response;
   istream& rs = session.receiveResponse(response);

This compiles, but it throws this exception at runtime:

Code: Select all

100             ostream &out = session.sendRequest(request);

NULL pointer: _pInstance [in file "/home/danchev/download/debian/poco-1.3.2+dfsg1/Util/include/Poco/Util/Application.h", line 422]
terminate called after throwing an instance of 'Poco::NullPointerException'
  what():  Null pointer

However, if I use a HTTPClientSession instead of a HTTPSClientSession object. This code works perfect.
I' using Poco version 1.3.2+dfsg1 (default debian Lenny), and every component is installed.
Is there any more work to set up an SSL connection i'm not doing?

Thanks in advance

EDIT: incuding backtrace

Code: Select all

(gdb) bt
#0  0xb7f1c424 in __kernel_vsyscall ()
#1  0xb7993640 in raise () from /lib/i686/cmov/
#2  0xb7995018 in abort () from /lib/i686/cmov/
#3  0xb7bb1988 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/
#4  0xb7baf865 in ?? () from /usr/lib/
#5  0xb7baf8a2 in std::terminate () from /usr/lib/
#6  0xb7baf95b in __cxa_rethrow () from /usr/lib/
#7  0xb7c1b546 in Poco::Net::SecureSocketImpl::connect (this=0x80ed698, address=@0xbff378e8, timeout=@0xbff37b80) at src/SecureSocketImpl.cpp:215
#8  0xb7c1d5f6 in Poco::Net::SecureStreamSocketImpl::connect (this=0x80ed670, address=@0xbff378e8, timeout=@0xbff37b80)
    at src/SecureStreamSocketImpl.cpp:75
#9  0xb7cc53dd in Poco::Net::StreamSocket::connect (this=0xbff37b68, address=@0xbff378e8, timeout=@0xbff37b80) at src/StreamSocket.cpp:97
#10 0xb7cdd6e3 in Poco::Net::HTTPSession::connect (this=0xbff37b64, address=@0xbff378e8) at src/HTTPSession.cpp:191
---Type <return> to continue, or q <return> to quit---
#11 0xb7c10590 in Poco::Net::HTTPSClientSession::connect (this=0xbff37b64, address=@0xbff378e8) at src/HTTPSClientSession.cpp:104
#12 0xb7cc022a in Poco::Net::HTTPClientSession::reconnect (this=0xbff37b64) at src/HTTPClientSession.cpp:289
#13 0xb7cc0957 in Poco::Net::HTTPClientSession::sendRequest (this=0xbff37b64, request=@0xbff37c10) at src/HTTPClientSession.cpp:184
#14 0x08049fa6 in main () at apps.cpp:101

Posts: 1184
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: HTTPClientSession.sendRequest(request) throws NullException

Postby guenter » 24 Feb 2009, 19:05

When you use HTTPSClientSession, or any other NetSSL classes, you must setup an SSL context first (class Poco::Net::Context in NetSSL). The simplest way to do this is by using the SSLManager class to automatically set up a context. However, this requires that your program uses the Application class from the Util library, as SSLManager uses the Application class to read a configuration file containing essential OpenSSL parameters. See the HTTPSTimeServer sample in the NetSSL_OpenSSL/samples directory for an example.
Alternatively, you can setup a Context yourself. See the download sample source code in NetSSL_OpenSSL/samples for how to do this.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests