{"id":1603,"date":"2014-12-18T14:18:45","date_gmt":"2014-12-18T14:18:44","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=1603"},"modified":"2023-06-27T23:14:59","modified_gmt":"2023-06-28T06:14:59","slug":"error-handling-java-client-library","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/","title":{"rendered":"Error handling in the Java client library"},"content":{"rendered":"<p>In my <a href=\"https:\/\/www.couchbase.com\/blog\/handling-runtime-errors-ruby-python-and-c-clients\/\">previous blog article<\/a>, we looked at the errors thrown by libCouchbase clients such as ruby, python, C and C++. This blog will focus on the Java client library for Couchbase.<\/p>\n<p>In the Java client library, there are exceptions, no errors. Depending on the return type and state of application, different exceptions can be thrown by the java client. Generally, you&#8217;ll find those exceptions noted either through the @throws annotations or your IDE will tell you that you need to catch them.<\/p>\n<p><strong>Here are some exceptions that you might encounter when using the Java library:<\/strong><\/p>\n<p>All asynchronous operations return futures, they do not raise an exception until you block on the result. In addition to trapping the exception, you can also inspect the status of the future and use the <em>getMessage() <\/em>API to obtain the actual message text.<\/p>\n<p>For synchronous APIs, the client library is implemented as a wrapper around the async methods. Here are the most common exceptions thrown by the syncronous java APIs :<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0 <strong>TimeoutException<\/strong> &#8211; This means that waiting on the future took longer than expected. For example, this exception is thrown if get() is used with a default timeout value and it expires. It is also thrown if get() with a custom timeout is used and the timeout expires.<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0 <strong>CancellationException<\/strong> &#8211; This means that the operation was cancelled while &#8220;in flight&#8221;. For example, a request sent over a network without a reply. This can particularly happen when a node fails. All operations that are currently in flight are cancelled.<\/p>\n<p>3.\u00a0\u00a0\u00a0\u00a0 <strong>InterruptedException<\/strong>&#8211; This means that there was a interrupt while blocking on the future.<\/p>\n<p>If you are using views in your application with Java, you might see the following exceptions :<\/p>\n<p>1.\u00a0\u00a0\u00a0 <strong>InvalidViewException<\/strong> &#8211; This means that an invalid view name or design document was specified. This exception is also thrown if a view is in the development stage and is not deployed to production or the view is in production and the app refers to the development view.<\/p>\n<p>To handle this exception, try using the correct viewname parameter when calling the view and make sure that this view is deployed to production.<\/p>\n<p>If you are using the APIs to verify that your data is persisted by Couchbase, there are a few more exceptions you might want to watch out for:<\/p>\n<p>1.\u00a0\u00a0\u00a0 <strong>ObservedException<\/strong> &#8211; This means that something general went wrong with API call and more details can be found in the status message.<\/p>\n<p>2.\u00a0\u00a0\u00a0 <strong>ObservedTimeoutException<\/strong> &#8211; This means that the API call timed out and you must retry.<\/p>\n<p>3.\u00a0\u00a0\u00a0 <strong>ObservedModifiedException<\/strong> &#8211; This means that the API call failed because the document was modified in the meantime. This indicates a race condition.<\/p>\n<p>Finally, during bootstrapping your application with the Java API you may encounter the following exceptions:<\/p>\n<p>1.\u00a0\u00a0\u00a0 <strong>ConfigParsingException<\/strong> &#8211; This means that the current configuration cannot be parsed. You must verify the correctness of your config file and try again.<\/p>\n<p>You may also see other network exceptions if the host is not reachable.<\/p>\n<p>Good luck building your applications using the Couchbase Java client. If you have any questions, please do not hesitate to ask us in the<a href=\"https:\/\/www.couchbase.com\/forums\/\"> forums<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous blog article, we looked at the errors thrown by libCouchbase clients such as ruby, python, C and C++. This blog will focus on the Java client library for Couchbase. In the Java client library, there are exceptions, [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[1316],"ppma_author":[8972],"class_list":["post-1603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-error-handling"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Error handling in the Java client library - The Couchbase Blog<\/title>\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.couchbase.com\/blog\/error-handling-java-client-library\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Error handling in the Java client library\" \/>\n<meta property=\"og:description\" content=\"In my previous blog article, we looked at the errors thrown by libCouchbase clients such as ruby, python, C and C++. This blog will focus on the Java client library for Couchbase. In the Java client library, there are exceptions, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-18T14:18:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-28T06:14:59+00:00\" \/>\n<meta name=\"author\" content=\"Don Pinto, Principal Product Manager, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Don Pinto, Principal Product Manager, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/\"},\"author\":{\"name\":\"Don Pinto, Principal Product Manager, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/eb130a1e0278989e089a7fbbf8bc754c\"},\"headline\":\"Error handling in the Java client library\",\"datePublished\":\"2014-12-18T14:18:44+00:00\",\"dateModified\":\"2023-06-28T06:14:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/\"},\"wordCount\":523,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"Error handling\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/\",\"name\":\"Error handling in the Java client library - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2014-12-18T14:18:44+00:00\",\"dateModified\":\"2023-06-28T06:14:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Error handling in the Java client library\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/eb130a1e0278989e089a7fbbf8bc754c\",\"name\":\"Don Pinto, Principal Product Manager, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/39c6d6178c73f0dc09af63f930a4f37d\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/574759a111515cb8c5d5a1f5268d2759050bd8383654dc0d9393324f0c35fae0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/574759a111515cb8c5d5a1f5268d2759050bd8383654dc0d9393324f0c35fae0?s=96&d=mm&r=g\",\"caption\":\"Don Pinto, Principal Product Manager, Couchbase\"},\"description\":\"Don Pinto is a Principal Product Manager at Couchbase and is currently focused on advancing the capabilities of Couchbase Server. He is extremely passionate about data technology, and in the past has authored several articles on Couchbase Server including technical blogs and white papers. Prior to joining Couchbase, Don spent several years at IBM where he maintained the role of software developer in the DB2 information management group and most recently as a program manager on the SQL Server team at Microsoft. Don holds a master's degree in computer science and a bachelor's in computer engineering from the University of Toronto, Canada.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/don-pinto\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Error handling in the Java client library - The Couchbase Blog","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.couchbase.com\/blog\/error-handling-java-client-library\/","og_locale":"en_US","og_type":"article","og_title":"Error handling in the Java client library","og_description":"In my previous blog article, we looked at the errors thrown by libCouchbase clients such as ruby, python, C and C++. This blog will focus on the Java client library for Couchbase. In the Java client library, there are exceptions, [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/","og_site_name":"The Couchbase Blog","article_published_time":"2014-12-18T14:18:44+00:00","article_modified_time":"2023-06-28T06:14:59+00:00","author":"Don Pinto, Principal Product Manager, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Don Pinto, Principal Product Manager, Couchbase","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/"},"author":{"name":"Don Pinto, Principal Product Manager, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/eb130a1e0278989e089a7fbbf8bc754c"},"headline":"Error handling in the Java client library","datePublished":"2014-12-18T14:18:44+00:00","dateModified":"2023-06-28T06:14:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/"},"wordCount":523,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["Error handling"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/","url":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/","name":"Error handling in the Java client library - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2014-12-18T14:18:44+00:00","dateModified":"2023-06-28T06:14:59+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/error-handling-java-client-library\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Error handling in the Java client library"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/eb130a1e0278989e089a7fbbf8bc754c","name":"Don Pinto, Principal Product Manager, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/39c6d6178c73f0dc09af63f930a4f37d","url":"https:\/\/secure.gravatar.com\/avatar\/574759a111515cb8c5d5a1f5268d2759050bd8383654dc0d9393324f0c35fae0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/574759a111515cb8c5d5a1f5268d2759050bd8383654dc0d9393324f0c35fae0?s=96&d=mm&r=g","caption":"Don Pinto, Principal Product Manager, Couchbase"},"description":"Don Pinto is a Principal Product Manager at Couchbase and is currently focused on advancing the capabilities of Couchbase Server. He is extremely passionate about data technology, and in the past has authored several articles on Couchbase Server including technical blogs and white papers. Prior to joining Couchbase, Don spent several years at IBM where he maintained the role of software developer in the DB2 information management group and most recently as a program manager on the SQL Server team at Microsoft. Don holds a master's degree in computer science and a bachelor's in computer engineering from the University of Toronto, Canada.","url":"https:\/\/www.couchbase.com\/blog\/author\/don-pinto\/"}]}},"authors":[{"term_id":8972,"user_id":4,"is_guest":0,"slug":"don-pinto","display_name":"Don Pinto, Principal Product Manager, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/574759a111515cb8c5d5a1f5268d2759050bd8383654dc0d9393324f0c35fae0?s=96&d=mm&r=g","author_category":"","last_name":"Pinto, Principal Product Manager, Couchbase","first_name":"Don","job_title":"","user_url":"","description":"Don Pinto is a Principal Product Manager at Couchbase and is currently focused on advancing the capabilities of Couchbase Server. He is extremely passionate about data technology, and in the past has authored several articles on Couchbase Server including technical blogs and white papers. Prior to joining Couchbase, Don spent several years at IBM where he maintained the role of software developer in the DB2 information management group and most recently as a program manager on the SQL Server team at Microsoft. Don holds a master's degree in computer science and a bachelor's in computer engineering from the University of Toronto, Canada."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=1603"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1603\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=1603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=1603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=1603"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}