Results 1 to 3 of 3
- 12-20-2011, 09:58 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 13
- Rep Power
- 0
Instantiation of bean failed; BeanInstantiationException
I am working on a tutorial and I running a JUnit test on a Java Application that incorporates Spring, JDBC, and Log4j. When I run the JUnit test, I am getting the following error message:
Java Code:Error creating bean with name 'userDAO' defined in file [C:\SpringsDAO\springJdbcDemoTest\config\appContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [user.DAO.Impl.UserDAOImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException
I have reviewed the code several times and I can not determine why the bean is not be instantiated. I am new to Spring, java beans, Log4j, and JUnit testing so there could be something that I am not understanding. I have verified that the spelling of the bean is correct throughout the application. There are no other noticeable errors.
Please find below the xml file:
I have also attached the xml file and the test class that contains the bean (userDAO).Java Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://127.0.0.1:3307/test"/> <property name="username" value="root"/> <property name="password" value="sesame"/> <property name="maxActive" value="10"/> <property name="maxIdle" value="5"/> <property name="minIdle" value="1"/> <property name="poolPreparedStatements" value="true"/> <property name="initialSize" value="1"/> </bean> <bean id= "transactionManager" class= "org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name= "dataSource" ref= "dataSource"/> </bean> <bean id= "userDAO" class="user.DAO.Impl.UserDAOImpl"> <property name= "transactionManager" ref= "transactionManager"/> </bean> </beans>
Thanks for your help in advance.
Best regards,
littleone
- 12-21-2011, 03:17 AM #2
Re: Instantiation of bean failed; BeanInstantiationException
Sounds like the null pointer is happening in the UserDAOImpl class itself. You do have a UserDAOImpl.java file right? Look in there for your null pointer - perhaps you didn't initialize something?
- 12-21-2011, 04:44 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN i
By gurpreet.singh in forum Advanced JavaReplies: 1Last Post: 03-23-2011, 07:55 AM -
Instantiation order
By Jeremy720 in forum New To JavaReplies: 3Last Post: 07-17-2009, 03:19 PM -
UREGENT-accessing session bean ok but entity bean
By parimal in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 08-28-2008, 01:34 PM -
instantiation
By Camden in forum New To JavaReplies: 1Last Post: 03-02-2008, 04:44 PM -
Instantiation
By kavithas in forum New To JavaReplies: 2Last Post: 12-05-2007, 04:56 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks