title: java.lang.ClassCastException: java.lang.String cannot be cast to com.example.service.AlbumService
body: <p>I using spring mvc and hibernate xml mapping. And I have error about  in jsp:</p>
  
  <p>My jsp (storeManager.jsp):</p>
  
  <pre><code>&lt;jsp:useBean id="albumService" type="com.example.service.AlbumService" scope="request" /&gt;
  
  &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Genre&lt;/th&gt;
              &lt;th&gt;Artist&lt;/th&gt;
              &lt;th&gt;Title&lt;/th&gt;
              &lt;th&gt;Price&lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
          &lt;tr&gt;
          &lt;%for (Album myAlbum : albumService.getAllAlbums()) { %&gt;
              &lt;%int tempGenreId = myAlbum.getGenreId().getGenreId(); %&gt;
              &lt;%int tempArtistId = myAlbum.getArtistid().getArtistid(); %&gt;
              &lt;td&gt;&lt;%=albumService.findGenreByIdFromAlbumRepository(tempGenreId).getName()%&gt;&lt;/td&gt;
              &lt;td&gt;&lt;%=albumService.findArtistByIdFromAlbumRepository(tempArtistId).getName()%&gt;&lt;/td&gt;
              &lt;td&gt;&lt;%=myAlbum.getTitle()%&gt;&lt;/td&gt;
              &lt;td&gt;&lt;%=myAlbum.getPrice()%&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="EditAlbum?editAlbumId=&lt;%=myAlbum.getAlbumId()%&gt;"&gt;Edit&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="DetailsAlbum?detailsAlbumId=&lt;%=myAlbum.getAlbumId()%&gt;"&gt;Details&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="DeleteAlbum?deleteAlbumId=&lt;%=myAlbum.getAlbumId()%&gt;"&gt;Delete&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;%}%&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And my Controller(StoreManagerController.java)</p>
  
  <pre><code>@Controller
  @RequestMapping("/StoreManager")
  public class StoreManagerController 
  {
  @Autowired
  private AlbumService albumService;
  
  @Autowired
  private GenreService genreService;
  
  @Autowired
  private ArtistService artistService;
  
  @RequestMapping(value="/", method = RequestMethod.GET)
  public ModelAndView getStoreManagerPage(HttpServletRequest request, HttpSession session,ModelMap model) {
  
      logger.debug("JUST GOT STORE MANAGER PAGE");
  
      List&lt;Album&gt; albumList = albumService.getAllAlbums();
      model.put("albumList", albumList);
  
      return new ModelAndView("storeManager", "albumService" , "albumService");
  }
  </code></pre>
  
  <p>When I deploy and run. it happent a error following:</p>
  
  <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/storeManager.jsp at line 18
  
  15: &lt;%@page import="java.util.List" %&gt;
  16: &lt;%@page import="java.util.Map" %&gt;
  17: 
  18: &lt;jsp:useBean id="albumService" type="com.example.service.AlbumService" scope="request" /&gt;
  19: 
  20: 
  21: &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  
  Stacktrace:
  org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
  org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
  org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  ch.qos.logback.classic.selector.servlet.LoggerContextFilter.doFilter(LoggerContextFilter.java:70)
  
  root cause
  
  java.lang.ClassCastException: java.lang.String cannot be cast to com.example.service.AlbumService
  org.apache.jsp.WEB_002dINF.jsp.storeManager_jsp._jspService(storeManager_jsp.java:78)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
  org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
  org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  ch.qos.logback.classic.selector.servlet.LoggerContextFilter.doFilter(LoggerContextFilter.java:70)
  </code></pre>
  
  <p>How can I solve this error? </p>