spring hibernate sessionFactory NullPointerException - spring-mvc

Hi I'm writing an application and I'm getting the following error.
Edit: Complete log
`
Aug 20, 2012 6:37:22 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;F:\SVN\bin\;F:\SVN\Python25\;C:\Program Files\PHP\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Server 5.5\bin;D:\apache-ant-1.8.2\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files\QuickTime\QTSystem\
Aug 20, 2012 6:37:22 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:yogamandir1' did not find a matching property.
Aug 20, 2012 6:37:22 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Aug 20, 2012 6:37:23 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Aug 20, 2012 6:37:23 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1277 ms
Aug 20, 2012 6:37:23 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 20, 2012 6:37:23 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.8
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Aug 20, 2012 6:37:27 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Aug 20 18:37:28 IST 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#d9ceea: defining beans []; root of factory hierarchy
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 582 ms
Aug 20, 2012 6:37:28 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appServlet'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Mon Aug 20 18:37:28 IST 2012]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [jdbc.properties]
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#659078: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,studentDAO,homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#1,org.springframework.format.support.FormattingConversionServiceFactoryBean#1,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#1,org.springframework.web.servlet.handler.MappedInterceptor#1,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#1,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#1,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#1,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,sessionFactory,transactionManager,multipartResolver,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#d9ceea
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/register],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.omkar.yogamandir.web.controllers.HomeController.register(java.util.Locale,org.springframework.ui.Model,com.omkar.yogamandir.web.beans.Student,org.springframework.web.multipart.MultipartFile,org.springframework.validation.BindingResult)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.omkar.yogamandir.web.controllers.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
INFO : org.springframework.jdbc.datasource.DriverManagerDataSource - Loaded JDBC driver: com.mysql.jdbc.Driver
INFO : org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.3.1.GA
INFO : org.hibernate.cfg.Environment - Hibernate 3.2.6
INFO : org.hibernate.cfg.Environment - hibernate.properties not found
INFO : org.hibernate.cfg.Environment - Bytecode provider name : cglib
INFO : org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
INFO : org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: com.omkar.yogamandir.entity.beans.BatchDTO
INFO : org.hibernate.cfg.annotations.EntityBinder - Bind entity com.omkar.yogamandir.entity.beans.BatchDTO on table batch
INFO : org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: com.omkar.yogamandir.entity.beans.StudentDTO
INFO : org.hibernate.cfg.annotations.EntityBinder - Bind entity com.omkar.yogamandir.entity.beans.StudentDTO on table student
INFO : org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
INFO : org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean - Building new Hibernate SessionFactory
INFO : org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
INFO : org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.5.8
INFO : org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.15 ( Revision: ${bzr.revision-id} )
INFO : org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
INFO : org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
INFO : org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO : org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
INFO : org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
INFO : org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
INFO : org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
INFO : org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
INFO : org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
INFO : org.hibernate.cfg.SettingsFactory - Connection release mode: auto
INFO : org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
INFO : org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
INFO : org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
INFO : org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
INFO : org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
INFO : org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO : org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
INFO : org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
INFO : org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
INFO : org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
INFO : org.hibernate.cfg.SettingsFactory - Query cache: disabled
INFO : org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider
INFO : org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
INFO : org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
INFO : org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
INFO : org.hibernate.cfg.SettingsFactory - Statistics: disabled
INFO : org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
INFO : org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
INFO : org.hibernate.cfg.SettingsFactory - Named query checking : enabled
INFO : org.hibernate.impl.SessionFactoryImpl - building session factory
INFO : org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/register],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.omkar.yogamandir.web.controllers.HomeController.register(java.util.Locale,org.springframework.ui.Model,com.omkar.yogamandir.web.beans.Student,org.springframework.web.multipart.MultipartFile,org.springframework.validation.BindingResult)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.omkar.yogamandir.web.controllers.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.orm.hibernate3.HibernateTransactionManager - Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource#89eb77] of Hibernate SessionFactory for HibernateTransactionManager
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 6021 ms
Aug 20, 2012 6:37:34 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 20, 2012 6:37:34 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 20, 2012 6:37:34 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11556 ms
INFO : com.omkar.yogamandir.web.controllers.HomeController - Welcome home! the client locale is en_US
INFO : com.omkar.yogamandir.web.controllers.HomeController - Welcome home! the client locale is en_US
INFO : com.omkar.yogamandir.web.controllers.HomeController - Student Registration!
INFO : com.omkar.yogamandir.entity.dao.StudentDAO - Start: saveStudent() in StudentDAO class
java.lang.NullPointerException
at com.omkar.yogamandir.entity.dao.StudentDAO.saveStudent(StudentDAO.java:27)
at com.omkar.yogamandir.business.StudentBusinessAdapter.insertStudent(StudentBusinessAdapter.java:30)
at com.omkar.yogamandir.web.controllers.HomeController.register(HomeController.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
`
My StudentDAO class:
`package com.omkar.yogamandir.entity.dao;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.omkar.yogamandir.entity.beans.StudentDTO;
#Repository
#Transactional
public class StudentDAO {
private static final Logger logger = LoggerFactory
.getLogger(StudentDAO.class);
#Autowired
private SessionFactory sessionFactory;
public void saveStudent(StudentDTO studentDTO) {
try{
logger.info("Start: saveStudent() in StudentDAO class");
Session session = sessionFactory.getCurrentSession();
session.save(studentDTO);
logger.info("Successfully saved the student!!!");
} catch(Exception e){
e.printStackTrace();
}
}
}`
servlet-context.xml
`<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.omkar.yogamandir" />
<annotation-driven />
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<beans:bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="${jdbc.driverClassName}" />
<beans:property name="url" value="${jdbc.url}" />
<beans:property name="username" value="${jdbc.username}" />
<beans:property name="password" value="${jdbc.password}" />
</beans:bean>
<beans:bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource"></beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">${hibernate.dialect}</beans:prop>
<beans:prop key="hibernate.show_sql">${hibernate.show_sql}</beans:prop>
</beans:props>
</beans:property>
<beans:property name="packagesToScan" value="com.omkar.yogamandir"></beans:property>
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="sessionFactory"></beans:property>
</beans:bean>
<beans:bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<beans:property name="maxUploadSize" value="5000000" />
</beans:bean>
<tx:annotation-driven />
</beans:beans>`
I have all the required jars in classpath. Please have a look at this issue.
sessionFactory is null when I use sessionFactory.getCurrentSession();

You couldn't inject the sessionFactory to studentDAO calss. Check on it

Related

Having troubles sending emails from spring boot application

I have been trying to send email via spring boot and i cant seem to succeed. I am been using javamail api for a long time now but want to use springboot with spring mail.
public class SendMail {
#Autowired
private JavaMailSender javaMailSender;
public void sendingMail(String to, String subject, String body) {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(body);
javaMailSender.send(message);
}
}
and here is my mailer
#Controller
public class ExamPle {
#Autowired
private SendMail sendMail;
#RequestMapping("/he")
public String homePage() {
sendMail.sendingMail("bobobush007#gmail.com", "Welcome George", "Sample Message here");
return "Sent";
}
}
I already have sprint-boot-starter-mail in my pom file but i keep getting this error message. I have even watched youtube videos of tutorials on how to do this and yet it doesn't work. I am using Spring Tool Suite Version: 3.9.0.RELEASE.
Properties file
spring.mail.host=smtp.gmail.com
spring.mail.username=my-email-address
spring.mail.password=my-password
spring.mail.port=587
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.defaultEncoding=UTF-8
2017-09-14 05:25:57.811 INFO 12576 --- [ main]
com.example.demo.EmaildemoApplication : Starting
EmaildemoApplication on Georges-MacBook-Pro.local with PID 12576
(started by georgetebo in /Users/georgetebo/STS Projects/Emaildemo)
2017-09-14 05:25:57.814 INFO 12576 --- [ main]
com.example.demo.EmaildemoApplication : No active profile set,
falling back to default profiles: default 2017-09-14 05:25:57.845
INFO 12576 --- [ main]
ationConfigEmbeddedWebApplicationContext : Refreshing
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3d3fcdb0:
startup date [Thu Sep 14 05:25:57 WAT 2017]; root of context hierarchy
2017-09-14 05:25:58.652 INFO 12576 --- [ main]
s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with
port(s): 8080 (http) 2017-09-14 05:25:58.662 INFO 12576 --- [
main] o.apache.catalina.core.StandardService : Starting service
[Tomcat] 2017-09-14 05:25:58.662 INFO 12576 --- [ main]
org.apache.catalina.core.StandardEngine : Starting Servlet Engine:
Apache Tomcat/8.5.20 2017-09-14 05:25:58.714 INFO 12576 ---
[ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] :
Initializing Spring embedded WebApplicationContext 2017-09-14
05:25:58.714 INFO 12576 --- [ost-startStop-1]
o.s.web.context.ContextLoader : Root WebApplicationContext:
initialization completed in 871 ms 2017-09-14 05:25:58.821 INFO 12576
--- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2017-09-14 05:25:58.823
INFO 12576 --- [ost-startStop-1]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
'characterEncodingFilter' to: [/] 2017-09-14 05:25:58.824 INFO 12576
--- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/] 2017-09-14
05:25:58.824 INFO 12576 --- [ost-startStop-1]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
'httpPutFormContentFilter' to: [/] 2017-09-14 05:25:58.824 INFO
12576 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean :
Mapping filter: 'requestContextFilter' to: [/] 2017-09-14
05:25:58.848 WARN 12576 --- [ main]
ationConfigEmbeddedWebApplicationContext : Exception encountered
during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'examPle': Unsatisfied dependency
expressed through field 'sendMail'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type 'com.example.demo.SendMail' available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations:
{#org.springframework.beans.factory.annotation.Autowired(required=true)}
2017-09-14 05:25:58.850 INFO 12576 --- [ main]
o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-09-14 05:25:58.861 INFO 12576 --- [ main]
utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration
report re-run your application with 'debug' enabled. 2017-09-14
05:25:58.927 ERROR 12576 --- [ main]
o.s.b.d.LoggingFailureAnalysisReporter :
*************************** APPLICATION FAILED TO START
Description:
Field sendMail in com.example.demo.ExamPle required a bean of type
'com.example.demo.SendMail' that could not be found.
Action:
Consider defining a bean of type 'com.example.demo.SendMail' in your
configuration.
This is my Pom file
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.mailsender</groupId>
<artifactId>MailSender</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MailSender</name>
<description>ZemoPoint for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I have uninstalled my jdk as well as STS and installed new copies.Now i get this error
This works.
#Service
public class SendMail {
#Autowired
private JavaMailSender javaMailSender;
public void sendingMail(String to, String subject, String body) {
MimeMessage message=javaMailSender.createMimeMessage();
MimeMessageHelper helper;
helper=new MimeMessageHelper(message,true);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(body);
javaMailSender.send(message);
}}
Have you tried adding javax.mail to your pom ? Spring email sender has a dependency to JavaMail.
I think the password you should use is the Generated app password for gmail, it shouldn't be just any password i guess.
Seems your properties is not fetched properly, for example:
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
You should try to use other way like this:
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(emailProperties.getHost());
mailSender.setPort(Integer.parseInt(emailProperties.getPort()));
mailSender.setUsername(emailProperties.getUsername());
mailSender.setPassword(emailProperties.getPassword());
Properties javaMailProperties = new Properties();
javaMailProperties.put("mail.smtp.starttls.enable", "true");
javaMailProperties.put("mail.smtp.auth", "true");
javaMailProperties.put("mail.transport.protocol", "smtp");
javaMailProperties.put("mail.debug", "true");
mailSender.setJavaMailProperties(javaMailProperties);
See more this way from the post Spring Boot Freemarker Email Template
Hope this help!

No mapping found with #RestController an #RequestMapping

I have the following Controller
#RestController("/person")
public class PersonController {
#Autowired
PersonService personService;
#RequestMapping(value = "/list",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE
)
public List<PersonNode> getPersons(){
return personService.getList();
}
}
Now the spring neo4j config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Scan the JavaConfig -->
<context:annotation-config/>
<context:component-scan base-package="server.infrastructure.repositories.neo4j.config" />
</beans>
and spring mvc rest config:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--Used for Spring MVC configuration - must have-->
<mvc:annotation-driven />
<!-- This shows where to scan for rest controller -->
<context:component-scan base-package="server.api.rest.controller" />
</beans>
and web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Restful Web Application with Spring MVC 4.0.5x</display-name>
<!-- Root App Context -->
<!-- The definition of the Root Spring Context Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/ApplicationContext.xml</param-value>
</context-param>
<!-- Bootstrap the root application context.Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Web App Settings -->
<!-- Processes application requests -->
<servlet>
<servlet-name>MR.rest.api</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/SpringMVC/SpringMVC-RESTContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MR.rest.api</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
However when I refer to http://localhost:8080/rest/person/list i keep getting the:
[http-bio-8080-exec-2] WARN o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/rest/person/list] in DispatcherServlet with name 'MR.rest.api'
with my Tomcat startup log:
...
INFO: Initializing Spring root WebApplicationContext
01:50:55.703 [localhost-startStop-1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started
01:50:55.774 [localhost-startStop-1] INFO o.s.w.c.s.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Wed Dec 16 01:50:55 CET 2015]; root of context hierarchy
01:50:55.805 [localhost-startStop-1] INFO o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/ApplicationContext.xml]
01:50:55.879 [localhost-startStop-1] INFO o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/Neo4j-DataSources.xml]
01:50:56.254 [localhost-startStop-1] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'myNeo4jConfiguration' of type [class server.infrastructure.repositories.neo4j.config.MyNeo4jConfiguration$$EnhancerBySpringCGLIB$$7212f882] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
01:50:56.257 [localhost-startStop-1] INFO o.s.d.n.config.Neo4jConfiguration - Initialising PersistenceExceptionTranslationPostProcessor
01:50:56.683 [localhost-startStop-1] INFO o.n.o.m.info.ClassFileProcessor - Starting Post-processing phase
01:50:56.684 [localhost-startStop-1] INFO o.n.o.m.info.ClassFileProcessor - Building annotation class map
01:50:56.684 [localhost-startStop-1] INFO o.n.o.m.info.ClassFileProcessor - Building interface class map for 6 classes
01:50:56.684 [localhost-startStop-1] INFO o.n.o.m.info.ClassFileProcessor - Registering default type converters...
01:50:56.692 [localhost-startStop-1] INFO o.n.o.m.info.ClassFileProcessor - Post-processing complete
01:50:56.692 [localhost-startStop-1] INFO o.n.o.m.info.ClassFileProcessor - 6 classes loaded in 22 milliseconds
01:50:56.974 [localhost-startStop-1] INFO o.s.d.n.mapping.Neo4jMappingContext - Neo4jMappingContext initialisation completed
01:50:57.088 [localhost-startStop-1] INFO o.s.d.n.config.Neo4jConfiguration - Initialising PersistenceExceptionTranslator
01:50:57.092 [localhost-startStop-1] INFO o.s.d.n.config.Neo4jConfiguration - Initialising PersistenceExceptionTranslationInterceptor
01:50:57.095 [localhost-startStop-1] INFO o.s.d.n.config.Neo4jConfiguration - Initialising Neo4jTransactionManager
01:50:57.130 [localhost-startStop-1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1424 ms
01:50:57.161 [localhost-startStop-1] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'MR.rest.api': initialization started
gru 16, 2015 1:50:57 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'MR.rest.api'
01:50:57.165 [localhost-startStop-1] INFO o.s.w.c.s.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'MR.rest.api-servlet': startup date [Wed Dec 16 01:50:57 CET 2015]; parent: Root WebApplicationContext
01:50:57.166 [localhost-startStop-1] INFO o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/SpringMVC/SpringMVC-RESTContext.xml]
01:50:57.399 [localhost-startStop-1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/list],methods=[GET],produces=[application/json]}" onto public java.util.List<server.infrastructure.persistence.neo4j.nodes.PersonNode> server.api.rest.controller.PersonController.getPersons()
01:50:57.626 [localhost-startStop-1] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for #ControllerAdvice: WebApplicationContext for namespace 'MR.rest.api-servlet': startup date [Wed Dec 16 01:50:57 CET 2015]; parent: Root WebApplicationContext
01:50:57.694 [localhost-startStop-1] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for #ControllerAdvice: WebApplicationContext for namespace 'MR.rest.api-servlet': startup date [Wed Dec 16 01:50:57 CET 2015]; parent: Root WebApplicationContext
01:50:57.758 [localhost-startStop-1] INFO o.s.w.s.h.BeanNameUrlHandlerMapping - Mapped URL path [/person] onto handler '/person'
01:50:57.826 [localhost-startStop-1] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'MR.rest.api': initialization completed in 665 ms
gru 16, 2015 1:50:57 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
However, when I refer to http://localhost:8080/rest/list I get the expected list of persons.
I want to refer to the http://localhost:8080/rest/person/list while using the #RestController for the person at class level and the `list' at the method level. How this can be done?
you should add #RequestMapping to your Controller Class
#RestController
#RequestMapping("/person")
public class PersonController {
#Autowired
PersonService personService;
#RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<PersonNode> getPersons(){
return personService.getList();
}
}

Spring Boot (ConfigServer) is restarting all the time

we have a very simple Spring Boot Service (#EnableConfigServer) running behind a nginx proxy.
The service basically works, but it is restarting all the time (Context is closed and started continuously).
See the log files here: http://pastebin.com/GErCF5x6
The setup is basically just one Java Class and the two configs (bootstrap.properties as well as application.properties).
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.annotation.Configuration;
/**
* Main Application, which starts the Spring Boot context
*/
#Configuration
#EnableAutoConfiguration
#EnableConfigServer
public class Application {
#SuppressWarnings("PMD.SignatureDeclareThrowsException")
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
bootstrap.properties
spring.application.name = configserver
spring.cloud.config.enabled = false
encrypt.failOnError= false
encrypt.key= secret
application.properties
# HTTP Configuration
server.port = 8888
# Management Configuration
management.context-path=/manage
# SSH Based Git-Repository
spring.cloud.config.server.git.uri=git#bitbucket.org:xyz.git
spring.cloud.config.server.git.basedir = cache/config
security.user.name=ads
security.user.password={cipher}secret2
security.basic.realm=Config Server
Log-File
11:13:47.105 [qtp1131266554-101] INFO o.s.boot.SpringApplication - Started application in 0.176 seconds (JVM running for 245.66)
11:13:47.105 [qtp1131266554-101] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#7709b120: startup date [Wed Apr 08 11:13:47 UTC 2015]; root of context hierarchy
11:13:47.690 [qtp1131266554-51] INFO o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Wed Apr 08 11:13:47 UTC 2015, principal=ads, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails#ffffe21a: RemoteIpAddress: 10.10.100.207; SessionId: null}]
11:13:48.324 [qtp1131266554-19] INFO o.s.boot.SpringApplication - Starting application on api01.prd.rbx.xxxx.com with PID 24204 (started by ads in /home/ads/config-server)
11:13:48.328 [qtp1131266554-19] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#473cffd3: startup date [Wed Apr 08 11:13:48 UTC 2015]; root of context hierarchy
11:13:48.332 [qtp1131266554-19] INFO o.s.boot.SpringApplication - Started application in 0.092 seconds (JVM running for 246.887)
11:13:48.332 [qtp1131266554-19] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#473cffd3: startup date [Wed Apr 08 11:13:48 UTC 2015]; root of context hierarchy
11:13:48.612 [qtp1131266554-55] INFO o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Wed Apr 08 11:13:48 UTC 2015, principal=ads, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails#ffffe21a: RemoteIpAddress: 10.10.100.207; SessionId: null}]
11:13:50.601 [qtp1131266554-77] INFO o.s.boot.SpringApplication - Starting application on api01.prd.rbx.xxxx.com with PID 24204 (started by ads in /home/ads/config-server)
11:13:50.604 [qtp1131266554-77] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#44330486: startup date [Wed Apr 08 11:13:50 UTC 2015]; root of context hierarchy
11:13:50.607 [qtp1131266554-77] INFO o.s.boot.SpringApplication - Started application in 0.088 seconds (JVM running for 249.162)
11:13:50.607 [qtp1131266554-77] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#44330486: startup date [Wed Apr 08 11:13:50 UTC 2015]; root of context hierarchy
11:13:51.831 [qtp1131266554-55] INFO o.s.boot.SpringApplication - Starting application on api01.prd.rbx.xxxx.com with PID 24204 (started by ads in /home/ads/config-server)
11:13:51.834 [qtp1131266554-55] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#1843040d: startup date [Wed Apr 08 11:13:51 UTC 2015]; root of context hierarchy
11:13:51.840 [qtp1131266554-55] INFO o.s.boot.SpringApplication - Started application in 0.094 seconds (JVM running for 250.395)
Any idea, how to solve the problem?
best,
fritz
That's normal. It's not the application that is starting and stopping, it's just the mini-contexts that are used to create the config resources for remote clients. Completely harmless.
I found out the problem which I am facing here. Basically we have two remote services running on AWS and a configured Load Balanacer, which continously checks the /health endpoint. By invoking this method, the ConfigServerClient always calls our ConfigServer.
I don't understand why there is a HealthIndicator for the ConfigServer, is there a way to disable this HealthIndicator, as every request to this endpoint will query our config server again and again. Another disadvantage is, that the /health request is not responding as fast as possible anymore, which leads to timeouts in the Load Balancer (default 2s).
So, config server isn't restarting. It uses a new Spring Application Context and loads the files it grabbed from git into a new context and the formats the values to send back to the client. Below are the logs from my config server for one client connection. The logs just looks confusing like it is restarting.
2015-04-08 12:22:52.206 INFO 85076 --- [nio-8888-exec-1] o.s.b.a.audit.listener.AuditListener : AuditEvent [timestamp=Wed Apr 08 12:22:52 EDT 2015, principal=user, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails#957e: RemoteIpAddress: 127.0.0.1; SessionId: null}]
2015-04-08 12:22:52.944 INFO 85076 --- [nio-8888-exec-2] o.s.b.a.audit.listener.AuditListener : AuditEvent [timestamp=Wed Apr 08 12:22:52 EDT 2015, principal=user, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails#957e: RemoteIpAddress: 127.0.0.1; SessionId: null}]
2015-04-08 12:22:53.490 INFO 85076 --- [nio-8888-exec-1] o.s.boot.SpringApplication : Starting application on sgibb-mbp.local with PID 85076 (started by sgibb in /Users/sgibb/workspace/spring/spring-cloud-samples/configserver)
2015-04-08 12:22:53.494 INFO 85076 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#571e4b84: startup date [Wed Apr 08 12:22:53 EDT 2015]; root of context hierarchy
2015-04-08 12:22:53.497 INFO 85076 --- [nio-8888-exec-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-04-08 12:22:53.498 INFO 85076 --- [nio-8888-exec-1] o.s.boot.SpringApplication : Started application in 0.151 seconds (JVM running for 23.747)
2015-04-08 12:22:53.499 INFO 85076 --- [nio-8888-exec-1] o.s.c.c.s.NativeEnvironmentRepository : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/foo.properties
2015-04-08 12:22:53.500 INFO 85076 --- [nio-8888-exec-1] o.s.c.c.s.NativeEnvironmentRepository : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/application.yml
2015-04-08 12:22:53.500 INFO 85076 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#571e4b84: startup date [Wed Apr 08 12:22:53 EDT 2015]; root of context hierarchy
2015-04-08 12:22:54.090 INFO 85076 --- [nio-8888-exec-2] o.s.boot.SpringApplication : Starting application on sgibb-mbp.local with PID 85076 (started by sgibb in /Users/sgibb/workspace/spring/spring-cloud-samples/configserver)
2015-04-08 12:22:54.096 INFO 85076 --- [nio-8888-exec-2] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#416d044c: startup date [Wed Apr 08 12:22:54 EDT 2015]; root of context hierarchy
2015-04-08 12:22:54.098 INFO 85076 --- [nio-8888-exec-2] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-04-08 12:22:54.099 INFO 85076 --- [nio-8888-exec-2] o.s.boot.SpringApplication : Started application in 0.433 seconds (JVM running for 24.348)
2015-04-08 12:22:54.099 INFO 85076 --- [nio-8888-exec-2] o.s.c.c.s.NativeEnvironmentRepository : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/foo.properties
2015-04-08 12:22:54.099 INFO 85076 --- [nio-8888-exec-2] o.s.c.c.s.NativeEnvironmentRepository : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/application.yml
2015-04-08 12:22:54.099 INFO 85076 --- [nio-8888-exec-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#416d044c: startup date [Wed Apr 08 12:22:54 EDT 2015]; root of context hierarchy

Spring3.0 Autowired null

I am doing with Spring #MVC3 and I've got a problem. Spring beans are created, but #Autowired doesn't work in a class. Here is my setting and source code:
xxx-servlet-.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.lodestone.ccah.controller"/>
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
</beans>
beans.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:website.properties" />
</bean>
<bean id="contextApplicationContextProvider" class="com.lodestone.ccah.util.ApplicationContextProvider"></bean>
<bean id="staticVars" class="com.lodestone.ccah.util.StaticVars">
<property name="awsServerIp" value="${website.AWSServerIP}" />
<property name="timeOutConnection" value="${website.timeOutConnection}" />
<property name="timeOutReceive" value="${website.timeOutReceive}" />
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="${db.url}?useJDBCCompliantTimezoneShift=true" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="maxIdle" value="10" />
<property name="maxActive" value="100" />
<property name="maxWait" value="10000" />
<property name="validationQuery" value="select 1" />
<property name="testOnBorrow" value="false" />
<property name="testWhileIdle" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="1200000" />
<property name="minEvictableIdleTimeMillis" value="1800000" />
<property name="numTestsPerEvictionRun" value="5" />
<property name="defaultAutoCommit" value="true" />
</bean>
<!-- DAO settings -->
<bean id="mediaDao" class="com.lodestone.ccah.dao.MediaDao">
<!--<property name="dataSource" ref="dataSource"></property>-->
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="mediaService" class="com.lodestone.ccah.service.MediaService"></bean>
</beans>
Tomcat Log:
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Thu Mar 08 13:21:49 EST 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [beans.xml]
DEBUG: org.springframework.beans.factory.xml.DefaultDocumentLoader - Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl]
DEBUG: org.springframework.beans.factory.xml.PluggableSchemaResolver - Loading schema mappings from [META-INF/spring.schemas]
DEBUG: org.springframework.beans.factory.xml.PluggableSchemaResolver - Loaded schema mappings: {http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/jms/spring-jms-2.5.xsd=org/springframework/jms/config/spring-jms-2.5.xsd, http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd, http://cxf.apache.org/schemas/configuration/http-conf.xsd=schemas/configuration/http-conf.xsd, http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd=schemas/xmldsig-core-schema.xsd, http://www.springframework.org/schema/security/spring-security-3.0.3.xsd=org/springframework/security/config/spring-security-3.0.3.xsd, http://www.springframework.org/schema/security/spring-security-2.0.1.xsd=org/springframework/security/config/spring-security-2.0.1.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd, http://www.w3.org/2006/07/ws-policy.xsd=schemas/ws-policy-200607.xsd, http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd=org/springframework/oxm/config/spring-oxm-3.0.xsd, http://cxf.apache.org/schemas/jaxrs.xsd=schemas/jaxrs.xsd, http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd=schemas/configuration/wsrm-manager.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://schemas.xmlsoap.org/ws/2004/08/addressing=schemas/wsdl/addressing.xsd, http://www.springframework.org/schema/security/spring-security-2.0.xsd=org/springframework/security/config/spring-security-2.0.xsd, http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd=schemas/oasis-200401-wss-wssecurity-secext-1.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://schemas.xmlsoap.org/wsdl/=schemas/wsdl/wsdl.xsd, http://cxf.apache.org/schemas/bindings/object.xsd=schemas/bindings/object.xsd, http://www.springframework.org/schema/mvc/spring-mvc.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd, http://www.springframework.org/schema/flex/spring-flex-1.0.xsd=org/springframework/flex/config/xml/spring-flex-1.0.xsd, http://cxf.apache.org/schemas/configuration/jms.xsd=schemas/configuration/jms.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd, http://cxf.apache.org/schemas/configuration/http-jetty.xsd=schemas/configuration/http-jetty.xsd, http://schemas.xmlsoap.org/wsdl/http/=schemas/wsdl/http.xsd, http://cxf.apache.org/schemas/wsdl/jms.xsd=schemas/wsdl/jms.xsd, http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd=schemas/oasis-200401-wss-wssecurity-utility-1.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd, http://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd, http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd=schemas/configuration/wsrm-policy.xsd, http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://www.springframework.org/schema/security/spring-security-2.0.4.xsd=org/springframework/security/config/spring-security-2.0.4.xsd, http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd=schemas/wsdl/wsdl.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://cxf.apache.org/schemas/ws/addressing.xsd=schemas/ws-addr-conf.xsd, http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://cxf.apache.org/schemas/wsdl/http-conf.xsd=schemas/wsdl/http-conf.xsd, http://www.w3.org/2001/xml.xsd=schemas/xml.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/jms/spring-jms.xsd=org/springframework/jms/config/spring-jms-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/oxm/spring-oxm.xsd=org/springframework/oxm/config/spring-oxm-3.0.xsd, http://www.w3.org/2007/02/ws-policy.xsd=schemas/ws-policy-200702.xsd, http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://cxf.apache.org/schemas/policy.xsd=schemas/policy.xsd, http://schemas.xmlsoap.org/ws/2004/09/policy/ws-policy.xsd=schemas/ws-policy-200409.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://cxf.apache.org/schemas/configuration/cxf-beans.xsd=schemas/configuration/cxf-beans.xsd, http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://cxf.apache.org/schemas/core.xsd=schemas/core.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://www.springframework.org/schema/jms/spring-jms-3.0.xsd=org/springframework/jms/config/spring-jms-3.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://cxf.apache.org/schemas/configuration/security.xsd=schemas/configuration/security.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/security/spring-security-3.0.4.xsd=org/springframework/security/config/spring-security-3.0.4.xsd, http://cxf.apache.org/schemas/configuration/soap.xsd=schemas/configuration/soap.xsd, http://www.springframework.org/schema/security/spring-security-2.0.2.xsd=org/springframework/security/config/spring-security-2.0.2.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://cxf.apache.org/schemas/jaxws.xsd=schemas/jaxws.xsd, http://cxf.apache.org/schemas/simple.xsd=schemas/simple.xsd, http://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.0.4.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/security/spring-security-3.0.xsd=org/springframework/security/config/spring-security-3.0.xsd, http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd=org/directwebremoting/spring/spring-dwr-2.0.xsd, http://cxf.apache.org/schemas/configuration/wsrm-manager-types.xsd=schemas/configuration/wsrm-manager-types.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd}
DEBUG: org.springframework.beans.factory.xml.PluggableSchemaResolver - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.0.xsd
DEBUG: org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader - Loading bean definitions
DEBUG: org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loaded 7 bean definitions from location pattern [classpath:beans.xml]
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Bean factory for Root WebApplicationContext: org.springframework.beans.factory.support.DefaultListableBeanFactory#70d9cc1a: defining beans [propertyConfigurer,contextApplicationContextProvider,staticVars,dataSource,mediaDao,jdbcTemplate,mediaService]; root of factory hierarchy
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'propertyConfigurer'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'propertyConfigurer'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'propertyConfigurer' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'propertyConfigurer'
INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [website.properties]
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource#b56efe]
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster#789e60f]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#70d9cc1a: defining beans [propertyConfigurer,contextApplicationContextProvider,staticVars,dataSource,mediaDao,jdbcTemplate,mediaService]; root of factory hierarchy
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'propertyConfigurer'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'contextApplicationContextProvider'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'contextApplicationContextProvider'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'contextApplicationContextProvider' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'contextApplicationContextProvider'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'staticVars'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'staticVars'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'staticVars' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'staticVars'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'dataSource'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'dataSource'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'dataSource' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'dataSource'
**DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'mediaDao'**
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'mediaDao'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'mediaDao' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'mediaDao'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'jdbcTemplate' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'dataSource'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'mediaService'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'mediaService'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'mediaService' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'mediaService'
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor#29d03e78]
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
DEBUG: org.springframework.web.context.ContextLoader - Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 393 ms
Mar 8, 2012 1:21:49 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 8, 2012 1:21:49 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 8, 2012 1:21:49 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
Mar 8, 2012 1:21:49 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3687 ms
The problem bean is mediaDao. But it is created in the Spring container. And here is the Java source the issue is happening.
NoteService.java:
public class MediaService {
#Autowired private MediaDao mediaDao;
private static final Logger logger = Logger.getLogger("NoteDao");
/**
* #param note
* #return
*/
public long addNote(Note note) {
logger.info(" MediaService.addNote starts");
long insertedId = -1;
try {
insertedId = mediaDao.add(note);
} catch (SQLException e) {
logger.error(e);
}
logger.info(" MediaService.addNote ends");
return insertedId;
}
}
The mediaDao is null but other Java sources with #Autowired are OK. I don't know what is missing?
My thought is, have you annotated the service with #Service annotation, if not then spring does not recognize that as spring managed class and it may not inject the DAO for you. Either it should Service or Component annotated. Also as told by Dave check the package whether the package is scanned by spring context or not. You have given the component scan for controller package. I am not sure whether the MediaService is also placed in the same package. Just check all these factors.
You're not scanning the package of the class, so the annotation will be ignored. Add its package to a component scan element as you're already doing for the controller package.
The following is the correct form.
#Autowired private MediaDaoInterface mediaDaoInt;

dpHibernate: serializerFactory not initialized by Spring -> NullPointerException on service access

I am trying to get dpHibernate 2.0 RC6 running on an Apache Tomcat 7.0.12 with BlazeDS 4.0.0.14931, Spring 3.0.5 and Spring-BlazeDS-Integration 1.5.0.M2
With the following configuration the server starts fine, but as soon as I want to access a service or the RDSDispatchServlet via FlashBuilder4 DCD I am getting a NullPointerException. It seems the serializerFactory is not correctly injected into the dpHibernate HibernateUtil. Did I miss something in the configuration in remoting-config.xml?
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Server</display-name>
<description>Server Side based on BlazeDS, Spring and Hibernate</description>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<!-- begin SPRING INTEGRATION -->
<servlet>
<servlet-name>springMessageBroker</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<!-- <init-param> -->
<!-- <param-name>contextConfigLocation</param-name> -->
<!-- <param-value></param-value> Do not use if using ContextLoaderListener (would load app context twice -> Error) -->
<!-- </init-param> -->
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMessageBroker</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<!-- end SPRING INTEGRATION -->
<!-- begin rds -->
<servlet>
<servlet-name>RDSDispatchServlet</servlet-name>
<servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>
<init-param>
<param-name>useAppserverSecurity</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>messageBrokerId</param-name>
<param-value>_messageBroker</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RDSDispatchServlet</servlet-name>
<url-pattern>/CFIDE/main/ide.cfm</url-pattern>
</servlet-mapping>
<!-- end rds -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
<filter>
<filter-name>dpHibernateSessionFilter</filter-name>
<filter-class>org.dphibernate.filters.HibernateSessionServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>dpHibernateSessionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
applicationContext.xml (Spring Servlet default configuration file)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<import resource="flexContext.xml" />
<import resource="dataAccessContext.xml" />
<import resource="dpHibernateContext.xml"/>
<!-- Enable Spring Transaction Manager with Annotations -->
<tx:annotation-driven />
<context:annotation-config />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="/WEB-INF/server.properties" /></bean>
<context:component-scan base-package="com.mycompany.myproject.*" />
</beans>
flexContext.xml (definitions of services available for flex)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flex="http://www.springframework.org/schema/flex"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<flex:message-destination id="chat"/>
<flex:message-broker services-config-path="/WEB-INF/flex/services-config.xml">
<flex:remoting-service default-adapter-id="dpHibernateRemotingAdapter" default-channels="my-amf,my-secure-amf" />
<flex:message-service default-channels="my-streaming-amf,my-polling-amf"/>
</flex:message-broker>
</beans>
fpHibernateContext.xml (configuration of dpHibernate)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<!-- Defines the remoting adapter, which intercepts inbound & outbound messages, and routes them thruogh dpHibernate -->
<bean id="dpHibernateRemotingAdapter"
class="org.springframework.flex.core.ManageableComponentFactoryBean">
<constructor-arg value="org.dphibernate.adapters.RemotingAdapter" />
<property name="properties">
<value>
{"dpHibernate" :
{
"serializerFactory" : "org.dphibernate.serialization.SpringContextSerializerFactory"
}
}
</value>
</property>
</bean>
<bean id="dpHibernateMessagingAdapter"
class="org.springframework.flex.core.ManageableComponentFactoryBean">
<constructor-arg value="org.dphibernate.adapters.MessagingAdapter" />
</bean>
<bean id="dataAccessService" class="org.dphibernate.services.SpringLazyLoadService" autowire="constructor">
<flex:remoting-destination />
</bean>
<!-- Required -->
<bean id="hibernateSessionFilter" class="org.dphibernate.filters.SpringHibernateSessionServletFilter" />
<!-- The cache is used to prevent serializing the same object many times during serialization. Required -->
<bean id="dpHibernateCache"
class="org.dphibernate.serialization.DPHibernateCache" scope="prototype" />
<!-- The main serializer. Converts outbound POJO's to ASObjects with dpHibernate proxies for lazy loading. Required -->
<bean id="dpHibernateSerializer"
class="org.dphibernate.serialization.HibernateSerializer" scope="prototype">
<property name="pageSize" value="10"/>
</bean>
<bean id="dpHibernateDeserializer" class="org.dphibernate.serialization.HibernateDeserializer" scope="prototype" />
<!-- Handles entity updates (CRUD). Required if using entity persistence. -->
<bean id="objectChangeUpdater"
class="org.dphibernate.persistence.state.AuthenticatedObjectChangeUpdater"
scope="prototype">
<property name="preProcessors" ref="dpHibernatePreProcessors" />
<property name="postProcessors" ref="dpHibernatePostProcessors" />
</bean>
</beans>
remoting-config.xml (imported in services-config.xml)
<service id="remoting-service"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<adapters>
<adapter-definition id="hibernate-object" class="org.dphibernate.adapters.RemotingAdapter" default="true">
<properties>
<hibernate>
<sessionFactory>
<class>org.dphibernate.utils.HibernateUtil</class>
<getCurrentSessionMethod>getCurrentSession</getCurrentSessionMethod>
</sessionFactory>
</hibernate>
</properties>
</adapter-definition>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
</service>
NullPointerException (on service access or rds access via FB4 DCD)
startInternal INFO: Starting Servlet
Engine: Apache Tomcat/7.0.12
11.04.2011 18:34:19 org.apache.catalina.core.ApplicationContext
log INFO: Initializing Spring root
WebApplicationContext 1027 [Thread-2]
INFO
org.hibernate.annotations.common.Version
- Hibernate Commons Annotations 3.2.0.Final 1066 [Thread-2] INFO org.hibernate.cfg.Environment -
Hibernate 3.6.2.Final 1074 [Thread-2]
INFO org.hibernate.cfg.Environment -
hibernate.properties not found 1085
[Thread-2] INFO
org.hibernate.cfg.Environment -
Bytecode provider name : javassist
1116 [Thread-2] INFO
org.hibernate.cfg.Environment - using
JDK 1.4 java.sql.Timestamp handling
2146 [Thread-2] INFO
org.hibernate.cfg.Configuration -
Hibernate Validator not found:
ignoring 2182 [Thread-2] INFO
org.hibernate.cfg.search.HibernateSearchEventListenerRegister
- Unable to find org.hibernate.search.event.FullTextIndexEventListener
on the classpath. Hibernate Search is
not enabled. 2194 [Thread-2] INFO
org.hibernate.connection.ConnectionProviderFactory
- Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
2658 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Database ->
name : MySQL
version : 5.0.51a-24+lenny5-log
major : 5
minor : 0 2658 [Thread-2] INFO org.hibernate.cfg.SettingsFactory -
Driver ->
name : MySQL-AB JDBC Driver
version : mysql-connector-java-5.1.15 (
Revision: ${bzr.revision-id} )
major : 5
minor : 1 2861 [Thread-2] INFO org.hibernate.dialect.Dialect - Using
dialect:
org.hibernate.dialect.MySQLInnoDBDialect
2981 [Thread-2] INFO
org.hibernate.transaction.TransactionFactoryFactory
- Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
2991 [Thread-2] INFO
org.hibernate.transaction.TransactionManagerLookupFactory
- No TransactionManagerLookup configured (in JTA environment, use of
read-write or transactional
second-level cache is not recommended)
2991 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Automatic flush during
beforeCompletion(): disabled 2991
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Automatic session close at end of
transaction: disabled 2991 [Thread-2]
INFO org.hibernate.cfg.SettingsFactory
- JDBC batch size: 20 2991 [Thread-2] INFO org.hibernate.cfg.SettingsFactory
- JDBC batch updates for versioned data: disabled 2998 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Scrollable result sets: enabled 2998
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
JDBC3 getGeneratedKeys(): enabled 2998
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Connection release mode: auto 3003
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Maximum outer join fetch depth: 2 3003
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Default batch fetch size: 1 3003
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Generate SQL with comments: disabled
3003 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Order SQL updates by primary key:
disabled 3003 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Order SQL inserts for batching:
disabled 3003 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Query translator:
org.hibernate.hql.ast.ASTQueryTranslatorFactory
3023 [Thread-2] INFO
org.hibernate.hql.ast.ASTQueryTranslatorFactory
- Using ASTQueryTranslatorFactory 3023 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Query language substitutions: {} 3023
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
JPA-QL strict compliance: disabled
3023 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Second-level cache: enabled 3023
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Query cache: disabled 3029 [Thread-2]
INFO org.hibernate.cfg.SettingsFactory
- Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
3074 [Thread-2] INFO
org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
- Cache provider: org.hibernate.cache.HashtableCacheProvider
3084 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Optimize cache for minimal puts:
disabled 3084 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Structured second-level cache entries:
disabled 3131 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Echoing all SQL to stdout 3138
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Statistics: disabled 3138 [Thread-2]
INFO org.hibernate.cfg.SettingsFactory
- Deleted entity synthetic identifier rollback: disabled 3138 [Thread-2]
INFO org.hibernate.cfg.SettingsFactory
- Default entity-mode: pojo 3138 [Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Named query checking : enabled 3138
[Thread-2] INFO
org.hibernate.cfg.SettingsFactory -
Check Nullability in Core (should be
disabled when Bean Validation is on):
enabled 3239 [Thread-2] INFO
org.hibernate.impl.SessionFactoryImpl
- building session factory 3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [blob] overrides
previous :
org.hibernate.type.BlobType#17f7be7b
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [java.sql.Blob]
overrides previous :
org.hibernate.type.BlobType#17f7be7b
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [materialized_clob]
overrides previous :
org.hibernate.type.MaterializedClobType#9fa8988
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration
[wrapper_materialized_blob] overrides
previous :
org.hibernate.type.WrappedMaterializedBlobType#1f5b44d6
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [clob] overrides
previous :
org.hibernate.type.ClobType#21044daf
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [java.sql.Clob]
overrides previous :
org.hibernate.type.ClobType#21044daf
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [characters_clob]
overrides previous :
org.hibernate.type.PrimitiveCharacterArrayClobType#21882d18
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration
[wrapper_characters_clob] overrides
previous :
org.hibernate.type.CharacterArrayClobType#734893da
3282 [Thread-2] INFO
org.hibernate.type.BasicTypeRegistry -
Type registration [materialized_blob]
overrides previous :
org.hibernate.type.MaterializedBlobType#21e30857
3379 [Thread-2] INFO
org.hibernate.impl.SessionFactoryObjectFactory
- Not binding factory to JNDI, no JNDI name configured
11.04.2011 18:34:36 org.apache.catalina.core.ApplicationContext
log INFO: Initializing Spring
FrameworkServlet 'springMessageBroker'
11.04.2011 18:34:36 org.apache.coyote.AbstractProtocolHandler
start INFO: Starting ProtocolHandler
["http-bio-8080"]
11.04.2011 18:34:36 org.apache.coyote.AbstractProtocolHandler
start INFO: Starting ProtocolHandler
["ajp-bio-8009"]
11.04.2011 18:34:36 org.apache.catalina.startup.Catalina
start INFO: Server startup in 21332 ms
11.04.2011 18:49:02 org.apache.catalina.core.StandardWrapperValve
invoke SCHWERWIEGEND:
Servlet.service() for servlet
[RDSDispatchServlet] in context with
path [/myJavaServer] threw
exception
java.lang.NullPointerException at
org.dphibernate.utils.HibernateUtil.getSessionFactory(Unknown
Source) at
org.dphibernate.filters.HibernateSessionServletFilter.getSessionFactory(Unknown
Source) at
org.dphibernate.filters.AbstractHibernateSessionServletFilter.doFilter(Unknown
Source) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at
java.lang.Thread.run(Thread.java:662)
org.dphibernate.utils.HibernateUtil (snippet)
private static ISerializerFactory serializerFactory; // should be injected by Spring
public static SessionFactory getSessionFactory() throws HibernateException
{
return serializerFactory.getSessionFactory(); // but is null on this call?
}
The remotingConfig.xml isn't needed, and appears to be what's causing your problems.
Typically, in a Spring configuration, the HibernateUtil class you've shown there isn't used (the SpringContextSerializerFactory returns the SessionFactory to ensure you're getting the correct one from your Spring session)
However, it looks like your remotingConfig.xml file is overwriting the default settings, forcing it to use the old HibernateUtil approach, which is throwing your NPE.

Resources