List of usage examples for org.springframework.beans.factory NoSuchBeanDefinitionException getMessage
@Override
@Nullable
public String getMessage()
From source file:org.jahia.modules.bootstrap.osgi.CompileLessTemplateSetActivator.java
/** * Called when this bundle is started so the Framework can perform the * bundle-specific activities necessary to start this bundle. This method * can be used to register services or to allocate any resources that this * bundle needs./*from w w w .ja v a 2 s . c om*/ * <p/> * <p/> * This method must complete and return to its caller in a timely manner. * * @param context The execution context of the bundle being started. */ @Override public void start(BundleContext context) { if (this.context == null) { this.context = context; } context.addBundleListener(new SynchronousBundleListener() { private List<String> getDependenciesIds(JahiaTemplatesPackage jahiaTemplatesPackage) { String depends = jahiaTemplatesPackage.getBundle().getHeaders().get("Jahia-Depends"); ArrayList<String> l = new ArrayList<String>(); for (String dep : StringUtils.split(depends, ",")) { l.add(dep.trim()); } return l; } @Override public void bundleChanged(BundleEvent bundleEvent) { if (bundleEvent.getType() == BundleEvent.STARTED) { JahiaTemplateManagerService jahiaTemplateManagerService = ServicesRegistry.getInstance() .getJahiaTemplateManagerService(); if (jahiaTemplateManagerService == null) { return; } String version = bundleEvent.getBundle().getHeaders().get("Implementation-Version"); if (version == null) { return; } JahiaTemplatesPackage jahiaTemplatesPackage = jahiaTemplateManagerService .getTemplatePackageRegistry().lookupByIdAndVersion( bundleEvent.getBundle().getSymbolicName(), new ModuleVersion(version)); if (jahiaTemplatesPackage == null) { return; } if (jahiaTemplatesPackage.getModuleType() .equals(JahiaTemplateManagerService.MODULE_TYPE_TEMPLATES_SET) && getDependenciesIds(jahiaTemplatesPackage).contains("bootstrap")) { BootstrapCompiler bootstrapCompiler = null; try { bootstrapCompiler = (BootstrapCompiler) SpringContextSingleton .getBean("BootstrapCompiler"); } catch (NoSuchBeanDefinitionException e) { log.debug("Failed to find BootstrapCompiler", e); } if (bootstrapCompiler != null) { try { bootstrapCompiler.compile(jahiaTemplatesPackage); } catch (RepositoryException e) { log.error(e.getMessage(), e); } } } } } }); }
From source file:com.quancheng.saluki.boot.runner.GrpcReferenceRunner.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { Class<?> searchType = bean.getClass(); while (!Object.class.equals(searchType) && searchType != null) { Field[] fields = searchType.getDeclaredFields(); for (Field field : fields) { SalukiReference reference = field.getAnnotation(SalukiReference.class); if (reference != null) { Object value = null; try { value = applicationContext.getBean(field.getType()); } catch (NoSuchBeanDefinitionException e) { value = null;/*from w ww .j a v a 2 s. co m*/ } if (value == null) { value = refer(reference, field.getType()); } try { if (!field.isAccessible()) { field.setAccessible(true); } field.set(bean, value); } catch (Throwable e) { logger.error("Failed to init remote service reference at filed " + field.getName() + " in class " + bean.getClass().getName() + ", cause: " + e.getMessage(), e); } } } searchType = searchType.getSuperclass(); } return bean; }
From source file:org.infoscoop.admin.web.ServiceCommandServlet.java
@SuppressWarnings("unchecked") protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { String uri = req.getRequestURI(); String services = "/services/"; String path = uri.substring(uri.indexOf(services) + services.length()); String[] servicePaths = path.split("/"); String serviceName = servicePaths[0]; String commandName = servicePaths[1]; if (log.isInfoEnabled()) log.info("Call " + commandName + " comman of " + serviceName + " service."); Object temp = null;/*from w ww .ja v a2 s.c om*/ try { temp = SpringUtil.getBean(serviceName); } catch (NoSuchBeanDefinitionException ex) { log.error("", ex); } if (temp == null || !(temp instanceof ServiceCommand)) { resp.sendError(500, "Service Not Found"); return; } ServiceCommand serviceCommand = (ServiceCommand) temp; try { resp.setContentType("text/plain; charset=UTF-8"); resp.setHeader("Pragma", "no-cache"); resp.setHeader("Cache-Control", "no-cache"); CommandResponse commandResp; try { // check the roll. Properties notPermittedPatterns = serviceCommand.getNotPermittedPatterns(); Set permissionTypeList = notPermittedPatterns.keySet(); List<String> myPermissionList = PortalAdminsService.getHandle().getMyPermissionList(); String notPermittedPattern = ".*"; boolean notMatched = false; myPermissionList.add("*"); for (String myPermissionType : myPermissionList) { notPermittedPattern = notPermittedPatterns.getProperty(myPermissionType, ".*"); if (commandName.matches(notPermittedPattern)) continue; // when there is no pattern that isn't permitted notMatched = true; break; } if (!notMatched) resp.sendError(403, "It is an access to the service that has not been permitted."); commandResp = serviceCommand.execute(commandName, req, resp); } catch (Throwable ex) { log.error(ex.getMessage(), ex); Throwable cause; while ((cause = ex.getCause()) != null) ex = cause; commandResp = new CommandResponse(false, ex.getClass().getName() + ": " + ex.getMessage()); } int status = 200; String responseBody = commandResp.getResponseBody(); if (!commandResp.isSuccess()) status = 500; resp.setStatus(status); if (responseBody == null) responseBody = "command is " + ((status == 200) ? "succeed!" : "failed"); resp.getWriter().write(responseBody); if (log.isInfoEnabled()) log.info("Execution result of service command is " + commandResp.isSuccess() + "."); } catch (Exception ex) { log.error("Unexpected error occurred.", ex); resp.sendError(500, ex.getMessage()); } }
From source file:org.jasig.portlet.calendar.mvc.controller.CalendarController.java
@RequestMapping public ModelAndView getCalendar(@RequestParam(required = false, value = "interval") String intervalString, RenderRequest request) {/* w w w .j a va 2s .c o m*/ PortletSession session = request.getPortletSession(true); PortletPreferences prefs = request.getPreferences(); Map<String, Object> model = new HashMap<String, Object>(); // get the list of hidden calendars @SuppressWarnings("unchecked") HashMap<Long, String> hiddenCalendars = (HashMap<Long, String>) session.getAttribute("hiddenCalendars"); // indicate if the current user is a guest (unauthenticated) user model.put("guest", request.getRemoteUser() == null); /** * Add and remove calendars from the hidden list. Hidden calendars * will be fetched, but rendered invisible in the view. */ // check the request parameters to see if we need to add any // calendars to the list of hidden calendars String hideCalendar = request.getParameter("hideCalendar"); if (hideCalendar != null) { hiddenCalendars.put(Long.valueOf(hideCalendar), "true"); session.setAttribute("hiddenCalendars", hiddenCalendars); } // check the request parameters to see if we need to remove // any calendars from the list of hidden calendars String showCalendar = request.getParameter("showCalendar"); if (showCalendar != null) { hiddenCalendars.remove(Long.valueOf(showCalendar)); session.setAttribute("hiddenCalendars", hiddenCalendars); } // See if we're configured to show or hide the jQueryUI DatePicker. // By default, we assume we are to show the DatePicker because that's // the classic behavior. String showDatePicker = prefs.getValue("showDatePicker", "true"); model.put("showDatePicker", showDatePicker); /** * Find our desired starting and ending dates. */ Interval interval = null; if (!StringUtils.isEmpty(intervalString)) { interval = Interval.parse(intervalString); model.put("startDate", new DateMidnight(interval.getStart()).toDate()); model.put("days", interval.toDuration().getStandardDays()); model.put("endDate", new DateMidnight(interval.getEnd())); } else { //StartDate can only be changed via an AJAX request DateMidnight startDate = (DateMidnight) session.getAttribute("startDate"); log.debug("startDate from session is: " + startDate); model.put("startDate", startDate.toDate()); // find how many days into the future we should display events int days = (Integer) session.getAttribute("days"); model.put("days", days); // set the end date based on our desired time period DateMidnight endDate = startDate.plusDays(days); model.put("endDate", endDate.toDate()); interval = new Interval(startDate, endDate); } // define "today" and "tomorrow" so we can display these specially in the // user interface // get the user's configured time zone String timezone = (String) session.getAttribute("timezone"); DateMidnight today = new DateMidnight(DateTimeZone.forID(timezone)); model.put("today", today.toDate()); model.put("tomorrow", today.plusDays(1).toDate()); /** * retrieve the calendars defined for this portlet instance */ CalendarSet<?> set = calendarSetDao.getCalendarSet(request); List<CalendarConfiguration> calendars = new ArrayList<CalendarConfiguration>(); calendars.addAll(set.getConfigurations()); Collections.sort(calendars, new CalendarConfigurationByNameComparator()); model.put("calendars", calendars); Map<Long, Integer> colors = new HashMap<Long, Integer>(); Map<Long, String> links = new HashMap<Long, String>(); int index = 0; for (CalendarConfiguration callisting : calendars) { // don't bother to fetch hidden calendars if (hiddenCalendars.get(callisting.getId()) == null) { try { // get an instance of the adapter for this calendar ICalendarAdapter adapter = (ICalendarAdapter) applicationContext .getBean(callisting.getCalendarDefinition().getClassName()); //get hyperlink to calendar String link = adapter.getLink(callisting, interval, request); if (link != null) { links.put(callisting.getId(), link); } } catch (NoSuchBeanDefinitionException ex) { log.error("Calendar class instance could not be found: " + ex.getMessage()); } catch (CalendarLinkException linkEx) { // Not an error. Ignore } catch (Exception ex) { log.error(ex); } } // add this calendar's id to the color map colors.put(callisting.getId(), index); index++; } model.put("timezone", session.getAttribute("timezone")); model.put("colors", colors); model.put("links", links); model.put("hiddenCalendars", hiddenCalendars); /* * Check if we need to disable either the preferences and/or administration links */ Boolean disablePrefs = Boolean.valueOf(prefs.getValue(PREFERENCE_DISABLE_PREFERENCES, "false")); model.put(PREFERENCE_DISABLE_PREFERENCES, disablePrefs); Boolean disableAdmin = Boolean.valueOf(prefs.getValue(PREFERENCE_DISABLE_ADMINISTRATION, "false")); model.put(PREFERENCE_DISABLE_ADMINISTRATION, disableAdmin); return new ModelAndView(viewSelector.getCalendarViewName(request), "model", model); }
From source file:org.jasig.portlet.newsreader.mvc.portlet.reader.AjaxNewsController.java
@ResourceMapping public ModelAndView getJSONFeeds(ResourceRequest request, ResourceResponse response) throws Exception { log.debug("handleAjaxRequestInternal (AjaxNewsController)"); Map<String, Object> model = new HashMap<String, Object>(); String setName = request.getPreferences().getValue("newsSetName", "default"); NewsSet set = setCreationService.getNewsSet(setName, request); List<NewsConfiguration> feeds = new ArrayList<NewsConfiguration>(); feeds.addAll(set.getNewsConfigurations()); Collections.sort(feeds);//from w w w .ja v a 2 s .c o m JSONArray jsonFeeds = new JSONArray(); List<String> knownFeeds = new ArrayList<String>(); for (NewsConfiguration feed : feeds) { if (feed.isDisplayed()) { JSONObject jsonFeed = new JSONObject(); jsonFeed.put("id", feed.getId()); jsonFeed.put("name", feed.getNewsDefinition().getName()); jsonFeeds.add(jsonFeed); knownFeeds.add(String.valueOf(feed.getId())); } } model.put("feeds", jsonFeeds); PortletPreferences prefs = request.getPreferences(); String activeateNews = request.getParameter("activeateNews"); if (activeateNews != null) { prefs.setValue("activeFeed", activeateNews); prefs.store(); } int page = Integer.parseInt(request.getParameter("page")); // only bother to fetch the active feed String activeFeed = request.getPreferences().getValue("activeFeed", null); // if the current active feed no longer exists in the news set, unset it if (!knownFeeds.contains(activeFeed)) { activeFeed = null; } // if no active feed is currently set, use the first feed in the list if (activeFeed == null && jsonFeeds.size() > 0) { activeFeed = ((JSONObject) jsonFeeds.get(0)).getString("id"); prefs.setValue("activeFeed", activeateNews); prefs.store(); } if (activeFeed != null) { NewsConfiguration feedConfig = newsStore.getNewsConfiguration(Long.valueOf(activeFeed)); model.put("activeFeed", feedConfig.getId()); log.debug("On render Active feed is " + feedConfig.getId()); model.put("page", page); try { // get an instance of the adapter for this feed INewsAdapter adapter = (INewsAdapter) applicationContext .getBean(feedConfig.getNewsDefinition().getClassName()); // retrieve the feed from this adaptor NewsFeed sharedFeed = adapter.getSyndFeed(feedConfig, page); if (sharedFeed != null) { List<NewsFeedItem> items = sharedFeed.getEntries(); for (int i = 0; i < items.size(); i++) { NewsFeedItem item = items.get(i); if (item.getLink() == null && item.getFullStory() != null) { PortletURL link = response.createRenderURL(); link.setParameter("action", "fullStory"); link.setParameter("activeFeed", feedConfig.getId().toString()); link.setParameter("itemIndex", String.valueOf(i)); link.setParameter("page", Integer.toString(page)); item.setLink(link.toString()); } } model.put("feed", sharedFeed); } else { log.warn("Failed to get feed from adapter."); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } } catch (NoSuchBeanDefinitionException ex) { log.error("News class instance could not be found: " + ex.getMessage()); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } catch (NewsException ex) { log.warn(ex); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } catch (Exception ex) { log.error(ex); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } } else { //display message saying "Select the news you wish to read" model.put("message", "Select the news you wish to read."); } log.debug("forwarding to /ajaxFeedList"); String etag = String.valueOf(model.hashCode()); String requestEtag = request.getETag(); // if the request ETag matches the hash for this response, send back // an empty response indicating that cached content should be used if (request.getETag() != null && etag.equals(requestEtag)) { response.getCacheControl().setExpirationTime(1); response.getCacheControl().setUseCachedContent(true); // returning null appears to cause the response to be committed // before returning to the portal, so just use an empty view return new ModelAndView("empty", Collections.<String, String>emptyMap()); } // create new content with new validation tag response.getCacheControl().setETag(etag); response.getCacheControl().setExpirationTime(1); return new ModelAndView("json", model); }
From source file:org.jasig.portlet.newsreader.mvc.portlet.reader.NewsController.java
@RenderMapping(params = "action=fullStory") public ModelAndView fullStory(@RequestParam Long activeFeed, @RequestParam int itemIndex, @RequestParam int page, RenderRequest request, RenderResponse response, Model model) throws Exception { log.trace("fullStory (NewsController)"); //Security check that the feed belongs to the user String setName = request.getPreferences().getValue("newsSetName", "default"); NewsSet set = setCreationService.getNewsSet(setName, request); List<NewsConfiguration> feeds = new ArrayList<NewsConfiguration>(); feeds.addAll(set.getNewsConfigurations()); Collections.sort(feeds);/*from w w w .j a va 2s . c om*/ JSONArray jsonFeeds = new JSONArray(); List<String> knownFeeds = new ArrayList<String>(); for (NewsConfiguration feed : feeds) { if (feed.isDisplayed()) { JSONObject jsonFeed = new JSONObject(); jsonFeed.put("id", feed.getId()); jsonFeed.put("name", feed.getNewsDefinition().getName()); jsonFeeds.add(jsonFeed); knownFeeds.add(String.valueOf(feed.getId())); } } log.debug("Known feeds: " + knownFeeds.toString()); model.addAttribute("feeds", jsonFeeds); if (!knownFeeds.contains(activeFeed.toString())) { activeFeed = null; model.addAttribute("message", "Not allowed."); log.debug("Not allowd."); } model.addAttribute("activeFeed", activeFeed); NewsConfiguration feedConfig = newsStore.getNewsConfiguration(activeFeed); log.debug("On render Active feed is " + feedConfig.getId()); try { // get an instance of the adapter for this feed INewsAdapter adapter = (INewsAdapter) applicationContext .getBean(feedConfig.getNewsDefinition().getClassName()); // retrieve the feed from this adaptor NewsFeed sharedFeed = adapter.getSyndFeed(feedConfig, page); if (sharedFeed != null) { NewsFeedItem item = sharedFeed.getEntries().get(itemIndex); model.addAttribute("storyTitle", item.getTitle()); FullStory fullStory = item.getFullStory(); model.addAttribute("fullStory", fullStory.getFullStoryText()); } else { log.warn("Failed to get feed from adapter."); model.addAttribute("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } PortletPreferences prefs = request.getPreferences(); model.addAttribute("feedView", prefs.getValue("feedView", "select")); } catch (NoSuchBeanDefinitionException ex) { log.error("News class instance could not be found: " + ex.getMessage()); model.addAttribute("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } catch (NewsException ex) { log.warn(ex); model.addAttribute("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } catch (Exception ex) { log.error(ex); model.addAttribute("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } String etag = String.valueOf(model.hashCode()); String requestEtag = request.getETag(); // if the request ETag matches the hash for this response, send back // an empty response indicating that cached content should be used if (request.getETag() != null && etag.equals(requestEtag)) { response.getCacheControl().setExpirationTime(1); response.getCacheControl().setUseCachedContent(true); // returning null appears to cause the response to be committed // before returning to the portal, so just use an empty view return new ModelAndView("empty", Collections.<String, String>emptyMap()); } // create new content with new validation tag response.getCacheControl().setETag(etag); response.getCacheControl().setExpirationTime(1); String viewName = viewResolver.getFullStoryView(request); return new ModelAndView(viewName, model.asMap()); }
From source file:org.jasig.portlet.newsreader.mvc.portlet.singlefeed.SingleFeedNewsController.java
@RequestMapping public ModelAndView showFeed(RenderRequest request, RenderResponse response, @RequestParam(defaultValue = "0") Integer page) throws Exception { Map<String, Object> model = new HashMap<String, Object>(); PortletSession session = request.getPortletSession(true); /**/*from ww w .j a v a 2 s . c o m*/ * If this is a new session, perform any necessary * portlet initialization. */ if (session.getAttribute(INITIALIZED) == null) { // perform any other configured initialization tasks for (IInitializationService service : initializationServices) { service.initialize(request); } // mark this session as initialized session.setAttribute(INITIALIZED, true); } PortletPreferences prefs = request.getPreferences(); NewsConfiguration feedConfig = getFeedConfiguration(prefs); NewsFeed feed = null; try { // get an instance of the adapter for this feed INewsAdapter adapter = (INewsAdapter) applicationContext .getBean(feedConfig.getNewsDefinition().getClassName(), INewsAdapter.class); // retrieve the feed from this adaptor feed = adapter.getSyndFeed(feedConfig, page); if (feed != null) { log.debug("Got feed from adapter"); model.put("feed", feed); } else { log.warn("Failed to get feed from adapter."); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } } catch (NoSuchBeanDefinitionException ex) { log.error("News class instance could not be found: " + ex.getMessage()); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } catch (NewsException ex) { log.warn(ex); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } catch (Exception ex) { log.error(ex); model.put("message", "The news \"" + feedConfig.getNewsDefinition().getName() + "\" is currently unavailable."); } PortletPreferences portletPrefs = request.getPreferences(); Map<String, Object> preferences = new HashMap<String, Object>(); preferences.put(Preference.SUMMARY_VIEW_STYLE, portletPrefs.getValue(Preference.SUMMARY_VIEW_STYLE, "")); preferences.put(Preference.MAX_STORIES, portletPrefs.getValue(Preference.MAX_STORIES, "")); preferences.put(Preference.NEW_WINDOW, portletPrefs.getValue(Preference.NEW_WINDOW, Boolean.TRUE.toString())); preferences.put(Preference.SHOW_TITLE, portletPrefs.getValue(Preference.SHOW_TITLE, Boolean.TRUE.toString())); model.put("prefs", preferences); String viewName = viewResolver.getSingleFeedView(request); return new ModelAndView(viewName, model); }
From source file:org.mule.config.spring.SpringRegistry.java
/** * If looks for the bean registered under {@code key}. * If the returned bean is a prototype and {@code applyLifecycle} * is {@code true}, then the completed lifecycle phases * are applied to the returning bean// ww w . ja va2 s .co m * * @param key the key of the object you're looking for * @param applyLifecycle if lifecycle should be applied to the returned object. * Passing {@code true} doesn't guarantee that the lifecycle is applied * @return object or {@code null} if not found */ @SuppressWarnings("unchecked") @Override public Object lookupObject(String key, boolean applyLifecycle) { if (StringUtils.isBlank(key)) { logger.warn(createStaticMessage("Detected a lookup attempt with an empty or null key").getMessage(), new Throwable().fillInStackTrace()); return null; } if (key.equals(SPRING_APPLICATION_CONTEXT) && applicationContext != null) { return applicationContext; } else { Object object; try { object = applicationContext.getBean(key); } catch (NoSuchBeanDefinitionException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } return null; } if (applyLifecycle && !applicationContext.isSingleton(key)) { try { getLifecycleManager().applyCompletedPhases(object); } catch (Exception e) { throw new MuleRuntimeException( createStaticMessage("Could not apply lifecycle into prototype object " + key), e); } } return object; } }
From source file:org.pentaho.platform.plugin.services.pluginmgr.DefaultPluginManager.java
@Override public IContentGenerator getContentGenerator(String type, String perspectiveName) { IContentGenerator cg = null;//from www . j a va 2 s . c o m if (perspectiveName == null || perspectiveName.equals(DEFAULT_PERSPECTIVE)) { cg = (IContentGenerator) getBean(type, IContentGenerator.class); } else { String beanId = (perspectiveName == null) ? type : type + "." + perspectiveName; //$NON-NLS-1$ try { cg = (IContentGenerator) getBean(beanId, IContentGenerator.class); } catch (NoSuchBeanDefinitionException e) { // fallback condition, look for a type agnostic content generator try { cg = (IContentGenerator) getBean(perspectiveName, IContentGenerator.class); } catch (NoSuchBeanDefinitionException e2) { throw new NoSuchBeanDefinitionException( "Failed to find bean: " + e.getMessage() + " : " + e2.getMessage()); } } } return cg; }