Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Getting nullpointer exception when Annotation are used for Spring 3

  1. #11
    Join Date
    Dec 2012
    Posts
    10

    Default

    I have specified to scan all Entity and DAO classes in applicationContext.xml

    Code:
    <context:component-scan base-package="net.bapco" />

  2. #12
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I strongly suggest a read of the reference guide (especially on what component-scan does and doesn't do) and rereading my post.

    Quote Originally Posted by mdeinum
    You haven't specified packages to scan on the LocalSessionFactoryBean
    In short component-scan doesn't do anything for @Entities that is the responsiblitiy of the SessionFactory (and as such it needs to be configured).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #13
    Join Date
    Dec 2012
    Posts
    10

    Default

    Thanks for pointing that out. I have added the following
    Code:
    <bean id="SessionFactory"
    		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    		<property name="dataSource" ref="DataSource" />
    		 <property name="annotatedClasses">	
    		  <list>
               <value>net.test.model.Employees</value>
               </list>	
               </property>
    and that problem got resolved. Now next issue is

    Code:
    SEVERE: org.hibernate.exception.GenericJDBCException: Missing IN or OUT parameter at index:: 1

  4. #14
    Join Date
    Dec 2012
    Posts
    10

    Default

    I have resolved all my errors. Thanks a lot for your help and kindness. Very much appreciated.

    I have one doubt though. If component-scan doesn't do anything for @Entities, then do we need to define all Entity classes in applicationContext.xml? Is this the best practice or are there better approaches to this?

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •