Complete Web Application: Angular Twitter Bootstrap Spring MVC, Data and Security

Hello, how are you?

Today we will see how to create a complete Java web application using Spring, Angular, JQuery, Twitter Bootstrap, Tiles, Maven, Tomcat, JPA/Hibernate.

The project that will be done here in this post will be used in another post that I will write, because of this future post, in this post will be described a detailed environment configuration. I will be using linux as my operational system (OS), but almost nothing will change if you use Windows or other OS.

I received a lot of emails asking for a post using Spring in a full web application, all the applications already posted here were using JEE technology (JSF, EJB, JPA). In this post we will see a project using Spring framework with the following modules: Spring MVC, SpringData e Spring Security. We will see how to do internationalization (i18n) with SpringMVC and templates with Tiles framework.

Postgre will be the database used here, but if you want use it with MySQL just add the MySQL jar to the project and change some configuration. In this post will be displayed both Postgre and MySQL configurations.

It is possible to find the source code of this project in the last page of this post, and to make everybody happy, 3 downloading ways will be available in the end of the post. In this post we will focus in the Spring/JPA code and some of the JPS code highlighting the Angular and Bootstrap libraries, all the JSP code, classes and configurations can be downloaded in the last page.

What we will see in here:

Page 02: Environment Setup
Page 03: Creating the project
Page 04: Understanding the “pom.xml”, “log4j.xml” and the “context.xml” files
Page 05: Creating the Spring and the project XMLs
Page 06: Tiles – Page templates
Page 07: Project Model Classes
Page 08: Using SpringData as Repository (DAO); creating User Service
Page 09: Using SpringData as Repository (DAO); creating Contact Service
Page 10: Creating the Controllers
Page 11: Using Restful approach with SpringMVC
Page 12: Understanding the Login, SpringMVC Interceptor and the Security Rules
Page 13: First Contact with Angular.js and the SpringMVC
Page 14: Using Angular.js bind in a HTML table
Page 15: Internationalization (i18n) with Spring
Page 16: Understanding the Twitter Bootstrap role
Page 17: Running the project

Let us get started!

149 thoughts on “Complete Web Application: Angular Twitter Bootstrap Spring MVC, Data and Security

  1. Excellent post! Learned a few new things in the first couple of pages

    Off topic but I must know how you got Eclipse running with that dark theme? I have tried a few approaches on my Ubuntu box but have never got it to look that good. Can you point me somewhere to set it up like that?

  2. Hello Uaihebert.,

    Mind blowing tutorial. I loved it. Thank you so much for you complete effort of 18+ Parts and also your Design Patterns is lovely.

    Can i ask you a question ?

    Is it possible to have a Vaadin and GWT as a FrontEnd and Spring as Backend ?

    • Hello LevelFive,

      I do not see a problem using Vaadin or GWT with Spring, I just do not have any tutorial do give to you.

      Thanks for passing by and for the feedback.

  3. hello,

    I installed your application, but when i run it i have this :
    java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    … 15 more

    nov. 10, 2013 11:48:19 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    nov. 10, 2013 11:48:19 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Erreur de démarrage du contexte [/uaiContacts] suite aux erreurs précédentes
    nov. 10, 2013 11:48:19 AM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    nov. 10, 2013 11:48:19 AM org.apache.catalina.core.StandardContext listenerStop
    SEVERE: Exception lors de l’envoi de l’évènement contexte détruit (context destroyed) à l’instance de classe d’écoute org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.springframework.web.context.ContextCleanupListener.(ContextCleanupListener.java:43)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

    what’s the problem?
    i work with eclipse juno, java7 and tomcat7 in Linux mint
    best regards

    • Hello tisfa,

      If you will use a tomcat that is not the maven tomcat you will need to add manually a few dependencies.

      Take a look at the pom in the tomcat7 plugin, there you will find the tomcat needed dependencies.

      Thanks for passing by.

  4. Thanks a lot for this cool tutorial project!

    What I would like to see additionally in it is sequence of steps to build it! Now it looks more like just the description of the ready application rather than tutorial.

    Anyway you did a great job! Thanks a lot!

    • Woworks, good afternoon.

      Only the creation file that were not displayed here, or the post would be longer.

      Someone that has a basic knowledge in Java already nows how to create a class in a package.

      It was not detailed the JSPs because it is a lot html code that is not the focus of this project. [=

      Thanks for passing by.

  5. I am facing bellow error, please guide me to resolve this issue…

    …]
    INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] [] localhost-startStop-1 HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] [] localhost-startStop-1 Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@13ed0e: defining beans [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,contactService,userService,contactsController,homeController,indexController,loginController,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.DefaultServletHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.handler.MappedInterceptor#1,org.springframework.web.servlet.handler.MappedInterceptor#2,tilesConfigurer,messageSource,localeResolver,org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,myContactDataSource,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,entityManagerFactory,contactRepository,userRepository,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor#0,org.springframework.security.methodSecurityMetadataSourceAdvisor,org.springframework.security.filterChains,org.springframework.security.filterChainProxy,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.PortResolverImpl#0,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler#0,org.springframework.security.access.vote.AffirmativeBased#1,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.userDetailsServiceFactory,org.springframework.security.web.DefaultSecurityFilterChain#0,org.springframework.security.provisioning.JdbcUserDetailsManager#0,org.springframework.security.authentication.dao.DaoAuthenticationProvider#0,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
    ERROR [org.springframework.web.context.ContextLoader] [] localhost-startStop-1 Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    … 20 more
    Caused by: org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:139)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
    at com.sun.proxy.$Proxy18.getConnection(Unknown Source)
    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
    at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:96)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    … 35 more
    Caused by: javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:132)
    … 53 more
    Dec 4, 2013 2:18:38 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    … 20 more

    • Hello Ajay,

      The exception says that: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].

      Take a look if the configurations inside the context.xml file if the data are correct.

      Thanks for passing buy.

      • Hi,
        my previous issue is fixed but currently I am facing another issue please check this error.

        ERROR [org.springframework.web.context.ContextLoader] [] localhost-startStop-1 Context initialization failed
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: uaiContactsPU] Unable to build EntityManagerFactory
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: uaiContactsPU] Unable to build EntityManagerFactory
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
        at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:79)
        at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70)
        at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        … 20 more
        Caused by: javax.persistence.PersistenceException: [PersistenceUnit: uaiContactsPU] Unable to build EntityManagerFactory
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
        … 35 more
        Caused by: org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect. MySQL5InnoDBDialect
        at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:76)
        at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146)
        at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
        at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
        at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:96)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
        … 41 more
        Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect. MySQL5InnoDBDialect ]
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:149)
        at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
        … 50 more
        Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect. MySQL5InnoDBDialect
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:296)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:249)
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:146)
        … 51 more
        Dec 4, 2013 10:46:18 PM org.apache.catalina.core.StandardContext listenerStart
        SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: uaiContactsPU] Unable to build EntityManagerFactory
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: uaiContactsPU] Unable to build EntityManagerFactory
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
        at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:79)
        at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70)
        at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        … 20 more
        Caused by: javax.persistence.PersistenceException: [PersistenceUnit: uaiContactsPU] Unable to build EntityManagerFactory
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
        … 35 more
        Caused by: org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect. MySQL5InnoDBDialect
        at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:76)
        at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146)
        at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
        at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
        at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:96)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
        … 41 more
        Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect. MySQL5InnoDBDialect ]
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:149)
        at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
        … 50 more
        Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect. MySQL5InnoDBDialect
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:296)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:249)
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:146)
        … 51 more
        Dec 4, 2013 10:46:18 PM org.apache.catalina.core.StandardContext startInternal
        SEVERE: Error listenerStart
        Dec 4, 2013 10:46:18 PM org.apache.catalina.core.StandardContext startInternal
        SEVERE: Context [/uaiContacts] startup failed due to previous errors
        Dec 4, 2013 10:46:18 PM org.apache.catalina.core.ApplicationContext log
        INFO: Closing Spring root WebApplicationContext
        Dec 4, 2013 10:46:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
        SEVERE: The web application [/uaiContacts] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
        Dec 4, 2013 10:46:18 PM org.apache.coyote.AbstractProtocol start
        INFO: Starting ProtocolHandler [“http-bio-8080″]

        • Hello Ajay,

          The error message says that: Dialect class not found: org.hibernate.dialect. MySQL5InnoDBDialect

          If you are running the project in a standalone tomcat you must add the needed dependencies.

          You will find the required tomcat dependencies in the pom file, in the tomcat7 plugin section.

          Regards

        • Hi Ajay, how did you solve the problem “Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].”?
          I am getting the same issue..could you please tell me what did you change to solve this?

          • Hello Dharmik,

            this kind of error happens because the datasource were not created in the context.xml file.

            Thanks for passing by. [=

  6. Hello, nice tutorial thank you.

    do you mind helping me with a problem i got.
    when i run it i get
    Dec 05, 2013 1:39:21 AM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

    and more…

    in the end

    Dec 05, 2013 1:39:21 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Dec 05, 2013 1:39:21 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/uaiContacts] startup failed due to previous errors
    Dec 05, 2013 1:39:21 AM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Dec 05, 2013 1:39:21 AM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“http-bio-8989″]

    thank you in advance

    ————————————————————————————————————–

    I also want to ask if i must create the schema in the mysql db or is going to be created automatically.

    Thank you again

    ————————————————————————————————————–

    ok i found the error. It was that i named “contex.xml” instead of “context.xml”. i copied “contex.xml” string from the title in page 4 of your tutorial. So if you want change it.

    Thank you again for your tutorial..

    p.s. Do you mind showing us how to put spring social in this?
    ————————————————————————————————————–
    [For others] The database is generated automatically.

  7. Hi, Great tutorial. When i run the application its starts tomcat.

    below is the output

    Jan 7, 2014 6:21:23 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler [“http-bio-8082″]
    Jan 7, 2014 6:21:23 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Tomcat
    Jan 7, 2014 6:21:23 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.37
    Jan 7, 2014 6:21:26 PM org.apache.catalina.core.ApplicationContext log
    INFO: No Spring WebApplicationInitializer types detected on classpath
    Jan 7, 2014 6:21:26 PM org.apache.coyote.AbstractProtocol start

    When i run the url in the browser it says Http-404 resource is not available.

    Can you please suggest what i might be doing wrong?

    • Hello Ranjan,

      If you follow the post steps you will be able to run it without a problem.

      If you are running in a stand alone tomcat, it looks like the war is not in the webapps folder.

      Thanks for passing by.

  8. Great Post !
    It worked perfect in my enviroment (SpringSource 3.4.0).
    What really surprised me was the use of the Tomcat plugin, it really can make easier to configure development enviroment.
    I have a question for you. What if I want to deploy project like this to production, in a Tomcat Server or another, what changes are necessary (additional xml files, etc.) and how I can make the deployment ? I just generate the WAR ?
    The Tomcat plugin won´t cause any problems ?

    Thanks in advance.

    Regards, Javier.

    • Javier, thanks for the feedback.

      If you want to run it in a Tomcat you will need to add all jars described in tomcat plugin of the pom.xml; just the jars of the tomcat7 plugin is needed.

      You will need to copy the configurations of the files found in the tomcat folder.

      Just generate the war file (mvn clean install) and copy the file to the webapps folder.

      Tomcat plugin is just activated by maven. [=

      Thanks for passing by! o_

  9. Dear Ajay,

    first how are you?

    I dewnload your application and when i start it by tomcat7 i have this problem:
    janv. 27, 2014 9:06:29 AM org.apache.catalina.core.AprLifecycleListener init
    Infos: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386:/usr/lib/jvm/java-7-openjdk-i386/jre/../lib/i386:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/client:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386::/usr/java/packages/lib/i386:/usr/lib/i386-linux-gnu/jni:/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/jni:/lib:/usr/lib
    janv. 27, 2014 9:06:29 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
    Avertissement: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:uaiContacts’ did not find a matching property.
    janv. 27, 2014 9:06:29 AM org.apache.coyote.AbstractProtocol init
    Infos: Initializing ProtocolHandler [“http-bio-8080″]
    janv. 27, 2014 9:06:29 AM org.apache.coyote.AbstractProtocol init
    Infos: Initializing ProtocolHandler [“http-bio-8443″]
    janv. 27, 2014 9:06:29 AM org.apache.coyote.AbstractProtocol init
    Infos: Initializing ProtocolHandler [“ajp-bio-8009″]
    janv. 27, 2014 9:06:29 AM org.apache.catalina.startup.Catalina load
    Infos: Initialization processed in 450 ms
    janv. 27, 2014 9:06:29 AM org.apache.catalina.core.StandardService startInternal
    Infos: Démarrage du service Catalina
    janv. 27, 2014 9:06:29 AM org.apache.catalina.core.StandardEngine startInternal
    Infos: Starting Servlet Engine: Apache Tomcat/7.0.47
    janv. 27, 2014 9:06:30 AM org.apache.catalina.core.ApplicationContext log
    Infos: No Spring WebApplicationInitializer types detected on classpath
    janv. 27, 2014 9:06:30 AM org.apache.catalina.core.StandardContext listenerStart
    Grave: Exception lors de l’envoi de l’évènement contexte initialisé (context initialized) à l’instance de classe d’écoute (listener) org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:270)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    … 14 more

    janv. 27, 2014 9:06:30 AM org.apache.catalina.core.StandardContext startInternal
    Grave: Error listenerStart
    janv. 27, 2014 9:06:30 AM org.apache.catalina.core.StandardContext startInternal
    Grave: Erreur de démarrage du contexte [/uaiContacts] suite aux erreurs précédentes
    janv. 27, 2014 9:06:30 AM org.apache.catalina.core.ApplicationContext log
    Infos: Closing Spring root WebApplicationContext
    janv. 27, 2014 9:06:30 AM org.apache.catalina.core.StandardContext listenerStop
    Grave: Exception lors de l’envoi de l’évènement contexte détruit (context destroyed) à l’instance de classe d’écoute org.springframework.web.context.ContextLoaderListener
    java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.springframework.web.context.ContextCleanupListener.(ContextCleanupListener.java:43)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:144)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

    janv. 27, 2014 9:06:30 AM org.apache.coyote.AbstractProtocol start
    Infos: Starting ProtocolHandler [“http-bio-8080″]
    janv. 27, 2014 9:06:30 AM org.apache.coyote.AbstractProtocol start
    Infos: Starting ProtocolHandler [“http-bio-8443″]
    janv. 27, 2014 9:06:30 AM org.apache.coyote.AbstractProtocol start
    Infos: Starting ProtocolHandler [“ajp-bio-8009″]
    janv. 27, 2014 9:06:30 AM org.apache.catalina.startup.Catalina start
    Infos: Server startup in 1472 ms

    • Hello nkine,

      To run this project in a Tomcat, without the maven plugin, you should use add the libraries described in the pom.xml. You will find the needed dependencies described at the tomcat7 plugin.

      Thanks for passing by.

        • Hello Nkine,

          If you follow all the steps of the post you will have no problem.

          If the dependency still missing check if the problem is not a corrupted file in your local maven repository.

          Thanks for passing by.

          • I have same probleme

            i changed my pom.xml into

            4.0.0

            uaiHebert
            uaiContacts
            1.0-SNAPSHOT
            war

            java.net.m2
            java.net m2 repo
            http://download.java.net/maven/2

            uaiContacts

            org.apache.maven.plugins
            maven-compiler-plugin
            3.1

            1.6
            1.6

            log4j
            log4j
            1.2.16

            org.slf4j
            slf4j-api
            1.7.1

            org.slf4j
            slf4j-log4j12
            1.7.1

            mysql
            mysql-connector-java
            5.1.14

            org.hibernate.javax.persistence
            hibernate-jpa-2.0-api
            1.0.1.Final

            org.hibernate
            hibernate-entitymanager
            4.2.4.Final

            org.slf4j
            slf4j-api

            org.springframework
            spring-orm
            3.1.1.RELEASE

            org.springframework
            spring-webmvc
            3.1.1.RELEASE

            org.springframework
            spring-context
            3.1.1.RELEASE

            org.springframework.security
            spring-security-core
            3.1.1.RELEASE

            org.springframework.security
            spring-security-config
            3.1.1.RELEASE

            org.springframework.security
            spring-security-taglibs
            3.1.1.RELEASE

            org.springframework.security
            spring-security-web
            3.1.1.RELEASE

            org.springframework
            spring-tx
            3.1.1.RELEASE

            org.springframework
            spring-jdbc
            3.2.3.RELEASE

            org.springframework
            spring-oxm
            3.1.1.RELEASE

            org.springframework.data
            spring-data-jpa
            1.2.0.RELEASE

            cglib
            cglib
            2.2

            org.aspectj
            aspectjrt
            1.7.0

            org.codehaus.jackson
            jackson-jaxrs
            1.8.2

            org.apache.tiles
            tiles-api
            2.2.2

            org.apache.tiles
            tiles-core
            2.2.2

            org.slf4j
            jcl-over-slf4j

            org.apache.tiles
            tiles-jsp
            2.2.2

            org.apache.tiles
            tiles-servlet
            2.2.2

            org.apache.tiles
            tiles-template
            2.2.2

            javax.servlet
            javax.servlet-api
            3.0.1
            provided
            true

            javax.servlet.jsp
            jsp-api
            2.2
            provided
            true

            javax.servlet
            jstl
            1.2

            commons-lang
            commons-lang
            2.4

            com.google.guava
            guava
            10.0.1

            org.slf4j
            slf4j-api
            1.7.1
            provided

            log4j
            log4j
            1.2.16
            provided

            commons-logging
            commons-logging
            1.1.1

            an i have same Error i dont understand why !!
            Please helpe me!

  10. hello,
    thank you very much for this Rich Example, i found a lot for what i was looking for, i can run you project on Postgres but not with MySql and i did all the required modification, the problem is With MySQL5InnoDBDialect.

    i would like to know how to create a form:select (comboBox) in your Dialogs, i worked with this example in my ex project:

    ROLE_ADMIN
    ROLE_USER

    But i can’t do it in your project, i think because you used the Java Script to communicate between you Controller and Jsp Pages, ?

    • Hello, marouen

      You can search in the web for angular select that you will find samples to do it.

      Thanks for passing by. I am sorry for the late response, I was very busy this last month.

  11. Hi,
    Thanks for the great post.
    I receive the following error in the web browser when trying to start the application:

    HTTP Status 404 – /uaiContacts/public/template/master.jsp
    type Status report
    message /uaiContacts/public/template/master.jsp
    description The requested resource is not available.

    Can you please tell me what could be wrong ?
    All the jsp are in the places like tutorial says, and the tiles.xml is copied from you source code.
    What am I doing wrong ?

    Thanks

    • Goran, good night.

      It looks like you service did not start. Take a look at the log to see if it has any error when it starts.

      Thanks for passing by.

      • Hi,

        I finally resolved the problem.
        The problem was in tiles.xml file where the configuration path to *.jsp files cause the problem (on my machine).
        In the example, the path to the *.jsp files is “/public/template/master.jsp” but after I changed to “/WEB-INF/public/template/master.jsp” everything is working fine. How in your example this works without “WEB-INF” ?

        Thanks for the replay,
        Goran

  12. The first one it’s a complete great example, but I have a problem.

    I used mysql database to test your web app and configure de tomcat context to use mysql. EveryThing looks ok initially. I configure some users on system-user table to logon in the system and create some contacts.

    But when I logon and I go to the contacts option menu option and create a new contact, the system don’t show any error, but the contact is not created in the table. Also if I insert from mysql tables a new contact and refresh the web app, also any contact is showed in the web. The web app don’t do any CRUD on the table Contact. What is the problem??

    best regards

    • Hello Miguel,

      One thing that you could do is to change de LOG level from “INFO” to “DEBUG” in the log4j.xml to see if any error pops up.

      I can not tell you what error is without an error message.

      Thanks for passing by.

    • hello,

      can you please send me your example how you Run it with mysql ?
      i like to do it with MySql but till now, using Postgres that i think is less useful than MySql…
      =
      Thanks

      • Marouen, good afternoon.

        I do not have a MySQL sample. In the post it is detailed all the codes that you should change to use MySQL.

        Thanks for passing by.

    • Hello John.

      If you take a look into the persistence.xml file you will see a configuration with the value update.

      All you need is to create the database and run the project.

      If you want to run it with MySQL you should update the database related code, just as the post says.

      Thanks for passing by.

    • João, good morning.

      Do you have your Maven correctly working?

      Is your Maven able to download new dependencies?

      Is the door 8080 allowed to run in your local firewall?

      Is there any error message?

      Thanks for passing by

  13. hello
    ı can try to angularJS alone js and html then write simple controller.js file call method in this file for example $scope.getConttactList(); but if ı call this method not working angularJS controller but delete this $scope.getConttactList(); my controller running. ı can’t understand that.

  14. Thanks for a great post. I was looking for this combinations of technologies for a new project.
    The projects runs and displays the login page but I cannot log even though I have created two users in the database.
    Can you kindly send the exact values for these two rows for enabled, role, email , password?
    it refuses to log-in.
    Also, in your mind, what is the best way to intercept Spring security and see if it has any exceptions etc. while accessing the database?
    (tables where created ok in the DB)

    • Hello Avishay,

      I do not have a insert example, sorry.

      I followed the same steps of the post and it worked.

      Check the generated LOG or change its level to DEBUG, it may display what is wrong.

      Thanks for passing by.

  15. Good day, and great tutorial
    By any chance, do you know how or which would be the best way to implement junit’s test cases? (For trying queries or methods)

    • Ricardo, good night.

      I would use the Spring Test module.

      You can find several query results in the google searching for: “springmvc test”

      Thanks for passing by

  16. Hi, can I reuse pieces of these codes in a project that I’ll release as MIT license? There are any problems using CSS files, JS files, etc?
    THanks.

  17. hello brother,

    your project is working very well in mysql using the Tomcat plugin like you described above, but i would like to add SPRING-TEST using @RunWith(SpringJUnit4ClassRunner.class)
    and
    @ContextConfiguration
    i created a new folder “usr/test/java”
    but, in the ContextConfigurator annotation, i didn’t know wich file i should put, when i tried “/context.xml” it doesn’t work for me, even when i copy all the xml files in “src/test/resources”.

    please, i need help to add TESTS module

    • Hello marouen,

      I am sorry but I do not have a sample here. I do know that you have to point where the file is.

      Thanks for passing by.

  18. Hi,

    First of all I would say you did a great job of explaining entire application in a series of pages.Thank you for the efforts.

    I am having few basic questions regarding angular js and spring mvc for my new project. They are:

    1. Recently I came across angularjs and found it very interesting but i would like to know what are the additional benefits that we get when we use angular js for binding when compared to spring default binding and which one do you prefer for a new project.

    2.Is it scalable when we write entire application as restful and use angular js as front end and how much secure is that? or is there any other approach you can think of using angular js with bootstrap and spring mvc which makes my application scalable and secure.

    3. While researching on internet i found that bootstrap is not compatible with angular js to make them compatible we need to use angular-bootstrap js implementation. Did you face any issues for big projects with their compatibility?

    Could you please let me know these details that helps me a lot for designing my new project.

    Thanks,
    Santosh

    • Hello Santosh, how are you?

      1) The Angular binding is about a bind between HTML and Javascript, is not related to the Spring Model Binding. I think you could use both
      2) Right now the project needs a http session. You could use a rest approach with token and your project would be scalable
      3) cannot help you about this issue, sorry.

      Thanks for passing by.

  19. Hi,

    Thanks, for this tutorial,

    I am following step by step, when I got to page 4, I got this error :

    Description Resource Path Location Type
    The container ‘Maven Dependencies’ references non existing library ‘C:Usersalotfi.m2repositoryorghibernatehibernate-entitymanager4.2.4.Finalhibernate-entitymanager-4.2.4.Final.jar’ uaiContacts Build path Build Path Problem

    Can you please help me.
    thanks

  20. Hello,

    Thanks for a great post. The projects runs perfectly.

    I’d like to add an object end to use Lazy loading method. So I add Address class.
    The Client class become :
    class Client { ….
    @JsonIgnore
    @OneToMany(mappedBy = “client”)
    private Set address;
    ……
    }

    The Address class : {…
    @ManyToOne
    private Client client;

    }

    But, when I try to get client I have this error :
    HandlerMethod details:
    Controller [uaiContacts.controller.ClientsController]
    Method [public org.springframework.http.ResponseEntity uaiContacts.controller.ClientsController.listAll(int,java.util.Locale)]

    org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: failed to lazily initialize a collection of role: uaiContacts.model.Client.address, could not initialize proxy – no Session (through reference chain: uaiContacts.controller.vo.ClientListVO[“clients”]->java.util.UnmodifiableRandomAccessList[0]->uaiContacts.controller.model.Client[“address”]); nested exception is org.codehaus.jackson.map.JsonMappingException: failed to lazily initialize a collection of role: uaiContacts.model.Client.address, could not initialize proxy – no Session (through reference chain: uaiContacts.vo.ClientListVO[“clients”]->java.util.UnmodifiableRandomAccessList[0]->uaiContacts.model.Client[“address”])

    Can you help me please to resolve this problem.

  21. Hi,
    I have got a quick question for you.

    Pardon my ignorance here, but is there a point in Using Spring MVC application and have angular JS in the same app.

    This would mean, java controllers would serve JSP pages, which in turn would have angularJS controllers and code on the client side.

    Is this a logical flaw? I feel like mixing MVC + MVVM in the same application sounds dirty?
    Please advise.

    Thanks,
    Paul John
    00971561886167

    • Hello Paul, how are you?

      I am using only the angular binding feature, that is why I did not see any problem with this approach.

      But I do agree with you that using both controllers would be very dirty.

      Thanks for passing by.

  22. Hi,

    First of all, I would like thanking you for efforts to entire application in a single page

    But, when i trying to run this project. I am getting below mentioned error.

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:97)
    2014-07-30 20:29:32.274:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0′: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]: Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:132)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
    at $Proxy5.toString(Unknown Source)
    at java.lang.String.valueOf(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source)
    at org.hibernate.ejb.util.LogHelper.logPersistenceUnitInfo(LogHelper.java:38)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:528)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:75)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:97)
    2014-07-30 20:29:32.306:INFO::Started SelectChannelConnector@0.0.0.0:8080

    • Hello Naresh, how are you?

      I believe that your error is with the JPA: Error creating bean with name ‘entityManagerFactory’ defined in ServletContext resource [/WEB-INF/spring/spring-jpa.xml]

      Check your configurations in this file.

      Thanks for passing by.

    • Hello Jerry, how are you?

      I will not update it because it will be a lot of changes in the post and in the code.

      Thanks for passing by

  23. Hi, I am new to maven & spring. Is there is any faster/easier way to add these loads of dependencies in pom.xml? It looks a bit daunting to add all these before starting the project. What I mean to say is this, isn’t there a way to add dependencies on the fly, as Eclipse imports java libraries while writing the class?

    • Hello Gamekathu, how are you?

      That depends of your IDE. With Intellij you could do it, but with Eclipse I do not know.

      Thanks for passing by.

  24. Hi Uaihebert…
    i’m developing login module using Angularjs with MySql database and using spring MVC….
    already developed Ui and java backend coding …
    but i get stuck in calling Rest Service via Angularjs controller using json object ??how can i proceed??

    • Hello Arun, how are you?

      I am sorry but I cannot help without seeing your code.

      You could post some of your at stackoverflow.com and ask some help there. In this comment the code would break and get no formatting.

      Thanks for passing by

  25. Hi,
    I just downloaded your whole app and run “clean install tomcat7:run”.
    I get:
    javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].

    I didn’t change anything after download, so do I have to make some configuration change?

    Cheers

  26. Why did you choose using tiles template, being able to use angularjs directives to modularize client side, detaching completely the responsabilites of views to angular?

  27. hi,

    this project runs smoothly as your guides.

    only that i cant login even after added users {admin & user}.

    here’s log from eclipse:

    TRACE [org.springframework.web.context.support.XmlWebApplicationContext] [] http-bio-8080-exec-10 Publishing event in Root WebApplicationContext: org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent; Authenticated: false; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@43458: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 0B0E90275A7A2663BACEF0E3EBA1BC6F; Not granted any authorities]

    • Hello wak, I am sorry but your log is to big for me to analyse it right now.

      If you have just the error part post it so that I can read.

      Thanks for passing by

      • Hello Hicham, how are you?

        First of all, I am really sorry for taking so long in my answer. I am working more than 10h per day, in this last month, all days. =(

        You could run it in the helios without a problem, you just need to install the helios version plugins.

        God bless you too.

        Thanks for the support. [=

      • Hallo Uaihebert,

        thank you for your SUPER tutorial. It is very good.
        I am not able to debug the code using tomcat7-maven-plugin and Run As/Debug As the project whit Eclipse on Server ( Tomcat 7).
        Do you have any suggestions?

        Thanks,
        Antonino

        • Hello Antonino.

          Are you having any error message?

          I am sorry for the late reply, I am working a lot these last days… I am at my job right now!

          See you later.

          • Hallo uaihebert,

            thank you for your email.

            First question => solved.
            I found the solution for running tomcat plugin in debug mode by the link
            http://javahotpot.blogspot.in/2013/11/running-tomcat-maven-plugin-in-debug.html

            Second Question
            I created A Web Application Project With Maven
            and copied your code in this Project.
            When I run the project Run As/Debug As the project whit Eclipse on Server (Tomcat 7),
            I get the following error message

            Jän 28, 2015 11:38:34 AM org.apache.catalina.core.StandardContext listenerStart
            SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
            org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring-jpa.xml]
            Offending resource: ServletContext resource [/WEB-INF/spring/spring.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 26 in XML document from ServletContext resource [/WEB-INF/spring/spring-jpa.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 26; columnNumber: 69; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘tx:annotation-driven’.
            at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
            at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
            at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:261)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:186)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:171)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:100)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
            at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
            at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
            at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
            at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
            at java.util.concurrent.FutureTask.run(FutureTask.java:262)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
            at java.lang.Thread.run(Thread.java:744)
            Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 26 in XML document from ServletContext resource [/WEB-INF/spring/spring-jpa.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 26; columnNumber: 69; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘tx:annotation-driven’.
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)

          • Hello Antonino.

            It looks like you have a problem in your spring XML file.

            matching wildcard is strict, but no declaration can be found for element ‘tx:annotation-driven’.

            Check the namespace description.

            Thanks for passing by

    • Hello Bhupendra,

      If you look at the last page, in the source code, you will find the link to the project repository.

      Thanks for passing by.

  28. Thank you for the tutorial. I have one issue, I’m not able to login even after creating the two users (admin, user). Do you have any idea ?

    Thank you in advance.

  29. i dont seem to have a folder structure like in yout example… i dont have the apache folder, or other folders like in your exampe. Any ideas why? After i created pom.xml what is the next step? i run maven-update project but not much seems to happen?

    • Nikola, how are you?

      You will need to create the tomcat folder manually.

      That is a folder that will hold the tomcat configuration.

  30. Very good tutorial and explanation.
    I try to follow your tutorial step by step but got errors in spring-jpa.xml.
    the error is like below
    Multiple markers in this line
    Reference file contains errors (http://www.springframework.org/schema/context/spring-context-3.0.xsd) ……
    Reference File contains errors (http://www.springframework.org/schema/tool/spring-tool-3.0.xsd) ……
    Refrence file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.0.xsd). For information , right click on the message in the problems view dan select “Shows Detail”

    Thanks for your tutorial.

    • Hello Salman,

      Those errors are the Eclipse validation errors, it should not stop you from building/running the project.

      Thanks for passing by

  31. Hi Uaihebert,

    I am also unable to login even after creating users.
    There are no errors in the logs(catalina.out).
    Have put some syso statements in LoginController; they are also not getting printed.

    I know definitely its not a DB connection error because the server is getting started without any errors.
    Any help would be highly appreciated.

    Regards,
    Ansh

    • Hello Ansh, how are you?

      Open the file log4j.xml and set de log level do DEBUG.

      Maybe it will print a message with the error.

      Thanks for passing by

      • Hi uaihebert,

        Thanks for following up.

        I set the log level to DEBUG, still no success .. nothing in the logs :(

        Below is the structure of the table. Can tinyint be a problem?

        CREATE TABLE `system_user` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `email` varchar(255) DEFAULT NULL,
        `enabled` tinyint(1) DEFAULT ‘1’,
        `name` varchar(255) DEFAULT NULL,
        `password` varchar(255) DEFAULT NULL,
        `user_role` varchar(255) DEFAULT NULL,
        PRIMARY KEY (`id`)
        ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

        and the data is :

        mysql> select * from system_user;
        +—-+—————-+———+——-+———-+————+
        | id | email | enabled | name | password | user_role |
        +—-+—————-+———+——-+———-+————+
        | 2 | amin@gmail.com | 1 | Admin | admin | ROLE_ADMIN |
        +—-+—————-+———+——-+———-+————+
        1 row in set (0.05 sec)

        Please help!

        Regards,
        Ansh

        • Hello Ansh,

          I am sorry but I do not know where the problem could be.

          You could check the query or anything else that involves the authentication.

          THanks for passing by and I am sorry for not knowing a solution to your problem.

  32. Hi uaihebert

    I am able to run your project successfully. But after I log in when clicking on contact tab, I am getting an error on UI (Something happened

    We have an unexpected result, could you report it to the administrator please?)

    Can you please help me to get rid of this. I am not getting anything in the tomcat console. I have contact table in my DB too.

    Regards
    Deep.

    • Hellp Deep,

      Check to see if your user has the right profile.

      If you are not finding the error, go to the log4j.xml file and change the log level from INFO to DEBUG.

      I hope that helps you, thanks for passing by.

  33. Hi uaihebert. I had created database schemas :”uaiContacts”. and i edit file context.xml?. when i run this app. it has more errors.

    [LOG]

    should i create more table in database? and where is file SQL for table?. Thanks u so much!!!

    • Hello Jake,

      I did not see any error in the LOG that you posted.

      Could you post only the error block?

      The database will be created automatically. (:

  34. Hi uaihebert,

    Need to say nice tutorial with nice explanations :).
    And this works fine in my machine too.

    And I have some suggestions for you
    1.Can we remove those jsps and use only html for our views.I see you are using spring message library for i18n purpose.We can give this to angular side.isnt it?

    2.And I need to know how I can divide this project into two project which is angular(front end) and spring backend and can we join them with request mappings..??

    thanks.
    have a nice day

    • DilharHello , how are you?

      I am sorry for the late reply, I have been really busy this last month.

      1) Yes you can.

      2) In Spring you would return only JSON and not a request mapping. You would use angular module+routing to controll the request.

      Regards

  35. Hi Sir:

    Thanks for your excellent code.

    I tried adding a date field to handle the “date of birth” of contact. However, in my form using the code below what was displayed is numeric value and not in the format of yyyy-MM-dd.

    Hope you can help figure this out.

    Thanks and kind regards.

    • Hello Fernando, how are you?

      I am sorry for the late reply, I have been really busy this last month.

      You should format the date. Search on google for: “format date springmvc”

      Regards

  36. Halo Hebert,
    I want to learn about spring and found your tutorial. but I got problem when
    I copied your code and import to “Spring Tool Suite” then when I run using maven
    #maven tomcat7:run
    I got errors
    ……………………………………… at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBean
    Factory.java:1443)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFa
    ctory.java:519)
    … 19 more
    Caused by: org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested
    exception is javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].

    at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:139)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
    at com.sun.proxy.$Proxy22.getConnection(Unknown Source)
    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.ja
    va:70)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcService
    sImpl.java:242)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
    at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:96)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntit
    yManagerFactoryBean.java:268)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:3
    10)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableB
    eanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBean
    Factory.java:1452)
    … 34 more
    Caused by: javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:132)
    … 52 more

    Mar 06, 2015 7:36:11 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error listenerStart
    Mar 06, 2015 7:36:11 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/uaiContacts] startup failed due to previous errors
    Mar 06, 2015 7:36:11 PM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Mar 06, 2015 7:36:11 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler [“http-bio-8080″]

    and this my context.xml file

    WEB-INF/web.xml

    could you help me to solve this errors ?
    thanks

    • Hello Salman, how are you?

      I am sorry for the late reply, I have been really busy this last month.

      You have an error in your datasource Caused by: javax.naming.NameNotFoundException: Name [jdbc/tomcatDataSource] is not bound in this Context. Unable to find [jdbc].

      Check if the context.xml file is in the correct folder, and if the database data is correct.

      Regards

    • Hello Jake, how are you?

      I am sorry for the late reply, I have been really busy this last month.

      I am glad that you could solve it.

      Regards

  37. We see so much stuff in console.
    I am ubable to turn that off. I thought log4j file should govern this but I seem to be lost why so much stuff is getting thrown on console.

    • Hello Tapan, how are you?

      You can edit the log4j.xml file and lower the amount of messages.

      Thanks for passing by.

  38. Hello uaihebert,

    Very nice tutorial and neatly written.

    I am able to run the application successfully using latest version of the frameworks that are used.

    Do let me know if you want me to send the updated files for reference.

    Thanks
    Naveen

    • Hello Naveen, how are you?

      I am sorry for the late reply, I have been really busy this last month.

      I appreciate your help for upgrading the frameworks. I will keep the same versions of the frameworks because all the post structure was created following those specific version, I is better to keep that way.

      Regards

Leave a Comment