This discussion is archived
1 Reply Latest reply: Mar 6, 2012 2:22 AM by EJP RSS

Could not connect over HTTP to server

883037 Newbie
Currently Being Moderated
when I run the integrated weblogic in Developer, it can work fine. But after I deployed this application on weblogic server(10.3.5), it throw a exception: Tried all: '1' addresses, but could not connect over HTTP to server: 'myknowledge.fdsm.fudan.edu.cn', port: '80'. Pls refer to the following source code:
public class CommunityJSONDataConveter {
private static Logger logger = LoggerFactory.getLogger(CommunityJSONDataConveter.class);
private static String url = PropertyHelper.getValueByKey("COMMUNITY_RECOMMEND_URL");
public CommunityJSONDataConveter() {
super();
}

public List<CommunityRecommendItem> getCommunityRecommendItems(){
URL url;
String inputline="";
String info="";
List<CommunityRecommendItem> items = null;
try {
url = new URL(this.url);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setReadTimeout(10*1000);
conn.setRequestMethod("GET");
InputStreamReader inStream = new InputStreamReader(conn.getInputStream(),"UTF-8");
BufferedReader buffer=new BufferedReader(inStream);
while( (inputline=buffer.readLine())!=null){
info+=inputline;
}
inStream.close();
} catch (ProtocolException e) {
logger.error("Get Community Data from the specified url throw ProtocolException=" + e.getMessage());
return Collections.emptyList();

} catch (MalformedURLException e) {
logger.error("Get Community Data from the specified url throw MalformedURLException=" + e.getMessage());
return Collections.emptyList();

} catch (IOException e) {
logger.error("Get Community Data from the specified url throw IOException=" + e.getMessage());
return Collections.emptyList();
}
JSONArray jsonob = JSONArray.fromObject(info);
if (jsonob != null && jsonob.size() > 0){
items = new ArrayList<CommunityRecommendItem>();
for(int i=0;i<jsonob.size();i++){  
String index =jsonob.getJSONObject(i).getString("index");
String title = jsonob.getJSONObject(i).getString("title");
String url1 = jsonob.getJSONObject(i).getString("url");
CommunityRecommendItem item = new CommunityRecommendItem();
try{
item.setIndex(Integer.parseInt(index));
} catch(NumberFormatException e){
item.setIndex(0);
}
item.setTitle(title);
item.setUrl(url1);
items.add(item);

}
}
return items;
}
}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points