Retrieve external webpage from Openshift war application?

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

Hi,

I'm new to Openshift and trying to deploy a war-application on JBossAS that will periodically "scrape" some information from external webpages and save in database.

I'm doing, like:

 org.apache.commons.httpclient.HttpClient httpClient = new HttpClient();
 HttpMethod httpMethod = new GetMethod(url);
 httpClient.executeMethod(httpMethod);

to access external URLs, and it works OK to access arbitrary URLs when I run it from my local Windows-machine.

But in Openshift, the call to

 httpClient.executeMethod(httpMethod)

throws

 java.net.BindException: Permission denied

Does this mean it is forbidden to access external URLs from Openshift?

Or is there a solution for this?

Thanks, /RP

Here's a forum thread related to your issue that has some suggestions:
https://www.openshift.com/forums/openshift/commons-httpclient-permission-denied

Please review it to see if it helps.

Thanks Nam, I got it working now.

Solution I chose was to upgrade from

		<dependency> 
			<groupId>org.apache.geronimo.bundles</groupId>
			<artifactId>commons-httpclient</artifactId>
			<version>3.1_2</version>
		</dependency>

to

		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.2.5</version>
		</dependency>

This required rewriting the java-code, since these version are not compatible, but use quite different API/programming-model and different java-packages.

Nice! Thanks for the details to your solution! This is going on my blog.