我有一个Jira Rest Java客户端,它可以作为一个独立的Java应用程序运行,但是当我使用它与Tomcat服务器一起使用Maven创建一个动态Web应用程序时,它会抛出以下Stack Trace:
java.lang.ClassNotFoundException: org.springframework.beans.factory.DisposableBean
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2918)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
at ReferenceClass.ListOfProjects(ReferenceClass.java:20)
at GetProjectList.doGet(GetProjectList.java:47)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我正在使用他关注pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javarticles.webapp</groupId>
<artifactId>webappExample</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>webappExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.openengsb.wrapped</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>2.0.0-m32.w1</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openengsb.wrapped</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>2.0.0-m32.w1</version>
</dependency>
</dependencies>
<build>
<finalName>webappExample</finalName>
</build>
我的计划如下:
import java.io.IOException;
import java.net.URISyntaxException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HelloWorldServlet
*/
@WebServlet("/GetProjectList")
public class GetProjectList extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public GetProjectList() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
/*
try {
r.ListOfProjects();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
response.getWriter().write("Success111");
response.getWriter().flush();
response.getWriter().close();
ReferenceClass r = new ReferenceClass();
try {
r.ListOfProjects();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
参考类代码
public class ReferenceClass {
public ArrayList<String> ListOfProjects() throws URISyntaxException, IOException {
String username = "xxxxx";
String password = "xxxxx";
ArrayList<String> list = null ;
URI jiraserverURI = new URI("https://jira.xxxxx.com");
JiraRestClientFactory restClientfactory = new AsynchronousJiraRestClientFactory();
JiraRestClient Client = restClientfactory.createWithBasicHttpAuthentication(jiraserverURI, username,
password);
try {
Iterable<BasicProject> allproject = Client.getProjectClient().getAllProjects().claim();
list = new ArrayList<String>();
for (BasicProject project : allproject) {
list.add(project.getName());
}
System.out.println( "--------" + list);
} catch (Exception e) {
System.out.println("Exception found " + e);
}
return list;
}
}
如果有人遇到此问题,请告诉我解决方案。
答案 0 :(得分:1)
您尚未为<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Settings</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/ui-darkness/jquery-ui.css">
<style>
#wrapper {
width: 980px;
height: auto;
}
#wrapper div {
margin-top: 5px;
margin-bottom: 5px;
}
td {
padding-top: 5px;
padding-bottom: 5px;
}
#ot_col1 {
width: 20%;
}
#opt_table {
width: 100%;
}
#ret_table {
width: 70%;
}
#rt_col1 {
width: 70%
}
#kv_txt {
width: 30%;
}
#vs_txt {
width: 30%;
}
#hp_txt {
width: 100%;
}
#ws_doc_txt {
width: 100%;
}
#ws_end_txt {
width: 100%;
}
#ws_ns_txt {
width: 100%;
}
#ws_op_txt {
width: 50%;
}
#ws_par_txt {
width: 50%;
}
#ws_val_txt {
width: 50%;
}
#left_col {
float: left;
width: 480px;
padding: 0 0 0 0;
}
#right_col {
margin: 0 0 0 500px;
padding: 0 0 0 0;
text-align: left;
}
textarea {
resize:none;
width: 100%;
height: 100%;
}
#button1 {
margin-top: 20px;
margin-bottom: 20px;
}
.greentxt {
color: green;
}
.redtxt {
color: red;
}
.vert_al {
vertical-align:bottom;
}
#status {
font-style:bold;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="left_col">
<fieldset><legend>Connection pconfiguration</legend>
<div>
<label>
<input type="radio" name="ws_type" value="WSDL" id="ws_type_0">WSDL</label>
<label>
<input type="radio" name="ws_type" value="NOWSDL" id="ws_type_1">Endpoint</label>
</div>
<div>
<table id="opt_table">
<tr id="ws_doc">
<td><label for="ws_doc">Document:</label></td>
<td><input type="text" name="ws_doc" id="ws_doc_txt">
</tr>
<tr id="ws_end">
<td><label for="ws_end">Endpoint:</label></td>
<td><input type="text" name="ws_end" id="ws_end_txt">
</tr>
<tr id="ws_ns">
<td><label for="ws_ns">Namespace:</label></td>
<td><input type="text" name="ws_ns" id="ws_ns_txt"></td>
</tr>
<tr id="ws_op">
<td id="ot_col1"><label for="ws_op">Operation:</label></td>
<td><input type="text" name="ws_op" id="ws_op_txt"></td>
</tr>
<tr id="ws_par">
<td><label for="ws_par">Parameter:</label></td>
<td><input type="text" name="ws_par" id="ws_par_txt"></td>
</tr>
<tr id="ws_val">
<td><label for="ws_val">Value:</label></td>
<td><input type="text" name="ws_val" id="ws_val_txt"></td>
</tr>
</table>
</div>
</fieldset>
<div>
<input type="submit" name="test" value="Test" class="vert_al">
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
<img class="vert_al" src="../Desktop/arrow_anim_left.gif" width="48" height="36" alt=""/>
</div>
<fieldset><legend>Return type</legend>
<div>
<label>
<input type="radio" name="ret_type" value="STRING" id="ret_type_0">String</label>
<label>
<input type="radio" name="ret_type" value="LIST" id="ret_type_1">List</label>
</div>
<div>
<table id="ret_table">
<tr id="kv">
<td id="rt_col1"><label for="kv">Key-value pair separator:</label></td>
<td><input type="text" name="kv" id="kv_txt">
</tr>
<tr id="vs">
<td><label for="vs">Value assignment symbol:</label></td>
<td><input type="text" name="vs" id="vs_txt">
</tr>
<tr id="hp">
<td><label for="hp">Hash path:</label></td>
<td><input type="text" name="hp" id="hp_txt"></td>
</tr>
</table>
</div>
</fieldset>
</div>
<div id="right_col"><span id="status">Status:</span><span id="err_resp"></span>
<div id="textarea1">
<textarea readonly="readonly" id="response"></textarea>
</div>
</div>
</div> <!--wrapper div-->
<script>
$(document).ready( function() {
$("*").addClass("ui-corner-all ui-widget");
$("input[type=submit]").button();
$("#ws_type_0").prop('checked','checked');
$("#ret_type_0").prop('checked','checked');
$("#ws_end").hide();
$("#ws_ns").hide();
$("#hp").hide();
$("input[name=ws_type]").on('change', function() {
if($(this).val()=="NOWSDL") {
$("#ws_end").show();
$("#ws_ns").show();
$("#ws_doc").hide();
}
else if($(this).val()=="WSDL") {
$("#ws_end").hide();
$("#ws_ns").hide();
$("#ws_doc").show();
}
});
$("input[name=ret_type]").on('change', function() {
if($(this).val()=="LIST") {
$("#kv").hide();
$("#vs").hide();
$("#hp").show();
}
else if($(this).val()=="STRING") {
$("#kv").show();
$("#vs").show();
$("#hp").hide();
}
});
var xmlstr = "";
xmlstr = "<CelsiusToFahrenheitResponse>\n <CelsiusToFahrenheitResult>77</CelsiusToFahrenheitResult>\n</CelsiusToFahrenheitResponse>";
$("#response").text(xmlstr);
});
</script>
</body>
</html>
课程添加任何依赖项。
我猜是在添加
org.springframework.beans.factory.DisposableBean
应该解决你的问题。如果不, 检查here以查找具有您的类的依赖项并添加正确的依赖项。