Exception in thread "main" java.lang.NullPointerException
at com.hibernate.UserDAO.findAll(UserDAO.java:154)
at test.main(test.java:12)
I am getting this error when trying to do anything with any of my DAOs any ideas? Thanks in advance!
Here's my Data source in my Spring applicationContext.xml file.
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://cs180admin.db.5875115.hostedresource.com:3306/cs180admin">
</property>
<property name="username" value="xxxxx"></property>
<property name="password" value="xxxxx"></property>
</bean>
Myeclipse connects to the database fine because I am able to reverse engineer it.
Test.java that I am using to test that throws error.
import com.hibernate.UserDAO;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
UserDAO dao = new UserDAO();
System.out.println(dao.findAll());
}
}
Edit:
UserDAO.java
public List findAll() {
log.debug("finding all User instances");
try {
String queryString = "from User";
Line 154 --> return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
The Line isn't commented out, I just did the arrow to show where the error is happening.