Hibernate version: 3.2.1 & 3.2.2
Hello new to hibernate and I am having issues with configuring hibernate3 with spring.
I am getting the following exception when I run my standalone app in Eclipse
Code:
Caused by: java.lang.NullPointerException
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:144)
at org.hibernate.cfg.Environment.<clinit>(Environment.java:515)
looking @ line 144 in ConfigHelper I noted
Code:
public static InputStream getResourceAsStream(String resource) {
String stripped = resource.startsWith("/") ?
resource.substring(1) : resource;
InputStream stream = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader!=null) {
stream = classLoader.getResourceAsStream( stripped );
}
if ( stream == null ) {
stream = Environment.class.getResourceAsStream( resource );
}
if ( stream == null ) {
stream = Environment.class.getClassLoader().getResourceAsStream( stripped ); // THIS IS LINE 144
}
if ( stream == null ) {
throw new HibernateException( resource + " not found" );
}
return stream;
}
I am using Spring 2.0 to configure the SessionFactory as below.
Code:
<beans>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc3:postgresql://127.0.0.1:5432/oai"/>
<property name="username" value="xxx"/>
<property name="password" value="xxx"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" lazy-init="false">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>oai.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
</props>
</property>
</bean>
</beans>
thanks in advance for any and all help