title: Error creating bean with name '...' defined in file
body: <p>can anyone help me with this</p>
  
  <p>I used IntelliJ Idea Ultimate with Spring MVC and DAO</p>
  
  <p>Error message:</p>
  
  <pre><code>"/media/vlad/36BCE079BCE034D1/Tomcat 7.0.62/bin/catalina.sh" run
  Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
  [2015-07-07 11:05:09,425] Artifact SibiuNewsAggregator:war exploded: Server is not connected. Deploy is not available.
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Server version:        Apache Tomcat/7.0.62
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Server built:          May 7 2015 17:14:55 UTC
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Server number:         7.0.62.0
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: OS Name:               Linux
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: OS Version:            3.19.0-21-generic
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Architecture:          amd64
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Java Home:             /usr/lib/jvm/java-8-oracle/jre
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: JVM Version:           1.8.0_45-b14
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: JVM Vendor:            Oracle Corporation
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: CATALINA_BASE:         /home/vlad/.IntelliJIdea14/system/tomcat/Unnamed_SibiuNewsAggregator
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: CATALINA_HOME:         /media/vlad/36BCE079BCE034D1/Tomcat 7.0.62
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -javaagent:/usr/share/java/jayatanaag.jar
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Djava.util.logging.config.file=/home/vlad/.IntelliJIdea14/system/tomcat/Unnamed_SibiuNewsAggregator/conf/logging.properties
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcom.sun.management.jmxremote=
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcom.sun.management.jmxremote.port=1099
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcom.sun.management.jmxremote.ssl=false
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Djava.rmi.server.hostname=127.0.0.1
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Djava.endorsed.dirs=/media/vlad/36BCE079BCE034D1/Tomcat 7.0.62/endorsed
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcatalina.base=/home/vlad/.IntelliJIdea14/system/tomcat/Unnamed_SibiuNewsAggregator
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcatalina.home=/media/vlad/36BCE079BCE034D1/Tomcat 7.0.62
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Djava.io.tmpdir=/media/vlad/36BCE079BCE034D1/Tomcat 7.0.62/temp
  Jul 07, 2015 11:05:10 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/vlad/IntelliJ IDEA 14.1.4(Linux)/bin::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
  Jul 07, 2015 11:05:10 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  Jul 07, 2015 11:05:10 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 725 ms
  Jul 07, 2015 11:05:10 AM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Jul 07, 2015 11:05:10 AM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.62
  Jul 07, 2015 11:05:10 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Jul 07, 2015 11:05:10 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Jul 07, 2015 11:05:10 AM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 65 ms
  Connected to server
  [2015-07-07 11:05:10,607] Artifact SibiuNewsAggregator:war exploded: Artifact is being deployed, please wait...
  Jul 07, 2015 11:05:10 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
  INFO: validateJarFile(/media/vlad/36BCE079BCE034D1/iQuest_project/iQuest_project_final/iQuest_final_3/Project/target/SibiuNewsAggregator/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
  Jul 07, 2015 11:05:12 AM org.apache.catalina.startup.TldConfig execute
  INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
  Jul 07, 2015 11:05:12 AM org.springframework.web.context.ContextLoader initWebApplicationContext
  INFO: Root WebApplicationContext: initialization started
  Jul 07, 2015 11:05:12 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
  INFO: Refreshing Root WebApplicationContext: startup date [Tue Jul 07 11:05:12 EEST 2015]; root of context hierarchy
  Jul 07, 2015 11:05:12 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
  INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/database-config.xml]
  Jul 07, 2015 11:05:12 AM org.springframework.web.context.support.XmlWebApplicationContext refresh
  WARNING: Exception encountered during context initialization - cancelling refresh attempt
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DBCTemplate' defined in file [/media/vlad/36BCE079BCE034D1/iQuest_project/iQuest_project_final/iQuest_final_3/Project/target/SibiuNewsAggregator/WEB-INF/classes/com/iquest/news/dao/DBCTemplate.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.iquest.news.dao.DBCTemplate]: Constructor threw exception; nested exception is java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1095)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1040)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
      at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
      at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
      at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
      at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
      at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
      at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
      at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
      at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
      at sun.rmi.transport.Transport$1.run(Transport.java:200)
      at sun.rmi.transport.Transport$1.run(Transport.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$241(TCPTransport.java:683)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/1334101548.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.iquest.news.dao.DBCTemplate]: Constructor threw exception; nested exception is java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1088)
      ... 59 more
  Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
      at com.iquest.news.dao.DBCTemplate.&lt;init&gt;(DBCTemplate.java:22)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
      ... 61 more
  
  
  
  Jul 07, 2015 11:05:12 AM org.apache.catalina.core.StandardContext startInternal
  SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
  Jul 07, 2015 11:05:12 AM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [] startup failed due to previous errors
  [2015-07-07 11:05:12,959] Artifact SibiuNewsAggregator:war exploded: Error during artifact deployment. See server log for details.
  Jul 07, 2015 11:05:20 AM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /media/vlad/36BCE079BCE034D1/Tomcat 7.0.62/webapps/manager
  Jul 07, 2015 11:05:20 AM org.apache.catalina.startup.TldConfig execute
  INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
  Jul 07, 2015 11:05:20 AM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deployment of web application directory /media/vlad/36BCE079BCE034D1/Tomcat 7.0.62/webapps/manager has finished in 73 ms
  </code></pre>
  
  <p>And here are my classes:
  DCBTemplate:</p>
  
  <pre><code>package com.iquest.news.dao;
  
  import com.iquest.news.model.Author;
  import com.iquest.news.model.Category;
  import com.iquest.news.model.News;
  import com.iquest.news.model.Statistics;
  import org.hibernate.SessionFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Repository;
  
  import java.lang.reflect.ParameterizedType;
  import java.lang.reflect.Type;
  import java.util.List;
  
  @Repository
  public class DBCTemplate&lt;T&gt; implements DAO&lt;T&gt; {
  
      private Class&lt;T&gt; clazz;
  
      public DBCTemplate() {
          final Type type = getClass().getGenericSuperclass();
          final ParameterizedType parameterizedType = (ParameterizedType) type;
          clazz = (Class) parameterizedType.getActualTypeArguments()[0];
      }
  
      @Autowired
      private SessionFactory sessionFactory;
  
      @Override
      public void add(T news) {
          sessionFactory.getCurrentSession().save(news);
      }
  
      @Override
      public T getItem(long id) {
          T news = (T) sessionFactory.getCurrentSession().get(clazz.getClass(), id);
          return news;
      }
  
      @SuppressWarnings("JpaQlInspection")
      @Override
      public List&lt;T&gt; getAll() {
          return sessionFactory.getCurrentSession().createQuery("from" + clazz.getName()).list();
      }
  
      @Override
      public void delete(long id) {
          T news = getItem(id);
          if (news != null)
              sessionFactory.getCurrentSession().delete(news);
      }
  
      @Override
      public void update(long id, T newNews) {
          if (newNews instanceof News) {
              News oldNews = (News) getItem(((News) newNews).getId());
              oldNews.setTitle(((News) newNews).getTitle());
              oldNews.setSubtitle(((News) newNews).getSubtitle());
              oldNews.setDescription(((News) newNews).getDescription());
              oldNews.setStart_date(((News) newNews).getStart_date());
              oldNews.setEnd_date(((News) newNews).getEnd_date());
              oldNews.setAuthor_id(((News) newNews).getAuthor_id());
              oldNews.setCategory_id(((News) newNews).getCategory_id());
              sessionFactory.getCurrentSession().update(oldNews);
          }
          else if(newNews instanceof Author){
              Author oldNews = (Author) getItem(((Author) newNews).getId());
              oldNews.setName(((Author) newNews).getName());
              sessionFactory.getCurrentSession().update(oldNews);
          }
          else if(newNews instanceof Category){
              Category oldNews = (Category) getItem(((Category) newNews).getId());
              oldNews.setName(((Category) newNews).getName());
              sessionFactory.getCurrentSession().update(oldNews);
          }
          else if(newNews instanceof Statistics){
              Statistics oldNews = (Statistics) getItem(((Statistics) newNews).getId());
              oldNews.setLast_scanned(((Statistics) newNews).getLast_scanned());
              oldNews.setUrl(((Statistics) newNews).getUrl());
              sessionFactory.getCurrentSession().update(oldNews);
          }
      }
  
      public SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  
      public void setSessionFactory(SessionFactory sessionFactory) {
          this.sessionFactory = sessionFactory;
      }
  }
  </code></pre>
  
  <p>XML for beans:</p>
  
  <pre><code>&lt;beans xmlns:mvc="http://www.springframework.org/schema/mvc"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns="http://www.springframework.org/schema/beans"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;mvc:annotation-driven/&gt;
      &lt;context:component-scan base-package="com.iquest.news.controller"/&gt;
  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/pages/"/&gt;
          &lt;property name="suffix" value=".jsp"/&gt;
      &lt;/bean&gt;
  
      &lt;bean class="com.iquest.news.dao.DBCTemplate" id = "DBCTemplate"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>So that's my problem, can anyone show me how I can fix it? 
  Thx in advance</p>