I have the hibernate-context
<context:property-placeholder location="/WEB-INF/spring.properties" />
<!-- Enable annotation style of managing transactions -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- Declare the Hibernate SessionFactory for retrieving Hibernate sessions -->
<!-- See http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.html -->
<!-- See http://docs.jboss.org/hibernate/stable/core/api/index.html?org/hibernate/SessionFactory.html -->
<!-- See http://docs.jboss.org/hibernate/stable/core/api/index.html?org/hibernate/Session.html -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
p:dataSource-ref="dataSource"
p:configLocation="${hibernate.config}"
p:packagesToScan="com.vaannila"/>
<!-- Declare a datasource that has pooling capabilities-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close"
p:driverClass="${app.jdbc.driverClassName}"
p:jdbcUrl="${app.jdbc.url}"
p:user="${app.jdbc.username}"
p:password="${app.jdbc.password}"
p:acquireIncrement="5"
p:idleConnectionTestPeriod="60"
p:maxPoolSize="100"
p:maxStatements="50"
p:minPoolSize="10" />
<!-- Declare a transaction manager-->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" />
</beans>
now i want to pass sessionFactory in my constructor of DAO like below
<bean id="registrationDAO" class="com.vaannila.dao.RegistrationDAOimpl" >
<constructor-arg ref="sessionFactory"/>
</bean>
but error says that bean sessionfactory not found
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registrationDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
This work for me
<bean id="hibernateSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:/hibernate.cfg.xml</value>
</property>
<property name="dataSource" ref="dataSource">
</property>
</bean>
<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="hibernateSessionFactory" />
</bean>
<bean class="com.vaannila.dao.RegistrationDAOimpl"
id="registrationDAO">
<property name="sessionFactory">
<ref bean="hibernateSessionFactory" />
</property>
</bean>
Related
I'm trying to migrate from spring-data-mongo 1.9.5 to 1.10.0 in order to use the noCursorTimeout() method in Query class, but I'm getting an error trying to deploy the application:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.example.util.properties.MongoPropertiesConfiguration#7dc57a65' defined in ServletContext resource [/WEB-INF/properties-context.xml]: Cannot resolve reference to bean 'mongoTemplateReplicaSet' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplateReplicaSet' defined in ServletContext resource [/WEB-INF/mongo-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxxxx': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean.()
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:648)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 68 more
It seems that MongoRepositoryFactoryBean doesn't have a default constructor anymore.
This is my spring mongo configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.10.xsd">
<bean id="mongoServer" class="com.mongodb.ServerAddress">
<constructor-arg type="java.lang.String" name="host" value="localhost"/>
<constructor-arg type="int" name="port" value="27017"/>
</bean>
<bean id="mongoServerList" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="mongoServer"/>
</list>
</constructor-arg>
</bean>
<bean id="mongoCredential" class="com.mongodb.MongoCredential">
<constructor-arg name="mechanism" value="#{T(com.mongodb.AuthenticationMechanism).SCRAM_SHA_1}"/>
<constructor-arg type="java.lang.String" name="userName" value="user"/>
<constructor-arg type="java.lang.String" name="source" value="myDB"/>
<constructor-arg type="char[]" name="password" value="xxxxx"/>
</bean>
<bean id="mongoCredentialList" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="mongoCredential"/>
</list>
</constructor-arg>
</bean>
<!-- MongoClient -->
<bean id="mongoClient" class="com.mongodb.MongoClient">
<constructor-arg ref="mongoServerList"/>
<constructor-arg ref="mongoCredentialList"/>
</bean>
<!-- MongoDbFactory -->
<bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
<constructor-arg name="mongo" ref="mongoClient"/>
<constructor-arg name="databaseName" value="myDb"/>
</bean>
<bean id="mappingContext"
class="org.springframework.data.mongodb.core.mapping.MongoMappingContext"/>
<bean id="typeInformationMapper" class="com.example.util.typemapper.AnnotationTypeInformationMapper">
<constructor-arg name="basePackagesToScan">
<list>
<value>com.example.entity</value>
</list>
</constructor-arg>
</bean>
<bean id="defaultMongoTypeMapper"
class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper">
<constructor-arg name="typeKey" value=
"_class" />
<constructor-arg name="mappers" >
<list>
<ref bean="typeInformationMapper" />
</list>
</constructor-arg>
</bean>
<bean id="mappingMongoConverter"
class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
<constructor-arg name="mappingContext" ref="mappingContext"/>
<property name="typeMapper" ref="defaultMongoTypeMapper"/>
</bean>
<!-- MongoTemplate -->
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate" primary="true">
<property name="writeResultChecking" value="EXCEPTION"/>
<property name="writeConcernResolver" ref="writeConcernResolver"/>
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
<constructor-arg name="mongoConverter" ref="mappingMongoConverter" />
</bean>
<bean id="mongoTemplateReplicaSet" class="org.springframework.data.mongodb.core.MongoTemplate" primary="false">
<property name="writeResultChecking" value="EXCEPTION"/>
<property name="writeConcernResolver" ref="writeConcernResolver"/>
<property name="readPreference" ref="readPreferenceSecondary"/>
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
<constructor-arg name="mongoConverter" ref="mappingMongoConverter" />
</bean>
<bean id="writeConcernResolver" class="com.example.MyWriteConcernResolver">
</bean>
<bean id="readPreferenceSecondary" class="com.mongodb.TaggableReadPreference.SecondaryPreferredReadPreference"/>
<mongo:repositories base-package="my.repository.package.*"/>
I'm using Spring 4.3.6.RELEASE and java-mongo-driver 3.3.0
Try Spring-Data-mongo 1.10.12 rather 1.10.0. And Update the mongo-java driver to 3.4.0
I managed to solve this changing the version of spring-data-commons as well.
These are the versions I used:
spring: 4.3.6.RELEASE,
spring-data-commons: 1.13.0.RELEASE,
spring-data-mongodb: 1.10.11.RELEASE
I have been running my project on Java 7 (exact version: jdk1.7.0_60) but since there is a company wide policy changed to upgrade to Java 8 (version: jdk1.8.0_73) I have upgraded my local machine's JVM to jdk1.8.0_73 and configured my project on this version.
Following are the facts for my project:
Spring Framework Version: 4.0.3.RELEASE
Java: jdk1.8.0_73
Since then my application is throwing following exceptions:
Feb 16, 2016 12:15:14 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.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#1': Cannot create inner bean 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0' of type [com.asi.core.spring.interceptor.ThrottleRequestInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.asi.v1.ext.api.service.impl.ThrottleService com.asi.core.spring.interceptor.ThrottleRequestInterceptor.throttlerV1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'throttlerV1': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.client.RestTemplate com.asi.v1.ext.api.service.impl.ThrottleService.restTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplate' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] while setting bean property 'messageConverters' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.MediaType#3ffc5996' of type [org.springframework.http.MediaType] while setting bean property 'supportedMediaTypes' with key [0]; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.ExpressionInvocationTargetException: A problem occurred when trying to execute method 'forName' on object of type [java.lang.Class]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
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: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.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#1': Cannot create inner bean 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0' of type [com.asi.core.spring.interceptor.ThrottleRequestInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.asi.core.spring.interceptor.ThrottleRequestInterceptor#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.asi.v1.ext.api.service.impl.ThrottleService com.asi.core.spring.interceptor.ThrottleRequestInterceptor.throttlerV1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'throttlerV1': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.web.client.RestTemplate com.asi.v1.ext.api.service.impl.ThrottleService.restTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplate' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] while setting bean property 'messageConverters' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#4dd016c7' defined in class path resource [spring/application-config.xml]: Cannot create inner bean 'org.springframework.http.MediaType#3ffc5996' of type [org.springframework.http.MediaType] while setting bean property 'supportedMediaTypes' with key [0]; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.ExpressionInvocationTargetException: A problem occurred when trying to execute method 'forName' on object of type [java.lang.Class]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:290)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:632)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:470)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1071)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:277)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.detectMappedInterceptors(AbstractHandlerMapping.java:221)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.initApplicationContext(AbstractHandlerMapping.java:196)
at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)
at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 20 more
Here is my spring configurations:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven/>
<web-services:annotation-driven/>
<web-services:dynamic-wsdl id="productSearch" portTypeName="ProductSearch"
targetNamespace="http://www.asicentral.com/schema/product" locationUri="/productSearchService">
<web-services:xsd location="/WEB-INF/product.xsd"/>
</web-services:dynamic-wsdl>
<web-services:dynamic-wsdl id="loginAPI" portTypeName="LoginAPI"
targetNamespace="http://www.asicentral.com/schema/login" locationUri="/loginAPI">
<web-services:xsd location="/WEB-INF/login.xsd"/>
</web-services:dynamic-wsdl>
<web-services:dynamic-wsdl id="batchAPI" portTypeName="BatchAPI"
targetNamespace="http://www.asicentral.com/schema/batch" locationUri="/batchAPI">
<web-services:xsd location="/WEB-INF/batch.xsd"/>
</web-services:dynamic-wsdl>
<context:component-scan base-package="com.asi"></context:component-scan>
<mvc:interceptors>
<bean class="com.asi.core.spring.interceptor.ThrottleRequestInterceptor" />
</mvc:interceptors>
<cache:annotation-driven />
<import resource="v1.xml"/>
<!-- When more versions are listed load version specific xml config -->
<import resource="v2.xml"/>
<import resource="v3.xml"/>
<bean id="headerHandler" class="com.asi.v1.service.resource.util.ExternalApiHeaderHandler" />
<bean id="ExternalApiApplicationContextProvider" class="com.asi.core.spring.config.provider.ExternalApiApplicationContextProvider"></bean>
<bean id="environmentConfigurator" class="com.asi.ext.api.config.EnvironmentConfigurator">
<property name="env" value="${Ext.env}"></property>
<property name="lookupRestTemplate" ref="restTemplate"></property>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml"/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>
<context:property-placeholder location="classpath:${Ext.env}-environment.properties, classpath:velocity-import*.properties, classpath:radar-version.properties" order="1"/>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml"/>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
</list>
</property>
</bean>
<bean id="dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="jdbcUrl" value="jdbc:sqlserver://${db.velocity.host}:${db.velocity.port};databaseName=${db.velocity.database}" />
<property name="user" value="${db.velocity.username}" />
<property name="password" value="${db.velocity.password}" />
<!-- these are C3P0 properties -->
<property name="acquireIncrement" value="1" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="300" />
</bean>
<bean id="hibernate3AnnotatedSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.asi.ext.api.dao.ExternalAPILogger</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
</bean>
<bean id="logDAO" class="com.asi.ext.api.dao.ExternalApiLoggerImpl">
<property name="sessionFactory" ref="hibernate3AnnotatedSessionFactory" />
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg value="application" />
<constructor-arg value="json" />
<constructor-arg value="#{T(java.nio.charset.Charset).forName('UTF-8')}"/>
</bean>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.StringHttpMessageConverter ">
<constructor-arg value="#{T(java.nio.charset.Charset).forName('UTF-8')}"/>
</bean>
</list>
</property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>error</value>
</property>
</bean>
</beans>
whereas, the v1, v2 & v3.xml imports are for different versions of beans. For example, below is just v1.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="loginServiceV1" class="com.asi.v1.ext.api.service.impl.LoginServiceImpl">
<property name="restTemplate" ref="restTemplate" />
<property name="loginAPIUrl" value="${ws.api.login}" />
<property name="authorizationKey" value="${ws.api.login.doorman.key}" />
<property name="authorizationScheme" value="${ws.api.login.doorman.auth.scheme}" />
<property name="grantTypeKey" value="${ws.api.login.doorman.auth.grant_type.key}" />
<property name="grantTypeValue" value="${ws.api.login.doorman.auth.grant_type.value}" />
<property name="appCodeKey" value="${ws.api.login.doorman.auth.app_code.key}" />
<property name="appCodeValue" value="${ws.api.login.doorman.auth.app_code.value}" />
<property name="appVersionKey" value="${ws.api.login.doorman.auth.app_version.key}" />
<property name="appVersionValue" value="${ws.api.login.doorman.auth.app_version.value}" />
</bean>
<bean id="batchServiceV1" class="com.asi.v1.ext.api.service.impl.BatchServiceImpl">
<property name="restTemplate" ref="restTemplate" />
<property name="createBatchURL" value="${ws.api.batch.create}" />
<property name="finalizeBatchURL" value="${ws.api.batch.finalize}" />
</bean>
<bean id="productServiceClientV1" class="com.asi.v1.service.product.client.ProductClient">
<property name="productSearchUrl" value="${ws.api.product.import}" />
<property name="scheme" value="${ws.api.authorization.scheme}" />
</bean>
<bean id="throttlerV1" class="com.asi.v1.ext.api.service.impl.ThrottleService">
<property name="radarLoginService" value="${ws.api.throttle.radar.validate.token.url}" />
<property name="throttleRequest" value="${ws.api.throttle.required}" />
<property name="maximumRequests" value="${ws.api.throttle.maximum.requests}" />
<property name="maximumWaitCalendarField" value="${ws.api.throttle.wait.time.field}" />
<property name="maximumWaitHours" value="${ws.api.throttle.wait.time}" />
<property name="restTemplate" ref="restTemplate"/>
</bean>
<!-- <bean id="loginService" class="com.asi.v1.service.resource.LoginService">
<property name="loginAPIUrl" value="${ws.api.login}"></property>
</bean> -->
<!-- <bean id="lookupDataStore" class="com.asi.v1.ext.api.product.transformers.ProductDataStore">
<property name="lookupRestTemplate" ref="restTemplate"/>
<property name="lookupConverter" ref="jsonlookupConvertor" />
</bean>
<bean id="jsonlookupConvertor" class="com.asi.v1.ext.api.util.JsonToLookupTableConverter">
<property name="lookupRestTemplate" ref="restTemplate"/>
</bean> -->
<bean id="lookupValuesClientV1" class="com.asi.v1.service.product.client.LookupValuesClient">
<property name="lookupRestTemplate" ref="restTemplate"/>
<property name="lookupColorURL" value="${lookup.color.url}"></property>
<property name="lookupSizeURL" value="${lookup.sizes.url}"></property>
<property name="lookupMaterialURL" value="${lookup.material.url}"></property>
<property name="lookupcriteriaAttributeURL" value="${lookup.sizes.criteria.url}"></property>
<property name="originLookupURL" value="${lookup.orgin.url}"></property>
<property name="lookupCategoryURL" value="${lookup.product.categories.url}"></property>
<property name="lookupArtworkURL" value="${lookup.imprint.artwork.url}"></property>
<property name="lookupImprintURL" value="${lookup.imprint.url}"></property>
<property name="lookupTradeNameURL" value="${lookup.product.trade.names.url}"></property>
<property name="lookupShapeURL" value="${lookup.product.shapes.url}"></property>
<property name="lookupPackageURL" value="${lookup.packaging.url}"></property>
</bean>
<bean id="lookupParserV1" class="com.asi.v1.ext.api.integration.lookup.parser.LookupParser">
<!-- <property name="lookupClient" ref="lookupValuesClient"/> -->
<!-- <property name="imprintParser" ref="imprintMethodParser"/> -->
</bean>
<bean id="criteriasParser" class="com.asi.v1.ext.api.integration.lookup.parser.CriteriaSetParser">
<!-- <property name="productLookupParser" ref="lookupParser"/> -->
</bean>
<bean id="productConfigurationParser" class="com.asi.v1.ext.api.integration.lookup.parser.ProductConfigurationsParser">
<property name="productLookupParser" ref="lookupParser"/>
</bean>
<bean id="configurationParserV1" class="com.asi.v1.ext.api.integration.lookup.parser.ConfigurationsParser">
<!-- <property name="productLookupParser" ref="lookupParser"/> -->
</bean>
<bean id="imprintMethodParserV1" class="com.asi.v1.ext.api.integration.lookup.parser.ImprintParser">
<!-- <property name="criteriaLookupParser" ref="criteriasParser"/>
<property name="lookupsParser" ref="lookupParser"/> -->
</bean>
<bean id="productServiceV1" class="com.asi.v1.ext.api.service.impl.ProductServiceImpl">
</bean>
<bean id="productRepoV1" class="com.asi.v1.core.repo.product.ProductRepo">
<!-- <property name="productClient" ref="productServiceClient"/> -->
<!-- <property name="productConfiguration" ref="productConfigurationParser"/> -->
<!-- <property name="configurationParser" ref="configurationParser"/> -->
<!-- <property name="imprintParser" ref="imprintMethodParser"/> -->
<!-- <property name="productRestTemplate" ref="restTemplate"/> -->
<property name="productImportURL" value="${ws.api.product.import}"></property>
<property name="batchProcessingURL" value="${lookup.batch.processing}"></property>
<!-- <property name="lookupDataStore" ref="lookupDataStore" /> -->
<!-- <property name="lookupsParser" ref="lookupParser"/> -->
</bean>
<!-- To enable #RequestMapping process on type level and method level -->
<bean id="productDetailV1" class="com.asi.v1.service.product.client.vo.ProductDetail"/>
</beans>
This issue was never there until i was using Java 7 version when I switched it to Java 8 then I am seeing this exception. Due to limitation of this editor I cannot paste the entire exception log. Will paste in comments if you need.
Can anyone help me with this issue?
Try value="java.nio.charset.StandardCharsets.UTF_8" instead of value="#{T(java.nio.charset.Charset).forName('UTF-8')}". You would also need to name your parameters otherwise Spring won't be able to instantiate the MediaType since multiple constructors with 3 parameters exist.
You can try the following code :
<bean class="org.springframework.http.MediaType" >
<constructor-arg name="type" value="application" />
<constructor-arg name="subtype" value="json" />
<constructor-arg name="charset" value="#{T(java.nio.charset.StandardCharsets).UTF_8}"/>
</bean>
Thank you #louis-f for pointing out the issue and providing the solution. I tried to resolve this issue with the above suggestions but it was still giving the same exceptions.
Then I tried following and it resolves my issue:
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg name="type" value="application"/>
<constructor-arg name="subtype" value="json"/>
<constructor-arg name="charset" value="UTF-8" />
</bean>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg name="defaultCharset" value="UTF-8" />
</bean>
</list>
</property>
</bean>
So, what I actually did is just changed the charset constructor argument to string value i.e. "UTF-8" and it did worked for me.
On the application debugging - I checked the object restTemplate in inspect element and now I have everything coming properly for the messageConverters list.
Thanks again.
I have an AOP proxy bean defined as follows:
<bean id="someService" class="..FactoryBean">
..
<property name="target">
<ref local="target" />
</property>
<property name="preInterceptors"><ref local="serviceInterceptors"/></property>
..
</bean>
a target bean:
<bean id="target" class=".." />
and a child to the target bean:
<bean parent="target">
<!-- set some properties -->
</bean>
I'd like to change the target bean to an anonymous bean, but maintain the child bean. The only problem is setting parent attribute of child bean to AOP proxy bean inherits from the factory bean and not the target bean. Is there a work around for this?
Not pretty, but it should work:
<bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<bean class="com.foo.bar.ExampleService" />
</property>
</bean>
<bean id="targetSource" factory-bean="proxy" factory-method="getTargetSource" />
<bean id="parent" factory-bean="targetSource" factory-method="getTarget" />
<bean parent="parent" />
I have an application context where I am trying to setup JPA:
application-context.xml:
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
<property name="persistenceUnits">
<map>
<entry key="pu1" value="pu1" />
<entry key="pu2" value="pu2" />
</map>
</property>
<property name="defaultPersistenceUnitName" value="pu1" />
</bean>
<bean id="emf1" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="pu1" />
<property name="dataSource" ref="dataSource1" />
</bean>
<bean id="emf2" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.SQLServer2005Dialect" />
</bean>
</property>
<property name="persistenceUnitName" value="pu2" />
<property name="dataSource" ref="dataSource2" />
</bean>
<!-- Enable annotation style of managing transactions -->
<tx:annotation-driven />
<bean id="transactionManager1" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf1" />
<property name="dataSource" ref="dataSource1" />
</bean>
<bean id="transactionManager2" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf2" />
<property name="dataSource" ref="dataSource2" />
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/db/database.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="ignoreResourceNotFound" value="true" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
</bean>
<!-- The actual config of the database is read from the properties file database.properties -->
<bean id="dataSource1" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"
p:acquireIncrement="5" p:idleConnectionTestPeriod="14400" p:maxPoolSize="50" p:maxStatements="15"
p:minPoolSize="5" p:testConnectionOnCheckout="true" p:preferredTestQuery="SELECT 4;"
p:driverClass="${db.system1.driver}" p:jdbcUrl="${db.system1.url}" p:user="${db.system1.user}" p:password="${db.system1.password}" />
<bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" p:acquireIncrement="5" p:idleConnectionTestPeriod="60" p:maxPoolSize="10"
p:maxStatements="50" p:minPoolSize="3" p:testConnectionOnCheckout="true" p:preferredTestQuery="SELECT 4;"
p:driverClass="${db.system2.driver}" p:jdbcUrl="${db.system2.url}" p:user="${db.system2.user}" p:password="${db.system2.password}" />
<context:annotation-config />
<context:component-scan base-package="com.myapp.model.manager"/>
persistence.xml:
<persistence-unit name="pu1" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.myapp.model.Address</class>
<class>com.myapp.model.AgressoFile</class>
<class>com.myapp.model.CustomerGroup</class>
...
</persistence-unit>
<persistence-unit name="pu2" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.myapp.model.CompetenceArea</class>
<class>com.myapp.model.CompetenceAreaCategory</class>
...
</persistence-unit>
I am loading application context in a web.xml this way:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/application-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
CompetenceAreaManager class that locates in the scanned package "com.myapp.model.manager" has the following content:
#Service
public class CompetenceAreaManager {
#PersistenceUnit(unitName = "pu2")
private EntityManagerFactory entityManagerFactory;
#SuppressWarnings("unchecked")
public List<CompetenceArea> getCompetenceAreas() {
List<CompetenceArea> competenceAreaList = null;
EntityManager em = entityManagerFactory.createEntityManager();
Query q = em.createNamedQuery(CompetenceArea.FIND_ALL);
competenceAreaList = q.getResultList();
return competenceAreaList;
}
public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}
}
However, when I try to run the application in Tomcat 7.0, I get the following error:
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 'competenceAreaManager': Injection of persistence dependencies failed; nested exception is java.lang.IllegalStateException: Could not obtain EntityManagerFactory [pu2] from JNDI
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:343)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
...
Caused by: java.lang.IllegalStateException: Could not obtain EntityManagerFactory [pu2] from JNDI
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.getPersistenceUnit(PersistenceAnnotationBeanPostProcessor.java:435)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:643)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:637)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
...
Caused by: javax.naming.NameNotFoundException: Name [pu2] is not bound in this Context. Unable to find [pu2].
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(Unknown Source)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
...
Any idea what I'm doing wrong?
If you configure the PersistenceAnnotationBeanPostProcessor with persistenceUnits, you are informing the PersistenceAnnotationBeanPostProcessor that PUs come from JNDI (as the javadoc for setPersistenceUnits() methods mentions it). The stack trace actually shows the failing JNDI lookup.
Since you are using <context:annotation-config/> in application-context.xml, you don't need to declare a PersistenceAnnotationBeanPostProcessor, because one will be automatically registered, which looks up PUs by reading your META-INF/persistence.xml files located in the classpath, which is actually what you expect.
Your configuration should be as simple as this :
persistence.xml remains unchanged
CompetenceAreaManager
As Sergey Makarov mentions it, just inject EntityManager with #PersistenceContext instead of injecting EntityManagerFactory with #PersistenceUnit. The em is transactional (thus bound to the thread, thus ensuring thread-safety for your DAO), and you can still configure #PersistenceContext with unitName in order to specify the PU the EM has to be bound to.
application-context.xml
Just drop the declaration of the PersistenceAnnotationBeanPostProcessor bean. The rest of the file remains unchanged.
I haven't tried your particular config (2 PUs), but the configuration I mention is the one I have always been using, with success.
As far I understood from my recent expirience of setting up 2 EntityManagerFactory in the same application - #PersistenceUnit(unitName="myPU") just doesn't work at all.
I would suggest to inject EntityManager, not EntityManagerFactory. This is clear since you always know which EMF is used. Same for specifying right TransactionManager.
Updated code of the service class:
#Service
public class CompetenceAreaManager
{
#PersistenceContext(unitName = "emf1")
private EntityManager em;
#SuppressWarnings("unchecked")
#Transactional(transactionManager="transactionManager1", readOnly=true)
public List<CompetenceArea> getCompetenceAreas()
{
List<CompetenceArea> competenceAreaList = null;
Query q = em.createNamedQuery(CompetenceArea.FIND_ALL);
competenceAreaList = q.getResultList();
return competenceAreaList;
}
}
Such injection is safe since Spring injects a proxy of EntityManager, which guarantees thread-safety.
I have encountered a problem of failed to create bean in spring suddenly. The webapp is already deployed and has been running for several months. However, below error message comes suddenly. It can be resolved by restarting the webapp, but comes again without any hints. Does anyone have any idea of this case?
Tomcat 6 is being used to host the webapp.
[2013/05/03 12:02:56:421 HKT] ajp-8009-42 org.ajax4jsf.webapp.BaseXMLFilter(227) - Exception in the filter chain
javax.servlet.ServletException: Error creating bean with name 'reportGenerationBean' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'scheduleBean' while setting bean property 'scheduleBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduleBean': Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException
applicationContext.xml as below
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:property-placeholder location="classpath*:webapp.properties,classpath*:env_prod.properties"/>
<context:annotation-config />
<bean id="facesUtils" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod">
<value>com.webapp.util.FacesUtils.init</value>
</property>
<property name="arguments">
<list>
<value>com.webapp.config.SpringBeanEnum</value>
<value>com.webapp.config.FacesBeanEnum</value>
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="inspectbookSessionFactory"/></property>
</bean>
<context:component-scan base-package="com.webapp.bo, com.webapp.service" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="hibernateDAO" abstract="true">
<property name="sessionFactory"><ref local="inspectbookSessionFactory"/></property>
</bean>
<!-- Temporary Setting -->
<bean id="ItemSearchBeanDao" class="com.webapp.dao.tmp.ItemSearchBeanDao" parent="hibernateDAO">
<property name="maxRecordNo" value="${no_of_record.order}"/>
</bean>
<bean id="BookedSearchBeanDao" class="com.webapp.dao.tmp.BookedSearchBeanDao" parent="hibernateDAO">
<property name="maxRecordNo" value="${no_of_record.booked}"/>
</bean>
<bean id="ScheduleBeanDao" class="com.webapp.dao.tmp.ScheduleBeanDao" parent="hibernateDAO"></bean>
<bean id="WhItemSearchBeanDao" class="com.webapp.dao.tmp.WhItemSearchBeanDao" parent="hibernateDAO">
<property name="maxRecordNo" value="${no_of_record.whItem}"/>
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="-secret-"/>
</bean>
<bean id="EmailUtil" class="com.webapp.util.EmailUtil">
<property name="mailSender" ref="mailSender"/>
</bean>
<bean id="freeMarkerTemplateMailer" class="com.webapp.bo.email.impl.FreeMarkerTemplateMailer">
<property name="mailSender" ref="mailSender"/>
</bean>
<bean id="emailService" class="com.webapp.bo.email.impl.EmailServiceImpl" >
<property name="orgunitDao" ref="OrgunitDAO"/>
<property name="contactMethodDao" ref="ContactMethodDAO"/>
<property name="mailer" ref="freeMarkerTemplateMailer"/>
</bean>
<bean id="scheduleEmail" class="com.webapp.bo.schedule.impl.ScheduleEmailImpl" >
<property name="orgunitDao" ref="OrgunitDAO"/>
<property name="scheduleBeanDao" ref="ScheduleBeanDao"/>
<property name="emailService" ref="emailService"/>
</bean>
<bean name="scheduleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.webapp.service.schedule.ScheduleJob" />
<property name="jobDataAsMap">
<map>
<entry key="scheduleEmail" value-ref="scheduleEmail" />
</map>
</property>
</bean>
<!-- JSF backing bean START -->
<bean id="vendorSearchBean" class="com.webapp.service.search.item.VendorSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.vendor}"/>
</bean>
<bean id="itemSearchBean" name="itemSearchBean" class="com.webapp.service.search.item.NewItemSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.order}"/>
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="itemSearchPopupBean" name="itemSearchPopupBean" class="com.webapp.service.search.item.NewItemSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.order}"/>
</bean>
<bean id="detailBean" class="com.webapp.service.detail.DetailBean" scope="session">
<property name="itemSearchBean" ref="itemSearchBean"/>
<property name="itemSearchPopupBean" ref="itemSearchPopupBean"/>
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="bookedSearchBean" class="com.webapp.service.search.booked.BookedSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.booked}"/>
</bean>
<bean id="scheduleConfirmBean" class="com.webapp.service.schedule.ScheduleConfirmBean" scope="session">
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="scheduleBean" class="com.webapp.service.search.schedule.ScheduleBean" scope="session">
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="dropBean" class="com.webapp.service.search.schedule.DropBean" scope="request">
<property name="scheduleBean" ref="scheduleBean"/>
</bean>
<bean id="inspectContactBean" class="com.webapp.service.detail.contact.InspectContactBean" scope="session">
<property name="detailBean" ref="detailBean"/>
</bean>
<bean id="inspectLocationBean" class="com.webapp.service.detail.contact.InspectLocationBean" scope="session">
<property name="detailBean" ref="detailBean"/>
</bean>
<bean id="whItemSearchBean" class="com.webapp.service.search.warehouse.WhItemSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.whItem}"/>
<!--<property name="propertiesUtil" ref="propertiesUtil"/>-->
</bean>
<!-- Autocomplete -->
<bean id="autocomplete" class="com.webapp.service.common.AutocompleteBean" scope="session"></bean>
<!-- PackingListBean -->
<bean id="packingListBean" class="com.webapp.service.common.PackingListBean" scope="session">
<property name="itemSearchBean" ref="itemSearchBean"/>
<property name="popupBean" ref="popupBean"/>
</bean>
<!-- Report Bean -->
<bean id="reportGenerationBean" class="com.webapp.service.report.ReportGenerationBean" scope="request">
<property name="itemSearchBean" ref="itemSearchBean"/>
<property name="packingListBean" ref="packingListBean"/>
<property name="scheduleBean" ref="scheduleBean"/>
</bean>
<!-- popupBean -->
<bean id="popupBean" class="com.webapp.service.common.PopupControlBean" scope="session">
</bean>
<!-- JSF backing bean END -->
</beans>