reset password
Author Message
liangxu
Posts: 15
Posted 11:47 May 08, 2009 |

I am getting a java.lang.NullPointerException in BlogValidator  when I try to creat a blog.

the exception happens  in the code line:

Blog oldBlog = blogDao.getBlogByTitle( title );

it even didn't get to the blogDaoImp.getBlogByTitle() level,  seems the system couldn't successfully assign a blogDao for it?

The log is attached below.  Please help!  Thanks a lot.

 

Attachments:
cysun
Posts: 2935
Posted 12:29 May 08, 2009 |

Did you wire blogDao to the validator?

liangxu
Posts: 15
Posted 13:02 May 08, 2009 |

I think so.   In the BlogValidator class,  I have 

protected BlogDao blogDao;

public void setBlogDao (BlogDao blogDao){}

and in spring-servlet.xml, I defined

<bean id="blogValidator"
        class="csns.spring.validator.BlogValidator">
        <property name="blogDao" ref="blogDao" />
    </bean>

anywhere else I need to "wire" the blogDao to the Validator?

Thanks!

 

cysun
Posts: 2935
Posted 13:48 May 08, 2009 |
liangxu wrote:

I think so.   In the BlogValidator class,  I have 

protected BlogDao blogDao;

public void setBlogDao (BlogDao blogDao){}

and in spring-servlet.xml, I defined

<bean id="blogValidator"
        class="csns.spring.validator.BlogValidator">
        <property name="blogDao" ref="blogDao" />
    </bean>

anywhere else I need to "wire" the blogDao to the Validator?

Thanks!

No, that should do it. If you are certain it's blogDao that causes the NullPointerException, try refresh the project, restart Eclipse etc. - sometimes Eclipse doesn't pick up the changes in the code.