Announcement Announcement Module
Collapse
No announcement yet.
Data Access using Hibernate -- No SessionFactory specified Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Access using Hibernate -- No SessionFactory specified

    I am following the examples given in Springs Reference Manual. Even though everything looks fine, I am getting java.lang.IllegalArgumentException: No SessionFactory specified
    while selecting a single row from a table.
    Here's my ContextFile content.

    <beans>
    <bean id="aeroController" class="com.xxx.xxx.AeroControllerServlet">
    </bean>


    <bean id="aeroDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName" value="aeroPool"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource" >
    <ref local="aeroDataSource"/>
    </property>
    <property name="mappingResources">
    <list>
    <value>webuser.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.O racle9Dialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    </bean>

    <!-- Hibernate Transaction Manager -->
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <!-- Session Factory Interceptor -->
    <bean id="hibernateInterceptor"
    class="org.springframework.orm.hibernate.Hibernate Interceptor">
    <property name="sessionFactory">
    <ref bean="sessionFactory"/>
    </property>
    </bean>

    <!-- Transaction Manager Interceptor -->
    <bean id="transactionInterceptor"
    class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager">
    <ref local="transactionManager" />
    </property>
    <property name="transactionAttributeSource">
    <value>
    com.AeroWebUserServiceImpl.findUser=PROPAGATION_RE QUIRED,-AeroUserDAOException
    </value>
    </property>
    </bean>

    <!-- UserLogonDAO -->
    <bean id="webUserDAO"
    class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>com.xxx.xxx.AeroWebUserDAO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>hibernateInterceptor</value>
    <value>transactionInterceptor</value>
    <value>aeroUserDaoImpl</value>
    </list>
    </property>
    </bean>
    <bean id="aeroUserDaoImpl" class="com.xxx.xxx.AeroWebUserDAOImpl">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>
    <!-- User Service -->
    <bean id="userService"
    class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>com.xxx.xxx.AeroWebUserService</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>transactionInterceptor</value>
    <value>userServiceTarget</value>
    </list>
    </property>
    </bean>
    <bean id="userServiceTarget"
    class="com.xxx.xxx.AeroWebUserServiceImpl">
    <property name="webUserDAO">
    <ref bean="webUserDAO"/>
    </property>
    </bean>

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="/login.do">aeroController</prop>
    </props>
    </property>
    </bean>
    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass"><value>org.springframework.web.se rvlet.view.JstlView</value></property>
    <property name="prefix"><value>/WEB-INF/jsp/</value></property>
    <property name="suffix"><value>.jsp</value></property>
    </bean>
    <bean id="messageSource" class="org.springframework.context.support.Resourc eBundleMessageSource">
    <property name="basename"><value>messages</value></property>
    </bean>
    </beans>

    And here my code for accessing database table :
    1. Code from DAOImpl

    Session session = SessionFactoryUtils.getSession(getSessionFactory() ,false) ;
    Criteria criteria = session.createCriteria(AeroWebUser.class);
    criteria.add(Expression.eq("webLoginName",userName ));
    criteria.add(Expression.eq("webPassword",userPassw ord));
    criteria.setMaxResults(1);

    Can anyone give me idea, what's going wrong ?

    Thanks,

    Thackkr

  • #2
    Where do you wire up DAOImpl - or was that just an abbreviation for com.xxx.xxx.AeroWebUserDAOImpl.

    Can you also post the stack trace?

    Comment


    • #3
      Data Access using Hibernate -- No SessionFactory specified

      It's wired at : <bean id="webUserDAO"

      Btw, here's the stakeTrace -----


      05/10/06 18:10:17 at com.ids.aerospace.services.impl.AeroWebUserService Impl.findUser(AeroWebUserServiceImpl.java:48)

      05/10/06 18:10:17 at com.ids.aerospace.servlet.AeroControllerServlet.ha ndleRequest(AeroControllerServlet.java:83)

      05/10/06 18:10:17 at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)

      05/10/06 18:10:17 at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:684)

      05/10/06 18:10:17 at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)

      05/10/06 18:10:17 at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)

      05/10/06 18:10:17 at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:355)

      05/10/06 18:10:17 at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)

      05/10/06 18:10:17 at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)

      05/10/06 18:10:17 at com.evermind.server.http.ResourceFilterChain.doFil ter(ResourceFilterChain.java:65)

      05/10/06 18:10:17 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unkn own Source)

      05/10/06 18:10:17 at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:649)

      05/10/06 18:10:17 at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:322)

      05/10/06 18:10:17 at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:790)

      05/10/06 18:10:17 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:270)

      05/10/06 18:10:17 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112)

      05/10/06 18:10:17 at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:192)

      05/10/06 18:10:17 at java.lang.Thread.run(Thread.java:534)

      05/10/06 18:10:17 java.lang.IllegalArgumentException: No SessionFactory specified

      05/10/06 18:10:17 at org.springframework.util.Assert.notNull(Assert.jav a:90)

      05/10/06 18:10:17 at org.springframework.orm.hibernate.SessionFactoryUt ils.getSession(SessionFactoryUtils.java:257)

      05/10/06 18:10:17 at org.springframework.orm.hibernate.SessionFactoryUt ils.getSession(SessionFactoryUtils.java:194)

      05/10/06 18:10:17 at com.ids.aerospace.DAO.impl.AeroWebUserDAOImpl.find User(AeroWebUserDAOImpl.java:66)

      05/10/06 18:10:17 at com.ids.aerospace.services.impl.AeroWebUserService Impl.findUser(AeroWebUserServiceImpl.java:48)

      05/10/06 18:10:17 at com.ids.aerospace.servlet.AeroControllerServlet.ha ndleRequest(AeroControllerServlet.java:83)

      05/10/06 18:10:17 at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)

      05/10/06 18:10:17 at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:684)

      05/10/06 18:10:17 at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)

      05/10/06 18:10:17 at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)

      05/10/06 18:10:17 at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:355)

      05/10/06 18:10:17 at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)

      05/10/06 18:10:17 at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)

      05/10/06 18:10:17 at com.evermind.server.http.ResourceFilterChain.doFil ter(ResourceFilterChain.java:65)

      05/10/06 18:10:17 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unkn own Source)

      05/10/06 18:10:17 at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:649)

      05/10/06 18:10:17 at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:322)

      05/10/06 18:10:17 at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:790)

      05/10/06 18:10:17 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:270)

      05/10/06 18:10:17 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112)

      05/10/06 18:10:17 at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:192)

      05/10/06 18:10:17 at java.lang.Thread.run(Thread.java:534)

      Comment


      • #4
        ...AeroWebUserServiceImpl.java:48)
        Is this the top of the stack? Can you post that part of the code?

        Comment


        • #5
          katentim,

          Sorry for the delay... I have switched from hibernate to simple JDBC. But stil I am facing problems.. I could workaround on it, by getting datasource from context. But still wondering why it failed in first place. I am here by giving all the code which is referred and the context file also.. (This is all code, when it's failing)..

          1. Application Context ------------------

          <beans>


          <bean id="aeroController" class="com.ids.aerospace.servlet.AeroControllerSer vlet">
          <property name="userService">
          <ref bean="userService"/>
          </property>
          </bean>



          <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
          <property name="driverClassName">
          <value>oracle.jdbc.OracleDriver</value>
          </property>
          <property name="url">
          <value>jdbc:oracle:thin:@atlas:1521:lg</value>
          </property>
          <property name="username"><value>aero</value></property>
          <property name="password"><value>aero</value></property>
          </bean>

          <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" singleton="true">
          <property name="dataSource"><ref local="dataSource" /></property>
          </bean>

          <bean id="aeroUserDao" class="com.ids.aerospace.DAO.impl.AeroWebUserDAOIm pl">
          <property name="dataSource">
          <ref bean="dataSource"/>
          </property>
          </bean>

          <bean id="userService"
          class="com.ids.aerospace.services.impl.AeroWebUser ServiceImpl">
          <property name="aeroUserDao">
          <ref local="aeroUserDao"/>
          </property>
          </bean>

          <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
          <property name="mappings">
          <props>
          <prop key="/logon.do">aeroController</prop>
          </props>
          </property>
          </bean>

          <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
          <property name="viewClass"><value>org.springframework.web.se rvlet.view.JstlView</value></property>
          <property name="prefix"><value>/WEB-INF/jsp/</value></property>
          <property name="suffix"><value>.jsp</value></property>
          </bean>
          <bean id="messageSource" class="org.springframework.context.support.Resourc eBundleMessageSource">
          <property name="basename"><value>messages</value></property>
          </bean>
          </beans>

          2. Code from Controller Servlet (Calls a Service Implementation, AeroWebUserService) ------------------

          public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {

          logger.info("Controller - returning hello view");

          try
          {
          String userName = (String)request.getParameter("username");
          String userPassword = (String)request.getParameter("password");
          String userEvent = (String)request.getParameter("userEvent") ;

          logger.info("UserEvent from Login page " + (String)request.getParameter("userEvent"));
          logger.info("UserName from Login page " + (String)request.getParameter("username"));
          logger.info("Password from Login page " + (String)request.getParameter("password"));

          //userService = (AeroWebUserService)AeroWebUserServiceImpl.class.n ewInstance() ;

          System.out.println("In Controller1") ;

          if(userEvent.equals("login"))
          {
          System.out.println("In Controller2") ;

          WebApplicationContext wac = getApplicationContext(request) ;

          userService = (AeroWebUserService)wac.getBean("userService") ;
          //ds = (DataSource)wac.getBean("dataSource");

          loginUser = userService.findUser(userName, userPassword ) ;


          if(loginUser != null)
          {
          userFiscalYears = userService.getFiscalYears(userName) ;
          loginUser.setFiscalYears(userFiscalYears);
          request.getSession().setAttribute("user",loginUser ) ;
          System.out.println("User validated " + loginUser.getWebLoginName()) ;
          Iterator iter = userFiscalYears.iterator() ;
          for( int i = 0 ; i < userFiscalYears.size() ; i++)
          {
          System.out.println("Fiscal Years " + userFiscalYears.get(i) ) ;
          }

          }
          }
          }
          catch(AeroUserDAOException ae)
          {
          logger.error("Invalid Login " + ae.getMessage());
          }
          catch(Exception e)
          {
          System.out.println("############################## ###") ;
          e.printStackTrace();
          }

          return new ModelAndView("AeroMainFrame.jsp");

          }

          public void setUserService(AeroWebUserService userService)
          {
          this.userService = userService;
          }


          public AeroWebUserService getUserService()
          {
          return userService;
          }

          3. Here's the DAO Implementation ------------------------------------

          public AeroWebUser findUser(String userName, String userPassword)
          throws AeroUserDAOException
          {
          AeroWebUser user = new AeroWebUser();
          int userCount = 0 ;
          Iterator lstIter ;
          System.out.println("In DAOImpl") ;

          try
          {
          jt = getJdbcTemplate();
          dataSource = getDataSource() ;

          System.out.println("Data Source --> " + dataSource.toString()) ;
          System.out.println("JDBCTemplate --> " + jt.toString()) ;

          jt.setDataSource(dataSource);

          //user = (AeroWebUser)jt.queryForObject("Select WEB_LOGIN_NAME, WEB_PASSWORD from AERO_WEB_USER WHERE WEB_LOGIN_NAME ='" +
          //userName + "' AND WEB_PASSWORD = '" + userPassword + "'",AeroWebUser.class) ;

          userCount = jt.queryForInt("Select count(*) from AERO_WEB_USER WHERE upper(WEB_LOGIN_NAME) ='" +
          userName.toUpperCase() + "' AND upper(WEB_PASSWORD) = '" + userPassword.toUpperCase() + "'") ;

          if(userCount > 0)
          {
          user.setWebLoginName(userName);
          user.setWebPassword(userPassword);
          }
          }
          catch(Exception e)
          {
          e.printStackTrace();
          throw new AeroUserDAOException(e.getMessage(),e) ;
          }

          return user ;

          }

          I think, i am not doing something right in the context file itself. But, pls have a look and let me know, if you can sort out.
          As i said before, it works when i pass the datasource all the way from Controller Servlet.

          Thanks,

          Thacker

          Comment


          • #6
            Sorry.. Missed the StakeTrace in previous posting

            Here it is ----------------------------------------------------------

            05/10/10 14:21:39 java.lang.NullPointerException

            05/10/10 14:21:39 at com.ids.aerospace.DAO.impl.AeroWebUserDAOImpl.find User(AeroWebUserDAOImpl.java:70)

            05/10/10 14:21:39 at com.ids.aerospace.services.impl.AeroWebUserService Impl.findUser(AeroWebUserServiceImpl.java:51)

            05/10/10 14:21:39 at com.ids.aerospace.servlet.AeroControllerServlet.ha ndleRequest(AeroControllerServlet.java:93)

            05/10/10 14:21:39 at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)

            05/10/10 14:21:39 at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:684)

            05/10/10 14:21:39 at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)

            05/10/10 14:21:39 at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)

            05/10/10 14:21:39 at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:355)

            05/10/10 14:21:39 at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)

            05/10/10 14:21:39 at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)

            05/10/10 14:21:39 at com.evermind.server.http.ResourceFilterChain.doFil ter(ResourceFilterChain.java:65)

            05/10/10 14:21:39 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unkn own Source)

            05/10/10 14:21:39 at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:649)

            05/10/10 14:21:39 at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:322)

            05/10/10 14:21:39 at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:790)

            05/10/10 14:21:39 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:270)

            05/10/10 14:21:39 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112)

            2005-10-10 14:21:39,920 ERROR [com.ids.aerospace.services.impl.AeroWebUserService Impl] - <Invalid Login null>

            05/10/10 14:21:39 at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:192)

            05/10/10 14:21:39 at java.lang.Thread.run(Thread.java:534)

            05/10/10 14:21:39 java.lang.NullPointerException

            05/10/10 14:21:39 at com.ids.aerospace.DAO.impl.AeroWebUserDAOImpl.find User(AeroWebUserDAOImpl.java:70)

            05/10/10 14:21:39 at com.ids.aerospace.services.impl.AeroWebUserService Impl.findUser(AeroWebUserServiceImpl.java:51)

            05/10/10 14:21:39 at com.ids.aerospace.servlet.AeroControllerServlet.ha ndleRequest(AeroControllerServlet.java:93)

            05/10/10 14:21:39 at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)

            05/10/10 14:21:39 at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:684)

            05/10/10 14:21:39 at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)

            05/10/10 14:21:39 at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)

            05/10/10 14:21:39 at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:355)

            05/10/10 14:21:39 at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)

            05/10/10 14:21:39 at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)

            05/10/10 14:21:39 at com.evermind.server.http.ResourceFilterChain.doFil ter(ResourceFilterChain.java:65)

            05/10/10 14:21:39 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unkn own Source)

            05/10/10 14:21:39 at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:649)

            05/10/10 14:21:39 at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:322)

            2005-10-10 14:21:39,951 ERROR [com.ids.aerospace.services.impl.AeroWebUserService Impl] - <Invalid Login null>

            05/10/10 14:21:39 at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:790)

            05/10/10 14:21:39 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:270)

            05/10/10 14:21:39 at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112)

            05/10/10 14:21:39 at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:192)

            05/10/10 14:21:39 at java.lang.Thread.run(Thread.java:534)

            Comment


            • #7
              Sorry.. Missed the StakeTrace in previous posting
              What happened to the IllegalArgumentException?
              Can you post the code for AeroWebUserDAOImpl?

              Comment


              • #8
                As i told you before.. I stopped using Hibernate and using JDBC instead. Hence, I am not accessing session/DataSource usingHibernateDAOSupoort, but accessing datasource using JdbcDAOSupport. Hence, no more Exception for SessionFactory. This time its DataSource.
                Here's the code you needed......

                package com.ids.aerospace.DAO.impl;
                import com.ids.aerospace.DAO.AeroWebUserDAO;
                import com.ids.aerospace.beans.AeroWebUser;
                import com.ids.aerospace.exceptions.AeroUserDAOException;
                import java.util.List;
                import java.util.Iterator;

                import javax.sql.DataSource;
                import net.sf.hibernate.Criteria;
                import net.sf.hibernate.HibernateException;
                import net.sf.hibernate.Session;
                import net.sf.hibernate.SessionFactory;
                import net.sf.hibernate.expression.Expression;

                import org.springframework.jdbc.core.JdbcTemplate;
                import org.springframework.jdbc.core.support.JdbcDaoSuppo rt;
                import org.springframework.orm.hibernate.SessionFactoryUt ils;
                import org.springframework.orm.hibernate.support.Hibernat eDaoSupport;



                public class AeroWebUserDAOImpl extends JdbcDaoSupport implements AeroWebUserDAO
                {

                private JdbcTemplate jt;
                private DataSource dataSource ;

                /**
                * Default Empty Constructor
                */
                public AeroWebUserDAOImpl()
                {
                }

                /**
                * Implementation of findUser method to get valid user Object
                * @throws com.ids.aerospace.exceptions.AeroUserDAOException
                * @return
                * @param userPassword
                * @param userName
                */

                public AeroWebUser findUser(String userName, String userPassword)
                throws AeroUserDAOException
                {
                AeroWebUser user = new AeroWebUser();
                int userCount = 0 ;
                Iterator lstIter ;
                System.out.println("In DAOImpl") ;

                try
                {

                jt = getJdbcTemplate() ;

                this.dataSource = getDataSource() ;

                jt.setDataSource(dataSource) ;


                //user = (AeroWebUser)jt.queryForObject("Select WEB_LOGIN_NAME, WEB_PASSWORD from AERO_WEB_USER WHERE WEB_LOGIN_NAME ='" +
                //userName + "' AND WEB_PASSWORD = '" + userPassword + "'",AeroWebUser.class) ;

                userCount = jt.queryForInt("Select count(*) from AERO_WEB_USER WHERE upper(WEB_LOGIN_NAME) ='" +
                userName.toUpperCase() + "' AND upper(WEB_PASSWORD) = '" + userPassword.toUpperCase() + "'") ;

                if(userCount > 0)
                {
                user.setWebLoginName(userName);
                user.setWebPassword(userPassword);
                }
                }
                catch(Exception e)
                {
                e.printStackTrace();
                throw new AeroUserDAOException(e.getMessage(),e) ;
                }

                return user ;

                }

                public List getFiscalYears(String userName)
                {
                List yearList ;
                StringBuffer yearQuery = new StringBuffer() ;

                jt = getJdbcTemplate() ;

                this.dataSource = getDataSource() ;

                jt.setDataSource(dataSource) ;

                yearQuery.append("select distinct jon_fy from aero_jon ") ;
                yearQuery.append("where jon_no in (select jon_no from aero_web_jon_access where ") ;
                yearQuery.append("upper(web_login_name) = '" + userName.toUpperCase() + "') order by jon_fy") ;

                System.out.println("Fiscal yr Query " + yearQuery.toString()) ;

                yearList = jt.queryForList(yearQuery.toString()) ;

                return yearList ;

                }


                }

                Comment


                • #9
                  public class AeroWebUserDAOImpl extends JdbcDaoSupport implements AeroWebUserDAO
                  {

                  private JdbcTemplate jt;
                  private DataSource dataSource ;
                  You don't need your own JdbcTemplate and DataSource, they are already declared in JdbcDaoSupport. The instance you get through getJdbcTemplate() is already Spring initialized.

                  Comment


                  • #10
                    dejanp,
                    Thanks for your reply. I am not getting JbdcTemplate Locally. I know, it gets initialized by JdbcDAOSupport. Even if I remove that code, i am not getting datasource from context. Pls have a look at my context file. Not sure what's going wrong.
                    Thanks again..

                    Comment


                    • #11
                      Hard to say really. Can you post the code and stacktrace without your own jt and ds? (and please mark the line where you get the npe)

                      Comment

                      Working...
                      X