Okay this is getting kinda confusing....
I have always had my contextLoadListener in my web.xml as so:
Code:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:data-access-context.xml
</param-value>
</context-param>
is this the wrong location for this? NOTE: that I am defining my data-access-context location here.
I have also added to my data-access-context.xml:
Code:
<context:component-scan base-package="com.logixplayer.pf" />
<context:annotation-config />
but now I am getting errors at startup:
Code:
Jan 1, 2010 3:14:01 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jan 1, 2010 3:14:05 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 'homePageController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.logixplayer.pf.service.IProfileService com.logixplayer.pf.homepage.controller.HomePageController.profileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IProfileService' defined in class path resource [application-context-iProfileService.xml]: Cannot resolve reference to bean 'ProfileDAO' while setting bean property 'IProfileDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProfileDAO' defined in class path resource [data-access-context.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [data-access-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: dataAccessPU] Unable to build EntityManagerFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.logixplayer.pf.service.IProfileService com.logixplayer.pf.homepage.controller.HomePageController.profileService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IProfileService' defined in class path resource [application-context-iProfileService.xml]: Cannot resolve reference to bean 'ProfileDAO' while setting bean property 'IProfileDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProfileDAO' defined in class path resource [data-access-context.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [data-access-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: dataAccessPU] Unable to build EntityManagerFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
... 40 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IProfileService' defined in class path resource [application-context-iProfileService.xml]: Cannot resolve reference to bean 'ProfileDAO' while setting bean property 'IProfileDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProfileDAO' defined in class path resource [data-access-context.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [data-access-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: dataAccessPU] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
... 42 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProfileDAO' defined in class path resource [data-access-context.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [data-access-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: dataAccessPU] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
... 57 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [data-access-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: dataAccessPU] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
... 70 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: dataAccessPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 80 more
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 86 more
Jan 1, 2010 3:14:05 PM org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'pf' = [C:\apache-tomcat-6.0.20\webapps\PublicFountainWAR-0.0.1-SNAPSHOT\]
Jan 1, 2010 3:14:05 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [C:\apache-tomcat-6.0.20\webapps\PublicFountainWAR-0.0.1-SNAPSHOT\WEB-INF\conf\log4j.xml]
Jan 1, 2010 3:14:05 PM org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
Jan 1, 2010 3:14:05 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Jan 1, 2010 3:14:07 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jan 1, 2010 3:14:07 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
its talking about how the entitymanager cannot be instantiated because of Hibernate Dialect must be explicitly set and other errors..
I think the way I have organized all of this might not be correct. i.e. the location of the org.springframework.web.context.ContextLoaderListe ner or the way I am setting up the component scan? In the meantime I can try to resolve the hibernate dialect issue but I am not sure if this is really the crux of the problem...