Getting a 404 error when instantiating a core java class in a servlet -
i building web application in java , when trying instantiate core java class servlet class , use methods of class, getting 404 error. have been trying figure out reason long couldn't find any.
code: servlet class:
public class supportpage extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws ioexception, servletexception { printwriter out = response.getwriter(); // when remove part, app runs fine. jirarest jirarest = new jirarest(); string key = null; try { key = jirarest.createissue(12403, 10000, "test", "test"); } catch (jsonexception e) { e.printstacktrace(); } catch (urisyntaxexception e) { e.printstacktrace(); } catch (httpexception e) { e.printstacktrace(); } out.println("<html>"); out.println("ticket key: "+key +" created"); out.println("</html>"); return; }}
java class:
public class jirarest { public string createissue(integer projectid, integer issuetypeid, string summary, string description) throws jsonexception, ioexception, urisyntaxexception, httpexception { jsonobject fields = new jsonobject(); fields.put("project", new jsonobject().put("id", projectid.tostring())); fields.put("issuetype", new jsonobject().put("id", issuetypeid.tostring())); fields.put("summary", "test"); fields.put("customfield_10004", "testdvf"); //fields.put("description", "this test.kindly ignore!"); jsonobject issue = new jsonobject(); issue.put("fields", fields); system.out.println(issue); stringentity se = new stringentity(issue.tostring()); se.setcontenttype("application/json"); httpclient client = new defaulthttpclient(); httppost post = new httppost("https://jira.endurance.com/rest/api/latest/issue?os_username=abc&os_password=xyz"); post.setentity(se); post.addheader("accept", "*/*"); post.addheader("connection", "keep-alive"); httpresponse response = client.execute(post); string json_string = entityutils.tostring(response.getentity()); system.out.println(json_string); jsonobject obj = new jsonobject(json_string); return obj.getstring("key"); }}
the java class making rest calls. url trying access: localhost/projectname/support. when remove jirarest class usage in supportpage class, works fine. appreciated.
edit: adding stacktrace http://pastebin.com/fdxmghu5
ensure have packed required , dependent libraries war file, or copy them under container shared library folder.
you stack says have missed library/class, stuffs...
Comments
Post a Comment