Java项目在Tomcat下能运行,到WAS上不能运行原因查找
来源:互联网 发布:washington post 知乎 编辑:程序博客网 时间:2024/06/06 09:45
0、分析原因:一般都是jar包冲突
1、定位错误:发布到WAS上定位错误的位置,找到哪行代码报的错误
找到错误位置为 Scheme sch = new Scheme("https", 443, sf);
即Scheme 所在的包产生冲突
2、Tomcat控制台输出:找到报错代码行,在控制台输出该行用的类所引用的jar包
//打印Scheme 所引用的Jar包
String jarFilePath = Scheme.class.getProtectionDomain().getCodeSource().getLocation().getFile();
jarFilePath = java.net.URLDecoder.decode(jarFilePath, "UTF-8");
System.out.println("+++++++++++++++++++++++++++++++"+jarFilePath);
Scheme sch = new Scheme("https", 443, sf);
3、WAS输出:放到WAS上运行输出。
在Tomcat下,控制台输出为
/D:/Workspaces/MyEclipse Blue Edition 10/Binding/WebRoot/WEB-INF/lib/httpclient-4.3.3.jar
找到在WAS上该类解析的日志输出
/wasHome/IBM/WebSphere/AppServer/plugins/com.ibm.ws.prereq.jaxrs.jar
4、方法2
package test;import java.io.IOException;import java.io.PrintWriter;import java.security.CodeSource;import java.security.ProtectionDomain;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.commons.httpclient.Cookie;import org.apache.http.HttpResponse;import org.apache.http.impl.client.DefaultHttpClient;public class TestServlet extends HttpServlet { /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); ProtectionDomain pd1 = DefaultHttpClient.class.getProtectionDomain(); CodeSource cs1 = pd1.getCodeSource(); ProtectionDomain pd2 = HttpResponse.class.getProtectionDomain(); CodeSource cs2 = pd2.getCodeSource(); ProtectionDomain pd3 = Cookie.class.getProtectionDomain(); CodeSource cs3 = pd3.getCodeSource(); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" <BODY>"); out.print(" DefaultHttpClient类 导入为httpclient包,运行时JAR包是 >>>>>> "); out.print(cs1.getLocation()); out.print("<br/>"); out.print(" HttpResponse类 导入为httpcore 包 引用的 JAR包是>>>>>> "); out.print(cs2.getLocation()); out.print("<br/>"); out.print(" Cookie类 导入为commons-httpclient 包 引用的 JAR包是>>>>>> "); out.print(cs3.getLocation()); out.print("<br/>"); out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); }}
- Java项目在Tomcat下能运行,到WAS上不能运行原因查找
- SSH项目部署到tomcatx能运行而之前的版本不能运行的原因
- JAVA程序在eclipse下可运行但不能在cmd命令下运行的原因
- php项目运行到tomcat上
- vue项目打包到tomcat下运行
- java web工程打成war包,部署到Linux tomcat上,运行失败的可能原因。
- VS2005 debug能运行release不能运行原因集
- 在cmd下运行java不能通过
- java项目发布到Linux上运行
- 项目在eclipse运行正常,但单独部署到tomcat上出现乱码解决办法
- 项目在eclipse运行正常,但单独部署到tomcat上不正常
- 项目在eclipse运行正常,但单独部署到tomcat上出现乱码解决办法
- 在tomcat下运行java代码
- 项目在tomcat部署成功,运行却报404错误,把所有文件复制到一个新的项目却能运行,后来又开始404.。。。
- java 项目部署到tomcat上运行两次报内存溢出
- 【再次求助】亲和数,在自己机子上能运行,在OJ平台上不能通过
- 在Idea下运行Tomcat无法加载项目到容器中
- RMI 程序能在 Windows 上运行,却在 Linux 上报错的一个原因
- hdu-oj 1425
- HDOJ 题目1083Courses(二分图匹配,匈牙利算法模板)
- fsl系统烧写工具MFGTool2工具详解
- C++第二十二天命名空间
- swf swc swz RSLs ant
- Java项目在Tomcat下能运行,到WAS上不能运行原因查找
- Exclusive or
- tcp ack 处理注释分析
- 易语言让我东山再起----邓学彬——————【Badboy】
- 2014 Multi-University Training Contest 8 1007 hdu 4951 Multiplication table
- ZOJ 2562 More Divisors(高合成数)
- Very Brief Introduction to Machine Learning for AI
- sql server 字符串中含有数字的分割
- Maven的使用