{"id":1390,"date":"2012-06-14T22:00:00","date_gmt":"2012-06-14T22:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/resteasy-tutorial-part-3-exception-handling.html"},"modified":"2012-10-22T05:36:01","modified_gmt":"2012-10-22T05:36:01","slug":"resteasy-tutorial-part-3-exception","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html","title":{"rendered":"RESTEasy Tutorial Part-3: Exception Handling"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the user an error page with details like brief exception message, error code(optional), hints to correct the input and retry(optional) and actual root cause(optional). This is applicable to RESTful web services also.<\/p>\n<p>But putting try-catch-finally blocks all around the code is not a good practice. We should design\/code in such a way that if there is any unrecoverable error occured then the code should throw that exception and there should an exception handler to catch those exceptions and extract the error details and give a proper error response to the client with all the error details.                     <\/p>\n<p>RESTEasy provides such ExceptionHandler mechanism which simplifies the ExceptionHandling process.                     <\/p>\n<p>In this part I will show you how we can use RESTEasy&#8217;s ExceptionHandlers to handle Exceptions.                     <\/p>\n<p><strong>Step#1: Create Application Specific Exceptions.<\/strong><\/p>\n<pre class=\"brush:java\"> **\r\n  * ResourceNotFoundException.java\r\n  *\r\n package com.sivalabs.resteasydemo;\r\n \r\n public class ResourceNotFoundException extends RuntimeException\r\n {\r\n  private static final long serialVersionUID = 1L;\r\n  public ResourceNotFoundException(String msg)\r\n  {\r\n   super(msg);\r\n  }\r\n }\r\n \r\n **\r\n  * ApplicationException.java\r\n  *\r\n package com.sivalabs.resteasydemo;\r\n \r\n import java.io.PrintWriter;\r\n import java.io.StringWriter;\r\n \r\n public class ApplicationException extends RuntimeException\r\n {\r\n  private static final long serialVersionUID = 1L;\r\n \r\n  public ApplicationException()\r\n  {\r\n   super();\r\n  }\r\n  public ApplicationException(String message, Throwable cause)\r\n  {\r\n   super(message, cause);\r\n  }\r\n  public ApplicationException(Throwable cause)\r\n  {\r\n   super(cause);\r\n  }\r\n  public ApplicationException(String msg)\r\n  {\r\n   super(msg);\r\n  }\r\n  public String getInternalErrorMessage()\r\n  {\r\n   Throwable cause = this.getCause();\r\n   if(cause != null)\r\n   {\r\n    StringWriter sw = new StringWriter();\r\n    PrintWriter pw = new PrintWriter(sw);\r\n    cause.printStackTrace(pw);\r\n    return sw.toString();\r\n   }\r\n   return null;\r\n  }\r\n }\r\n<\/pre>\n<p><strong>Step#2: Create ExceptionHandlers by implementing ExceptionMapper                                           interface.<\/strong><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\"> **\r\n  * ResourceNotFoundExceptionHandler.java\r\n  *\r\n package com.sivalabs.resteasydemo;\r\n \r\n import javax.ws.rs.core.Response;\r\n import javax.ws.rs.ext.ExceptionMapper;\r\n import javax.ws.rs.ext.Provider;\r\n \r\n import org.springframework.stereotype.Component;\r\n \r\n @Provider\r\n @Component\r\n public class ResourceNotFoundExceptionHandler implements ExceptionMapper&lt;ResourceNotFoundException&gt;\r\n {\r\n \r\n  @Override\r\n  public Response toResponse(ResourceNotFoundException ex)\r\n \r\n   For simplicity I am preparing error xml by hand.\r\n   Ideally we should create an ErrorResponse class to hold the error info.\r\n   String msg = ex.getMessage();\r\n   StringBuilder response = new StringBuilder('&lt;response&gt;');\r\n   response.append('&lt;status&gt;failed&lt;status&gt;');\r\n   response.append('&lt;message&gt;'+msg+'&lt;message&gt;');\r\n   response.append('&lt;response&gt;');\r\n \r\n   return Response.serverError().entity(response.toString()).build();\r\n  }\r\n \r\n }\r\n \r\n **\r\n  * ApplicationExceptionHandler.java\r\n  *\r\n package com.sivalabs.resteasydemo;\r\n \r\n import javax.ws.rs.core.Response;\r\n import javax.ws.rs.ext.ExceptionMapper;\r\n import javax.ws.rs.ext.Provider;\r\n \r\n import org.springframework.stereotype.Component;\r\n \r\n @Provider\r\n @Component\r\n public class ApplicationExceptionHandler implements ExceptionMapper&lt;ApplicationException&gt;\r\n {\r\n  @Override\r\n  public Response toResponse(ApplicationException ex)\r\n  {\r\n   For simplicity I am preparing error xml by hand.\r\n   Ideally we should create an ErrorResponse class to hold the error info.\r\n   String msg = ex.getMessage();\r\n   String internalError = ex.getInternalErrorMessage();\r\n   StringBuilder response = new StringBuilder('&lt;response&gt;');\r\n   response.append('&lt;status&gt;failed&lt;status&gt;');\r\n   response.append('&lt;message&gt;'+msg+'&lt;message&gt;');\r\n   response.append('&lt;internalError&gt;'+internalError+'&lt;internalError&gt;');\r\n   response.append('&lt;response&gt;');\r\n   return Response.serverError().entity(response.toString()).build();\r\n  }\r\n \r\n }<\/pre>\n<p><strong>Step#3: Update UserResource.getUserXMLById() method to validate user input and throw respective exceptions<\/strong>.<\/p>\n<pre class=\"brush:java\"> @Path('{id}')\r\n @GET\r\n public Response getUserXMLById(@PathParam('id') Integer id) \r\n {\r\n  if(id==null || id &lt; 1 ){\r\n   throw new ApplicationException('User Id['+id+'] should not be less than 1.');\r\n  }\r\n  User user = userService.getById(id);\r\n \r\n  if(user==null ){\r\n   throw new ResourceNotFoundException('No User found with Id :['+id+']');\r\n  }\r\n  return Response.ok(user).build();\r\n }<\/pre>\n<p><strong>Step#4: Test the UserResource.getUserXMLById() service method by issueing following requests.<\/strong><\/p>\n<pre class=\"brush:java\"> case 1 : GET http:localhost:8080resteasy-demorestusers0\r\n  Response :\r\n   &lt;response&gt;\r\n                         &lt;status&gt;failed&lt;status&gt;\r\n    &lt;message&gt;User Id[0] should not be less than 1.&lt;message&gt;\r\n    &lt;internalError&gt;null&lt;internalError&gt;\r\n   &lt;response&gt;\r\n \r\n case 2: GET http:localhost:8080resteasy-demorestusers100\r\n  Response :\r\n          &lt;response&gt;\r\n           &lt;status&gt;failed&lt;status&gt;\r\n    &lt;message&gt;No User found with Id :[100]&lt;message&gt;\r\n   &lt;response&gt;<\/pre>\n<p><strong>Important things to note:<\/strong>                     <\/p>\n<p>As Spring is creating the necessary objects we should let Spring know about @Provider classes to get them registered with RESTEasy. We can do this in two ways.                     <\/p>\n<p>a)Annotate Provider classes with @Component                     <\/p>\n<p>b)Using component-scan&#8217;s include-filter.<br \/>\n&lt;context:component-scan base-package=&#8217;com.sivalabs.springdemo&#8217;&gt;<br \/>\n&lt;context:include-filter expression=&#8217;javax.ws.rs.ext.Provider&#8217; type=&#8217;annotation&#8217;\/&gt;<br \/>\n&lt;\/context:component-scan&gt;<\/p>\n<dl>                     <\/dl>\n<p><strong>RESTEasy Tutorial Series<\/strong><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-1-basics.html\">RESTEasy Tutorial Part-1: Basics<\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-2-spring.html\">RESTEasy Tutorial Part-2: Spring Integration<\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html\">RESTEasy Tutorial Part 3 &#8211; Exception Handling<\/a><\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/www.sivalabs.in\/2012\/06\/resteasy-tutorial-part-3-exception.html\">RESTEasy Tutorial Part 3 &#8211; Exception Handling<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Siva Reddy at the <a href=\"http:\/\/www.sivalabs.in\/\">My Experiments on Technology<\/a> blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the user an error page with details like brief exception message, error code(optional), hints to correct the input and retry(optional) and actual root cause(optional). This is applicable to RESTful web services also. But putting &hellip;<\/p>\n","protected":false},"author":15,"featured_media":160,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[135,54],"class_list":["post-1390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jboss-resteasy","tag-restful-web-services"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>RESTEasy Tutorial Part-3: Exception Handling - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RESTEasy Tutorial Part-3: Exception Handling - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-06-14T22:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-22T05:36:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Siva Reddy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/sivalabs\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Siva Reddy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html\"},\"author\":{\"name\":\"Siva Reddy\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c4bc16742c140e793e22fe73a1b6f488\"},\"headline\":\"RESTEasy Tutorial Part-3: Exception Handling\",\"datePublished\":\"2012-06-14T22:00:00+00:00\",\"dateModified\":\"2012-10-22T05:36:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html\"},\"wordCount\":294,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"keywords\":[\"JBoss RESTEasy\",\"RESTful Web Services\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html\",\"name\":\"RESTEasy Tutorial Part-3: Exception Handling - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"datePublished\":\"2012-06-14T22:00:00+00:00\",\"dateModified\":\"2012-10-22T05:36:01+00:00\",\"description\":\"Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/resteasy-tutorial-part-3-exception.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"RESTEasy Tutorial Part-3: Exception Handling\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c4bc16742c140e793e22fe73a1b6f488\",\"name\":\"Siva Reddy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/57171cbc9a028e211086675fa890ef348d8da6113ee2e16e74aadad2261d21c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/57171cbc9a028e211086675fa890ef348d8da6113ee2e16e74aadad2261d21c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/57171cbc9a028e211086675fa890ef348d8da6113ee2e16e74aadad2261d21c8?s=96&d=mm&r=g\",\"caption\":\"Siva Reddy\"},\"description\":\"Katamreddy Siva Prasad is a Senior Software Engineer working in E-Commerce domain. His areas of interest include Object Oriented Design, SOLID Design principles, RESTful WebServices and OpenSource softwares including Spring, MyBatis and Jenkins.\",\"sameAs\":[\"http:\\\/\\\/sivalabs.blogspot.com\\\/\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/sivalabs\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/siva-reddy\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RESTEasy Tutorial Part-3: Exception Handling - Java Code Geeks","description":"Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html","og_locale":"en_US","og_type":"article","og_title":"RESTEasy Tutorial Part-3: Exception Handling - Java Code Geeks","og_description":"Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the","og_url":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-06-14T22:00:00+00:00","article_modified_time":"2012-10-22T05:36:01+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","type":"image\/jpeg"}],"author":"Siva Reddy","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/sivalabs","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Siva Reddy","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html"},"author":{"name":"Siva Reddy","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c4bc16742c140e793e22fe73a1b6f488"},"headline":"RESTEasy Tutorial Part-3: Exception Handling","datePublished":"2012-06-14T22:00:00+00:00","dateModified":"2012-10-22T05:36:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html"},"wordCount":294,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","keywords":["JBoss RESTEasy","RESTful Web Services"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html","url":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html","name":"RESTEasy Tutorial Part-3: Exception Handling - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","datePublished":"2012-06-14T22:00:00+00:00","dateModified":"2012-10-22T05:36:01+00:00","description":"Exception Handling is an obvious requirement while developing software application. If any error occured while processing user request we should show the","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/resteasy-tutorial-part-3-exception.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"RESTEasy Tutorial Part-3: Exception Handling"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c4bc16742c140e793e22fe73a1b6f488","name":"Siva Reddy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/57171cbc9a028e211086675fa890ef348d8da6113ee2e16e74aadad2261d21c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/57171cbc9a028e211086675fa890ef348d8da6113ee2e16e74aadad2261d21c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/57171cbc9a028e211086675fa890ef348d8da6113ee2e16e74aadad2261d21c8?s=96&d=mm&r=g","caption":"Siva Reddy"},"description":"Katamreddy Siva Prasad is a Senior Software Engineer working in E-Commerce domain. His areas of interest include Object Oriented Design, SOLID Design principles, RESTful WebServices and OpenSource softwares including Spring, MyBatis and Jenkins.","sameAs":["http:\/\/sivalabs.blogspot.com\/","https:\/\/x.com\/http:\/\/twitter.com\/sivalabs"],"url":"https:\/\/www.javacodegeeks.com\/author\/siva-reddy"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1390"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1390\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/160"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}