Initialization of bean failed; nested exception is org.springframework.beans

anand

I Keep my model class in the com.anand.model.Employee.java and correctly I mentioned in the sdnext-servlet.xml for annotatedClasses. But still I am getting the error. Please help me to solve this issue.

sdnext-servlet.xml

<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>com.anand.model.Employee</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>             
            </props>
        </property>
    </bean>

Model Class : Employee.java

package com.anand.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @author Anand Gopalan
 *
 */
@Entity
@Table(name="Employee")
public class Employee implements Serializable{

    private static final long serialVersionUID = -723583058586873479L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name = "empid")
    private Integer empId;

    @Column(name="empname")
    private String empName;

    @Column(name="empaddress")
    private String empAddress;

    @Column(name="salary")
    private Long salary;

    @Column(name="empAge")
    private Integer empAge;

    public Integer getEmpId() {
        return empId;
    }

    public void setEmpId(Integer empId) {
        this.empId = empId;
    }

    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    public String getEmpAddress() {
        return empAddress;
    }

    public void setEmpAddress(String empAddress) {
        this.empAddress = empAddress;
    }

    public Long getSalary() {
        return salary;
    }

    public void setSalary(Long salary) {
        this.salary = salary;
    }

    public Integer getEmpAge() {
        return empAge;
    }

    public void setEmpAge(Integer empAge) {
        this.empAge = empAge;
    }

}

Logs:

SEVERE: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/sdnext-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.lang.Class[]' for property 'annotatedClasses'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.anand.model.Employee] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5229) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5516) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.lang.Class[]' for property 'annotatedClasses'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.anand.model.Employee] at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:457) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1354) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1313) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) ... 26 more Caused by: java.lang.IllegalArgumentException: Cannot find class [com.anand.model.Employee] at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:294) at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:64) at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:474) at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:446) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:215) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:122) at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:485) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:227) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452) ... 30 more Caused by: java.lang.ClassNotFoundException: com.anand.model.Employee at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:291) ... 39 more

Oct 14, 2014 11:40:35 AM org.apache.catalina.core.StandardContext loadOnStartup SEVERE: Servlet /sdnext threw load() exception java.lang.ClassNotFoundException: com.anand.model.Employee at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:291) at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:64) at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:474) at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:446) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:215) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:122) at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:485) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:227) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1354) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1313) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5229) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5516) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

Zeus

This is an alternative to what you have done. Try to replace the annotatedClasses with that of the following element in your config and clean build your workspace after that + restart your server .

<property name="packagesToScan">
    <list>
        <value>com.anand.model</value>           
    </list>
</property>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

org.springframework.beans.NotWritablePropertyException: Invalid property 'adminEmails' of bean class

From Dev

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'authenticationManager' is defined

From Dev

Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector

From Dev

Context initialization failed / Error creating bean with name 'org.springframework.security.filterChains'

From Dev

org.springframework.beans.InvalidPropertyException: Invalid property 'id' of bean class

From Dev

Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name defined in class path resource

From Dev

Exception org.springframework.beans.factory.UnsatisfiedDependencyException

From Dev

Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException

From Dev

Exception org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type is defined: expected single matching bean

From Dev

Spring mvc + hibernate Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean

From Dev

Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field:

From Dev

Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement;

From Dev

org.springframework.beans.NotWritablePropertyException: Invalid property 'xxxx' of bean class :

From Dev

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:

From Dev

Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload

From Dev

Context initialization failed due to org.springframework.core.ResolvableTypeProvider

From Dev

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:

From Dev

Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

From Dev

Error creating bean with name 'mySessionFactory' initialization of bean failed; nested exception is MalformedParameterizedTypeException

From Dev

Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: org/springframework/core/convert/TypeDescriptor.NULL

From Dev

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actelService'

From Dev

Spring ERROR - Context initialization failed: org.springframework.beans.factory.BeanCreationException

From Dev

org.springframework.beans.NotWritablePropertyException: Invalid property 'xxxx' of bean class :

From Dev

HTTP Status 500 - Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException

From Dev

Error creating bean with name 'JobTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreat

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean

From Dev

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'eventpublisher' available

From Dev

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

Related Related

  1. 1

    org.springframework.beans.NotWritablePropertyException: Invalid property 'adminEmails' of bean class

  2. 2

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'authenticationManager' is defined

  3. 3

    Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector

  4. 4

    Context initialization failed / Error creating bean with name 'org.springframework.security.filterChains'

  5. 5

    org.springframework.beans.InvalidPropertyException: Invalid property 'id' of bean class

  6. 6

    Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name defined in class path resource

  7. 7

    Exception org.springframework.beans.factory.UnsatisfiedDependencyException

  8. 8

    Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException

  9. 9

    Exception org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type is defined: expected single matching bean

  10. 10

    Spring mvc + hibernate Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean

  11. 11

    Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field:

  12. 12

    Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement;

  13. 13

    org.springframework.beans.NotWritablePropertyException: Invalid property 'xxxx' of bean class :

  14. 14

    Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:

  15. 15

    Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload

  16. 16

    Context initialization failed due to org.springframework.core.ResolvableTypeProvider

  17. 17

    Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:

  18. 18

    Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException

  19. 19

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name

  20. 20

    Error creating bean with name 'mySessionFactory' initialization of bean failed; nested exception is MalformedParameterizedTypeException

  21. 21

    Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: org/springframework/core/convert/TypeDescriptor.NULL

  22. 22

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actelService'

  23. 23

    Spring ERROR - Context initialization failed: org.springframework.beans.factory.BeanCreationException

  24. 24

    org.springframework.beans.NotWritablePropertyException: Invalid property 'xxxx' of bean class :

  25. 25

    HTTP Status 500 - Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException

  26. 26

    Error creating bean with name 'JobTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreat

  27. 27

    org.springframework.beans.factory.BeanCreationException: Error creating bean

  28. 28

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'eventpublisher' available

  29. 29

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

HotTag

Archive