I've been googling for two days now. Maybe I just need some new eyes on this.
I am new to spring, and I've really searched the forums, but I just can't seem to find the issue. Everything seems to tell me I'm doing it correctly. Possibly I should use Hibernate 3 instead of 4?
Functions in below in PotteryDAOImpl getAllPottery() and getAllPotteryType(String) keep giving me a NullPointerException when called
If you need to see any other files, please let me know.
PotteryDAOImpl.java (if you need to see BOImpl just let me know)
Code:package net.nowakpottery.persistence; import java.util.List; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import net.nowakpottery.persistence.PotteryDAO; @Repository public class PotteryDAOImpl implements PotteryDAO { @Autowired private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public List getAllPottery() { return this.sessionFactory.getCurrentSession().createQuery("from Pottery").list(); } public List getAllPotteryType(String pottery_type) { return this.sessionFactory.getCurrentSession().createQuery("from Pottery where section='"+pottery_type+"'").list(); } }
applicationContext.xml
Current Jar ListCode:<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://localhost:3306/nowakpottery" /> <property name="username" value="root" /> <property name="password" value="049706" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mappingResources"> <list> <value>net/nowakpottery/hibernate/Pottery.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.MySQLDialect </value> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="myPotteryDAO" class="net.nowakpottery.persistence.PotteryDAOImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean>
I don't believe there's any jar issues, but I am not 100% sure.
Code:antlr-2.7.7.jar antlr-runtime-3.0.jar commons-beanutils-1.8.0.jar commons-collections-3.1.jar commons-dbcp-1.4.jar commons-digester-1.8.1.jar commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-logging-1.1.jar commons-pool-1.6.jar dom4j-1.6.1.jar freemarker-2.3.13.jar hibernate-commons-annotations-4.0.1.Final.jar hibernate-core-4.1.5.Final.jar hibernate-jpa-2.0-api-1.0.1.Final.jar javassist-3.15.0-GA.jar jboss-logging-3.1.0.GA.jar jboss-transaction-api_1.1_spec-1.0.0.Final.jar jta-1.1.jar junit-3.8.1.jar mysql-connector-java-3.1.14-bin.jar ognl-2.6.11.jar slf4j-api-1.6.1.jar spring-asm-3.2.0.M1.jar spring-beans-3.2.0.M1.jar spring-context-3.2.0.M1.jar spring-core-3.2.0.M1.jar spring-expression-3.2.0.M1.jar spring-jdbc-3.2.0.M1.jar spring-orm-3.2.0.M1.jar spring-tx-3.2.0.M1.jar spring-web-3.2.0.M1.jar struts2-convention-plugin-2.1.6.jar struts2-core-2.1.6.jar struts2-spring-plugin-2.1.6.jar struts2-tiles-plugin-2.1.6.jar tiles-api-2.1.2.jar tiles-compat-2.1.2.jar tiles-core-2.1.2.jar tiles-jsp-2.1.2.jar tiles-servlet-2.1.2.jar xwork-2.1.2.jar


Reply With Quote
