Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean : java.lang.NoSuchFieldError: NULL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean : java.lang.NoSuchFieldError: NULL

    Hi,

    have a question on the bean instantiation. I am using spring 3.1.0.M2. I am trying to do bean instantiattion and I am failing with the error below.

    bean with name 'org.springframework.context.config.internalBeanCo nfigurerAspect'
    2012-01-06 07:31:15,508 ERROR main org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'testbean' defined in ServletContext resource [/WEB-INF/spring-config-context.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: NULL
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
    at

    My TestBean class contain only a single setter with a String property. If I do not use proeprty in my spring-config-context.xml bean is able to instantiate but if i us eproperty likle this, I get the above error.

    <bean id="testBean" class="com.my.test.TestBean">
    <property name="myProp"><value>myvalue</value></property>
    </bean>


    my class

    public class TestBean {

    private String myProp;
    public void setMyProp(String myProp){
    this.myProp = myProp;
    }

    my web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- This web.xml file is not required when using Servlet 3.0 container,
    see implementation details http://jersey.java.net/nonav/documen...rs.html#d4e194 -->
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>api-war</display-name>
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    <servlet>
    <servlet-name>api</servlet-name>
    <servlet-class>com.sun.jersey.spi.spring.container.servlet. SpringServlet</servlet-class>

    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/spring-config-context.xml
    </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>api</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationContext.xml
    </param-value>


    </context-param>

    </web-app>

    can someone pls shed some light.

    thanks.

  • #2
    Try adding a public getter for the property, in addition to the setter.

    Comment

    Working...
    X