{"id":5211,"date":"2014-03-30T19:43:16","date_gmt":"2014-03-30T19:43:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/spring-cant-see-my-imported-classes-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:43:16","modified_gmt":"2014-03-30T19:43:16","slug":"spring-cant-see-my-imported-classes-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/spring-cant-see-my-imported-classes-collection-of-common-programming-errors\/","title":{"rendered":"Spring can&#39;t see my imported classes-Collection of common programming errors"},"content":{"rendered":"<p>My controller (abstract controller) is calling a service class to get a URL. In my service class I instantiate my dependency in the constructor:<\/p>\n<p>the abstract controller:<\/p>\n<pre><code>public class MyPageController extends AbstractController{\nprivate UserService userService;\nprivate LearnerService learnerService;\nprivate TwitterService twitterService;\n@Override\nprotected ModelAndView handleRequestInternal(HttpServletRequest request,\n                HttpServletResponse response) throws Exception {\n        userService = UserServiceFactory.getUserService();\n        learnerService = new LearnerService();\n        twitterService=new TwitterService();\n<\/code><\/pre>\n<p>the Service class:<\/p>\n<pre><code>public TwitterService(){\n        \/\/\n        twitter = new Twitter();\n}\n<\/code><\/pre>\n<p>but when I try to run my web app, spring throws the following error:<\/p>\n<pre><code>nested exception is java.lang.NoClassDefFoundError: twitter4j\/Twitter:\n    java.lang.NoClassDefFoundError: twitter4j\/Twitter\n    at com.hardwire.service.TwitterService.(Twitter Service.java:21)\n    at com.hardwire.controller.\n    MyPageController.handleReq uestInternal(MyPageController.java:30)\n<\/code><\/pre>\n<p>Why does it throw this error? I don&#8217;t understand. I imported the Twitter class in the service class that uses it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My controller (abstract controller) is calling a service class to get a URL. In my service class I instantiate my dependency in the constructor: the abstract controller: public class MyPageController extends AbstractController{ private UserService userService; private LearnerService learnerService; private TwitterService twitterService; @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { userService = UserServiceFactory.getUserService(); learnerService [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5211","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5211"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5211\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}