您的位置:首页 > 其它

分享一个CLASSPATH的问题导致SERVLET出错却没有任何log

2012-08-29 10:21 337 查看
在websphere的console http://localhost:9062/ibm/console/login.do 中environment\Shared
Libraries 中的一个ClassPath"C:\SLEWorkspace\lib\httpservice\ Httpclient\httpcore-4.2-alpha2.jar" 中不小心多了一个空格,结果导致运行这个 servlet 的 get 方法中出错却没有任何的System.out.println的输出,调试了好长时间。

public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {

System.out.println("call servlet succesfully - get method");

String url = "http://localhost:9088/UI/entitled/CommandControler";

try {

CommandControlerVO vo = new CommandControlerVO();

vo.setMessageId(1);

vo.setMessageSource("BES");

vo.setMessageSubtype("537U");

vo.setMessageType("INV");

vo.setMessageContent("content");

StringWriter xmlWriter = new StringWriter();

try {

final JAXBContext jaxbContext = JAXBContext.newInstance(CommandControlerVO.class);

jaxbContext.createMarshaller().marshal(vo, xmlWriter);

}catch(JAXBException e){

System.out.println("JAXB Exception caused "+e);

throw new RuntimeException("Error ocurred "+e);

}

System.out.println("the xml to pass " + xmlWriter.toString());

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);

nameValuePairs.add(new BasicNameValuePair("xmlData", xmlWriter.toString()));

DefaultHttpClient httpClient = new DefaultHttpClient();

HttpPost postRequest = new HttpPost(url);

postRequest.addHeader("accept", "application/json");

postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));

HttpResponse httpResponse = httpClient.execute(postRequest);

HttpEntity httpEntity = httpResponse.getEntity();

String xmlResponse = EntityUtils.toString(httpEntity);

System.out.println("response value is " + xmlResponse);

} catch (Exception e) {

e.printStackTrace();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐