分享一个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();
}
}
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();
}
}
相关文章推荐
- 关于C#更新Access数据库时发现的一个没有任何技术含量的问题,给大家分享,希望能给大家帮助
- java工程项目里,在一个包里面,不能出现同名的类名,这问题是刚接触java才会遇到的,特别是新手一般都没有建立包,而是使用默认的,易出现同名的类名,导致eclipse提示错误
- ant classpath导致的问题
- java工程项目里,在一个包里面,不能出现同名的类名,这问题是刚接触java才会遇到的,特别是新手一般都没有建立包,而是使用默认的,易出现同名的类名,导致eclipse提示错误
- gcc和MinGW的异同(在cygwin/gcc做的东西可以无缝的用在linux下,没有任何问题,是在windows下开发linux程序的一个很好的选择)
- java工程项目里,在一个包里面,不能出现同名的类名,这问题是刚接触java才会遇到的,特别是新手一般都没有建立包,而是使用默认的,易出现同名的类名,导致eclipse提示错误
- "java.lang.NoClassDefFoundError"错误——一个关于classpath设置的问题
- [tomcat服务器启动SSM项目时问题]class path resource [smvc_servlet.xml] cannot be opened because it……
- mysql 5.7目录下没有data目录导致报“服务没有报告任何错误”问题
- mybatis--maven默认不会将java下xml文件打包至classpath导致的问题
- 分享一个经验,Servlet和Struts共存问题
- 很恶心的一个问题,百度没找到You appear to have guava-jdk5 on your project buildScript or buildSrc classpath
- 分享一个 变量没有初始化 可能带来的问题
- PATH路径出错导致任何命令都找不到解决方法
- IDEA 中 maven 项目依赖没有自动 add class path的问题
- wiki moinmoin1.9.7 一个问题,用户登录后任何预览都要出错,不知何因。
- 学习Java的第一步是安装好JDK,写一个Hello World, 其实JDK的学习没有那么简单,关于JDK有两个问题是很容易一直困扰Java程序员的地方:一个是CLASSPATH的问题,其实从原理上来说,是要搞清楚JRE的ClassLoader是如何加
- startx后没有进入xwindows的问题(xfs没有启动导致的出错信息)
- 编码问题导致python脚本运行时出错: 没有那个文件或目录
- 太郁闷了,新建项目的时候不小心改了一个地方,导致已用到java类或者servlet 就出错!