-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: NullPointerException Spring 2.0 + Hibernate 3.2.x
PostPosted: Fri Feb 02, 2007 3:35 pm 
Newbie

Joined: Fri Feb 02, 2007 12:22 pm
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 12:17 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi chapman,

use debug feature of eclipse.Might be Environment.class.getClassLoader() getting as null.

_________________
Dharmendra Pandey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.