This is primarily for the record, though being new to Jython/Python,
I'd be interested in any comments anyone has with respect to
development & debugging environments/techniques...
I was just developing a basic test using jython, as shown below,
when I started having problems!
self.host = "localhost"
self.port = '7001'
self.httpConnection = httplib.HTTPConnection(self.host, self.port)
response = self.httpConnection.getresponse()
text = response.read()
if __name__ == "__main__":
runner = unittest.TextTestRunner()
When I ran this through Python I had no problems, but as I intended
to try & capture the message that the server posted to a JMS queue, I
wanted to run this under Jython, but that gave me traceback, as
Traceback (most recent call last):
File "ExampleTest.py", line 14, in runTest
File "D:\Java\Jython\Lib\httplib.py", line 508, in request
self._send_request(method, url, body, headers)
File "D:\Java\Jython\Lib\httplib.py", line 517, in _send_request
File "D:\Java\Jython\Lib\httplib.py", line 437, in putrequest
File "D:\Java\Jython\Lib\httplib.py", line 379, in send
File "D:\Java\Jython\Lib\httplib.py", line 363, in connect
File "D:\Java\Jython\Lib\socket.py", line 135, in connect
TypeError: java.net.Socket(): 1st arg can't be coerced to String or java.net.InetAddress
I had a hunt around for any easy way of debugging the Jython code,
but ended up having to just add print statements to try & see what was
going on... Tried creating by hand the 'host' as a java.lang.String,
to no effect, and was starting to wonder if there was any way I could
use Python to read JMS messages when I noticed in the socket.py that
if the 'host' was "", then the code itself got the localhost address,
so I tried that.
That then made things much clearer, as the new error message was
"TypeError: java.net.Socket(): 2nd arg can't be coerced to int".
As soon as I changed my "self.port = '7001'" to "self.port = 7001"
then all was well and I could get on with developing the rest of the