Converting EJB MDB application to Spring base JMS service.
JMS Queue configuration is in Weblogic server.
Have following in configuration in applicationContext XML file.
<?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:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">
<bean id="vTMessageQueueListener" class="com.collection.mom.sink.EventMessageBean" />
<bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>/jms/FilingTopicConnFact</value>
</property>
</bean>
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="cache">
<value>true</value>
</property>
</bean>
<bean id="QueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="queueConnectionFactory" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property>
</bean>
<bean id="SMMessageQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<!--<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>-->
<property name="jndiName">
<value>com/vx/jms/vTMessageQueue</value>
</property>
</bean>
<bean id="V3JMSlistener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="5" />
<property name="connectionFactory" ref="queueConnectionFactory" />
<property name="destinationName" ref="SMMessageQueue"/>
<property name="messageListener" ref="vTMessageQueueListener" />
</bean>
</beans>
.
<HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'V3JMSlistener' defined in class path resource [SpringJMSContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'V3JMSlistener' defined in class path resource [SpringJMSContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:584)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:590)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:604)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1697)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1653)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:299)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:585)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:604)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1697)
Truncated. see log file for complete stacktrace
Any help will be appreciated!!!
Use
<property name="destination" ref="SMMessageQueue"/>
instead of destinationName.
Spring can resolve a destination from its name but since you have the destination, you should inject that directly.
entityManagerFactoryBean
2016-02-13 20:38:22 WARN XmlWebApplicationContext:546 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [5]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'UserDetailsServiceImplementation' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserDetailsServiceImplementation' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Cannot resolve reference to bean 'jpaUserDao' while setting bean property 'adminUserDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaUserDao' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Cannot resolve reference to bean 'entityManagerFactoryBean' while setting bean property 'entityManagerFactoryBean'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactoryBean' is defined
2016-02-13 20:38:22 ERROR ContextLoader:353 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [5]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'UserDetailsServiceImplementation' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserDetailsServiceImplementation' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Cannot resolve reference to bean 'jpaUserDao' while setting bean property 'adminUserDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaUserDao' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Cannot resolve reference to bean 'entityManagerFactoryBean' while setting bean property 'entityManagerFactoryBean'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactoryBean' is defined
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.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
spring-security.xml lies in web directory
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- enable use-expressions -->
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/adm/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/red/**" access="hasAnyRole('ROLE_ADMIN', 'ROLE_REDADMIN')" />
<intercept-url pattern="/**" access="permitAll" />
<!-- access denied page -->
<access-denied-handler error-page="/index" />
<form-login login-page="/login" default-target-url="/index"
login-processing-url="/j_spring_security_check"
authentication-failure-url="/login?error"
username-parameter="email"
password-parameter="password" />
<logout logout-success-url="/login?logout" />
<csrf />
</http>
<beans:bean id="UserDetailsServiceImplementation"
class="com.softserveinc.ita.redplatform.business.service.UserDetailsServiceImplementation">
<beans:property name="adminUserDao" ref="jpaUserDao" />
</beans:bean>
<beans:bean id="jpaUserDao"
class="com.softserveinc.ita.redplatform.persistence.dao.impl.JPAAdminUserDao">
<beans:property name="entityManagerFactoryBean" ref="entityManagerFactoryBean"/>
</beans:bean>
<authentication-manager>
<authentication-provider user-service-ref="UserDetailsServiceImplementation">
</authentication-provider>
</authentication-manager>
persistence-context.xml lies in persistence directory
<?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:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
<context:component-scan base-package="com.softserveinc.ita.redplatform.persistence.dao.impl" />
<bean id="entityManagerFactoryBean"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="JPAUnit" />
<property name="packagesToScan">
<list>
<value>com.softserveinc.ita.redplatform.common.entity</value>
</list>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactoryBean" />
</bean>
<!-- <bean id="jpaUserDao" class="com.softserveinc.ita.redplatform.persistence.dao.impl.JPAAdminUserDao"> -->
<!-- <property name="managerFactoryBean" ref="entityManagerFactoryBean"/> -->
<!-- </bean> -->
<tx:annotation-driven />
</beans>
web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>REDplatform</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<context:component-scan
base-package="com.softserveinc.ita.redplatform.web.controller" />
<import resource="classpath*:**/spring/*context.xml" />
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath*:**/properties/*properties</value>
</property>
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="formatters">
<set>
<ref bean="realEstateAgencyDTOFormatter" />
</set>
</property>
</bean>
<mvc:annotation-driven conversion-service="conversionService" />
<mvc:resources mapping="/resources/**" location="/resources/" />
JPAAdminUserDao class have method findUserByEmail
#Transactional
public class JPAAdminUserDao extends JPAGenericDao<AdminUser, Long>
implements AdminUserDao {
#Autowired
private EntityManager entityManagerFactoryBean;
/**
*
* #param email receiving
* #return AdminUser object
*/
public final AdminUser findUserByEmail(final String email) {
List<AdminUser> users = new ArrayList<AdminUser>();
users = (List<AdminUser>)entityManagerFactoryBean.getEntityManagerFactory().createEntityManager()
.createQuery("from " + AdminUser.class.getName()
+ " as user where user.email=:email")
.setParameter("email", email).getResultList();
if (users.size() > 0) {
return users.get(0);
} else {
return null;
}
}
}
UserDetailsServiceImplementation
public class UserDetailsServiceImplementation implements UserDetailsService {
/**
* Using JPAAdminUserDao object.
*/
#Autowired
private JPAAdminUserDao jpaUserDao;
#Override
public final UserDetails loadUserByUsername(final String username)
throws UsernameNotFoundException {
HashSet<String> set = new HashSet<String>();
AdminUser user = (AdminUser) jpaUserDao.findUserByEmail(username);
if (user instanceof AdminUser) {
set.add(new String("ROLE_USER"));
set.add(new String("ROLE_ADMIN"));
set.add(new String("ROLE_REDADMIN"));
} else {
set.add(new String("ROLE_USER"));
}
List<GrantedAuthority> authorities = buildUserAuthority(set);
return buildUserForAuthentication(user, authorities);
}
/**
*
* #param user Receiving user object
* #param authorities Receiving list of user authorities
* #return returning user object
*/
private User buildUserForAuthentication(final AdminUser user,
final List<GrantedAuthority> authorities) {
return new User(user.getEmail(), user.getPassword(), true,
true, true, true, authorities);
}
/**
*
* #param userRoles receiving
* #return Returning list of authorities
*/
private List<GrantedAuthority> buildUserAuthority(final
Set<String> userRoles) {
Set<GrantedAuthority> setAuths = new HashSet<GrantedAuthority>();
// Build user's authorities
for (String userRole : userRoles) {
setAuths.add(new SimpleGrantedAuthority(userRole));
}
List<GrantedAuthority> result = new
ArrayList<GrantedAuthority>(setAuths);
return result;
}
public final JPAAdminUserDao getJpaUserDao() {
return jpaUserDao;
}
public final void setAdminUserDao(final JPAAdminUserDao newJpaUserDao) {
this.jpaUserDao = newJpaUserDao;
}
}
If i comment next line
<beans:property name="entityManagerFactoryBean" ref="entityManagerFactoryBean"/>
in spring-security I will have java.lang.NullPointerException in JPAAdminUserDao class in method findUserByEmail
You seem to have problems while you are loading your spring xml beans configuration files. Your persistence-context.xml is probably never loaded.
Are you sure that this line is importing the persistence-context.xml file (Remove it if it is no longer necessary, it may load some context twice) :
<import resource="classpath*:**/spring/*context.xml" />
Try to add the persistence-context.xml in the context-param in your web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security.xml
**/path/to/persistence-context.xml
</param-value>
</context-param>
To ensure that your servlet-context.xml file is correctly loaded, add an init param to your DispatcherServlet declaration in your web.xml :
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/path/to/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
I am facing some issue while creating the bean it gives error.
Can someone please assist me. I will retrieve the files from sftp resource and will read those file with a spring task scheduler job.
App-Config.xml
<?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:task="http://www.springframework.org/schema/task"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/sftp
http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
<context:component-scan base-package="com.canaldigital.tsi.bank" />
<context:property-placeholder location="classpath:settings.properties" />
<task:scheduled-tasks scheduler="myScheduler">
<task:scheduled ref="myBean" method="printMessage" fixed-delay="600000" initial-delay="3000"/>
<task:scheduled ref="myBean" method="checkStatus" fixed-delay="6000" initial-delay="2000"/>
</task:scheduled-tasks>
<task:scheduler id="myScheduler" pool-size="10" />
<bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="defaultSftpSessionFactory" />
<property name="sessionCacheSize" value="10"/>
<property name="sessionWaitTimeout" value="1000"/>
</bean>
<bean id="defaultSftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="${sftp.host}"/>
<property name="username" value="${sftp.username}"/>
<property name="password" value="${sftp.password}"/>
<property name="port" value="${sftp.serverPort}"/>
<!-- <property name="privateKey" value="${sftp.private.keyfile}"/> -->
<!-- <property name="privateKeyPassphrase" value="${sftp.passphrase}"/> -->
</bean>
<int-sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
session-factory="sftpSessionFactory"
channel="requestChannel"
filename-pattern="*.csv"
remote-directory="/home/oracle/IBSTOBANK/DNB/Norway/Outgoing"
preserve-timestamp="true"
local-directory="file:target/foo"
auto-create-local-directory="true"
local-filename-generator-expression="#this.toUpperCase() + '.a'"
local-filter="myFilter"
temporary-file-suffix=".writing"
delete-remote-files="false">
<int:poller fixed-rate="1000"/>
</int-sftp:inbound-channel-adapter>
<int:channel id="requestChannel">
<int:queue/>
</int:channel>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}"/>
<property name="url" value="${db.url}"/>
<property name="username" value="${db.user}"/>
<property name="password" value="${db.password}"/>
</bean>
<!-- Defining a datasource -->
<!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<description>This is JNDI based Data Source.</description>
<property name="jndiName">
<value>jdbc/BIZLOGDS</value>
</property>
</bean> -->
<!-- Definition for JDBCTemplate bean -->
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="TransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
</beans>
StackTrace:
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler shutdown
INFO: Shutting down ExecutorService 'myScheduler'
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sftpSessionFactory' defined in class path resource [app-config.xml]: Cannot resolve reference to bean 'defaultSftpSessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultSftpSessionFactory' defined in class path resource [app-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'sftp' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:646)
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:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
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.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.canaldigital.tsi.bank.config.AppMain.main(AppMain.java:16)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultSftpSessionFactory' defined in class path resource [app-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'sftp' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
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:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
... 17 more
Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'sftp' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:146)
at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1362)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:214)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:186)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 23 more
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'sftp' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:215)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:78)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:48)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:103)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94)
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:143)
... 29 more
please visit DefaultSftpSessionFactory
it has following :
setUser
public void setUser(String user)
The remote user to use. This is a mandatory property.
Parameters:
user - The user.
See Also:
JSch.getSession(String, String, int)
I'm trying to convert my existing traditional spring application to a spring boot. I have imported my XML Configuration with #ImportResource and when I run my application. It throws Injection failed even though this bean is configured in XML Configuration. Not sure what's going wrong here
> Application.java
#Configuration
#ComponentScan("com.vzt")
#EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
public class Application {
public static void main(String[] args) {
ApplicationContext applicationContext = SpringApplication.run(
Application.class, args);
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = applicationContext.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
}
}
#Configuration
#ImportResource("classpath:spring/beans.xml")
// #Profile("itest2") //commented it from the suggestion to set the
spring.profiles.active=itest2 on VM arguments
class XMLImportingConfiguration {
}
>XML 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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:util="http://www.springframework.org/schema/util"
xmlns:c="http://www.springframework.org/schema/c" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="com.vzt" />
<!-- <oxm:jaxb2-marshaller id="marshaller" contextPath="com.vzt.ws.stubs.cca.ivrinfows"
/> -->
<!-- <jee:jndi-lookup id="ccaDataSource" jndi-name="java:/cca"
resource-ref="true" />
-->
<bean id="ccaDataSourceTest"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="${cca.jdbc.url}" />
<property name="username" value="${cca.jdbc.username}" />
<property name="password" value="${cca.jdbc.password}" />
</bean>
<bean id="ccaService" class="com.vzt.callcenter.service.CCAServiceImpl">
<!-- wire dependency -->
</bean>
<bean id="ccaRepository" class="com.vzt.callcenter.dao.CCARepository">
<property name="dataSource" ref="ccaDataSourceTest" />
</bean>
<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<!-- IVR Info WS Request and Response Classes -->
<value>com.vzt.ws.stubs.cca.ivrinfows.CallData</value>
<value>com.vzt.ws.stubs.cca.ivrinfows.GetCallData</value>
<value>com.vzt.ws.stubs.cca.ivrinfows.IvrTransfer</value>
<value>com.vzt.ws.stubs.cca.ivrinfows.IvrTransferred</value>
<!-- Weather Data WS Request and Response Classes -->
<value>com.vzt.ws.stubs.weather.Alert</value>
<value>com.vzt.ws.stubs.weather.DataSet</value>
<value>com.vzt.ws.stubs.weather.GetAll</value>
<value>com.vzt.ws.stubs.weather.GetAllResponse</value>
<value>com.vzt.ws.stubs.weather.Weather</value>
<!-- MW (ESB) Webservice SR Request and Response Classes -->
<value>com.hughestelematics.htimessageheader.MessageHeaderT</value>
<value>com.hughestelematics.xmlns.webservicesr.WebserviceSRRequest
</value>
<value>com.hughestelematics.xmlns.webservicesr.WebserviceSRReturn
</value>
<!-- Siebel Webservice updateSRType Request and Response Classes -->
<value>com.siebel.customui.UpdateSRTypeInput</value>
<value>com.siebel.customui.UpdateSRTypeOutput</value>
<!-- MW (BPEL) Webservice SR PSTN Request and Response Classes -->
<value>com.hti.xmlns.webservicepstn.ObjectFactory</value>
<value>com.hti.xmlns.webservicepstn.PSTNRequestT</value>
<value>com.hti.xmlns.webservicepstn.PSTNReturnT</value>
<value>com.hti.xmlns.webservicepstn.PSTNOutput</value>
</list>
</property>
</bean>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="marshaller" ref="jaxb2Marshaller" />
<property name="unmarshaller" ref="jaxb2Marshaller" />
<constructor-arg ref="messageFactory" />
<!-- <property name="defaultUri" value="${ccawebservice.url}" /> -->
<property name="messageSender">
<bean
class="org.springframework.ws.transport.http.HttpComponentsMessageSender">
<property name="connectionTimeout" value="${cca.ivrinfo.webservice.timeout}" />
<property name="readTimeout" value="${cca.ivrinfo.webservice.timeout}" />
<property name="acceptGzipEncoding" value="false" />
</bean>
</property>
</bean>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="messageFactory">
<bean
class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl" />
</property>
</bean>
<!-- <mvc:default-servlet-handler /> -->
<mvc:resources location="/resources/" mapping="/resources/**" />
<!-- <mvc:interceptors> <bean class = "com.vzt.nissan.interceptors.HttpRequestResponseLoggingInterceptor"/>
<bean class = "com.vzt.nissan.interceptors.AddSessionBeanInterceptor" />
</mvc:interceptors> -->
<context:annotation-config />
<mvc:annotation-driven />
<aop:aspectj-autoproxy />
<beans profile="dev">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:framework_dev.properties</value>
<value>classpath:data/testdata/testdata_dev.properties</value>
<value>classpath:db/db_dev.properties</value>
</list>
</property>
</bean>
</beans>
<beans profile="itest">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:framework_itest.properties</value>
<value>classpath:data/testdata/testdata_itest.properties</value>
<value>classpath:db/db_itest.properties</value>
</list>
</property>
</bean>
</beans>
<beans profile="itest2">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:framework_itest2.properties</value>
<value>classpath:data/testdata/testdata_itest2.properties</value>
<value>classpath:db/db_itest2.properties</value>
</list>
</property>
</bean>
</beans>
>CCAServiceImpl.java
package com.vzt.callcenter.service;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.soap.client.SoapFaultClientException;
import com.vzt.callcenter.constants.Constants;
import com.vzt.callcenter.model.GetCallDataByInteractionIdResponse;
import com.vzt.ws.stubs.cca.ivrinfows.CallData;
import com.vzt.ws.stubs.cca.ivrinfows.GetCallData;
import com.vzt.ws.stubs.cca.ivrinfows.IvrTransfer;
import com.vzt.ws.stubs.cca.ivrinfows.IvrTransferred;
import com.vzt.ws.stubs.cca.ivrinfows.ObjectFactory;
#Service
public class CCAServiceImpl implements CCAService {
#Autowired
private WebServiceTemplate webServiceTemplate;
static Logger logger = Logger.getLogger(CCAServiceImpl.class);
#Value("${cca.ivrinfo.webservice.url}")
private String webserviceUrl;
#Value("${cca.ivrinfo.webservice.timeout}")
private String webserviceTimeout;
public String getWebserviceUrl() {
return webserviceUrl;
}
public void setWebserviceUrl(String webserviceUrl) {
this.webserviceUrl = webserviceUrl;
}
public String getWebserviceTimeout() {
return webserviceTimeout;
}
public void setWebserviceTimeout(String webserviceTimeout) {
this.webserviceTimeout = webserviceTimeout;
}
/* (non-Javadoc)
* #see com.vzt.callcenter.service.CCAService#getCallDataByInteractionId(java.lang.String)
*/
#Override
public GetCallDataByInteractionIdResponse getCallDataByInteractionId(
String interactionId) {
//code not shown for brevity
return getCallDataByInteractionIdResponse;
}
/* (non-Javadoc)
* #see com.vzt.callcenter.service.CCAService#ivrTransfer(com.vzt.callcenter.model.IvrTransferRequest)
*/
#Override
public String ivrTransfer(com.vzt.callcenter.model.IvrTransferRequest ivrTransferRequest) {
logger.info("Request:" + ivrTransferRequest);
//code not shown for brevity
return Constants.WS_RC_CCAINFOWS_WSEXCEPTION;
}
}
>Error when I do the Spring Boot
>EDIT
Based on USER:axtavt comment, I made change to the
spring.active.profiles on run-time instead of using #Annotations. And
now I get the below error.
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#4260904e: startup date [Thu Dec 11 09:47:19 EST 2014]; root of context hierarchy
09:47:19 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext obtainFreshBeanFactory Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#4260904e: org.springframework.beans.factory.support.DefaultListableBeanFactory#4db8738f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,application]; root of factory hierarchy
09:47:20 INFO rg.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions Loading XML bean definitions from class path resource [spring/beans.xml]
09:47:21 INFO ngframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition Overriding bean definition for bean 'mvcContentNegotiationManager': replacing [Root bean: class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration; factoryMethodName=mvcContentNegotiationManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]]
09:47:21 INFO rk.context.annotation.ConfigurationClassBeanDefinitionReader iddenByExistingDefinition Skipping bean definition for [BeanMethod:name=mvcUriComponentsContributor,declaringClass=org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport]: a definition for bean 'mvcUriComponentsContributor' already exists. This top-level bean definition is considered as an override.
09:47:21 INFO ngframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
09:47:21 INFO framework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties Loading properties file from class path resource [framework_itest2.properties]
09:47:21 INFO framework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties Loading properties file from class path resource [data/testdata/testdata_itest2.properties]
09:47:21 INFO framework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties Loading properties file from class path resource [db/db_itest2.properties]
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
09:47:22 INFO t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$acc877c3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 INFO t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 INFO t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 INFO t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext initMessageSource Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource#773fe60f]
09:47:22 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext plicationEventMulticaster Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster#4191ff3]
09:47:22 DEBUG ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory etArchiveFileDocumentRoot Code archive: C:\Users\v579424\.m2\repository\org\springframework\boot\spring-boot\1.1.7.RELEASE\spring-boot-1.1.7.RELEASE.jar
09:47:22 DEBUG ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory plodedWarFileDocumentRoot Code archive: C:\Users\v579424\.m2\repository\org\springframework\boot\spring-boot\1.1.7.RELEASE\spring-boot-1.1.7.RELEASE.jar
09:47:22 DEBUG ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory getValidDocumentRoot Document root: C:\Users\v579424\Documents\workspace-sts-3.4.0.RELEASE\VZTCallCenterFramework\src\main\webapp
09:47:22 INFO ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory tEmbeddedServletContainer Server initialized with port: 8080
09:47:22 INFO org.springframework.web.context.ContextLoader ddedWebApplicationContext Root WebApplicationContext: initialization completed in 3087 ms
09:47:23 INFO pringframework.boot.context.embedded.ServletRegistrationBean onStartup Mapping servlet: 'dispatcherServlet' to [/]
09:47:23 INFO springframework.boot.context.embedded.FilterRegistrationBean configure Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
09:47:26 INFO org.springframework.oxm.jaxb.Jaxb2Marshaller ateJaxbContextFromClasses Creating JAXBContext with classes to be bound [class com.vzt.ws.stubs.cca.ivrinfows.CallData,class com.vzt.ws.stubs.cca.ivrinfows.GetCallData,class com.vzt.ws.stubs.cca.ivrinfows.IvrTransfer,class com.vzt.ws.stubs.cca.ivrinfows.IvrTransferred,class com.vzt.ws.stubs.weather.Alert,class com.vzt.ws.stubs.weather.DataSet,class com.vzt.ws.stubs.weather.GetAll,class com.vzt.ws.stubs.weather.GetAllResponse,class com.vzt.ws.stubs.weather.Weather,class com.hughestelematics.htimessageheader.MessageHeaderT,class com.hughestelematics.xmlns.webservicesr.WebserviceSRRequest,class com.hughestelematics.xmlns.webservicesr.WebserviceSRReturn,class com.siebel.customui.UpdateSRTypeInput,class com.siebel.customui.UpdateSRTypeOutput,class com.hti.xmlns.webservicepstn.ObjectFactory,class com.hti.xmlns.webservicepstn.PSTNRequestT,class com.hti.xmlns.webservicepstn.PSTNReturnT,class com.hti.xmlns.webservicepstn.PSTNOutput]
09:47:27 INFO org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName Loaded JDBC driver: oracle.jdbc.OracleDriver
09:47:27 INFO .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
09:47:27 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/service/customAgentRoute/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<com.vzt.callcenter.model.CustomRoute> com.vzt.callcenter.web.CustomAgentRouteController.customAgentRoutes()
09:47:27 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/service/customAgentRoute/{mdn}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.vzt.callcenter.model.CustomRoute com.vzt.callcenter.web.CustomAgentRouteController.getCustomRougeByMdn(java.lang.String)
09:47:27 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
09:47:27 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
09:47:28 INFO .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
09:47:28 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/service/customAgentRoute/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<com.vzt.callcenter.model.CustomRoute> com.vzt.callcenter.web.CustomAgentRouteController.customAgentRoutes()
09:47:28 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/service/customAgentRoute/{mdn}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.vzt.callcenter.model.CustomRoute com.vzt.callcenter.web.CustomAgentRouteController.getCustomRougeByMdn(java.lang.String)
09:47:28 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
09:47:28 INFO b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
09:47:28 INFO .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
09:47:28 INFO .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
09:47:28 INFO pringframework.jmx.export.annotation.AnnotationMBeanExporter afterPropertiesSet Registering beans for JMX exposure on startup
09:47:28 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext initLifecycleProcessor Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor#27b6c151]
09:47:28 DEBUG oconfigure.logging.AutoConfigurationReportLoggingInitializer ogAutoConfigurationReport
09:47:28 ERROR org.springframework.boot.SpringApplication run Application startup failed
java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:154)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:272)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at com.vzt.Application.main(Application.java:28)
09:47:28 INFO ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext doClose Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#4260904e: startup date [Thu Dec 11 09:47:19 EST 2014]; root of context hierarchy
09:47:28 INFO pringframework.jmx.export.annotation.AnnotationMBeanExporter destroy Unregistering JMX-exposed beans on shutdown
Exception in thread "main" java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:154)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:272)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at com.vzt.Application.main(Application.java:28)
**
Got it fixed by passing the spring.profiles.active=itest2 on VM arguments instead of setting it as an annotation shown below. Not sure, why spring-boot is not allowing to configure using annotation.
#Configuration
#ImportResource("classpath:spring/beans.xml")
#Profile("itest2")
class XMLImportingConfiguration {
}
Not able to figure out, what's wrong. I keep getting the same error again and again. I have searched Google but failed to solve this issue. I was looking the same post over here try to solve but still the same.
JobsDAOImp.java
public class JobsDAOImp implements JobsDAO {
#Autowired
private SessionFactory sessionFactory;
..
}
JobService.java
public interface JobsService {
....
}
JobServiceImp.java
#Service
#Transactional(readOnly=true)
public class JobsServiceImp implements JobsService {
#Autowired private JobsDAOImp jobsDAOImp;
..
}
JobsController.java
#Controller
#RequestMapping(value="/")
public class JobsController {
#Autowired
private JobsService jobsService;
...
}
spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<!-- DAO Implementations -->
<bean id="usersImp" class="org.delance.daoimplementation.UsersImp" />
<bean id="jobsDAOImp" class="org.delance.daoimplementation.JobsDAOImp" />
<!-- Service Implementations -->
<bean id="jobsServiceImp" class="org.delance.serviceimp.JobsServiceImp" />
<bean id="dataSource" class="${jdbc.dataSource}" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
<property name="user" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxStatements" value="${jdbc.maxStatements}"/>
<property name="acquireIncrement" value="${jdbc.acquireIncrement}" />
<property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}" />
<property name="checkoutTimeout" value="${jdbc.checkoutTimeout}" />
<property name="unreturnedConnectionTimeout" value="${jdbc.unreturnedConnectionTimeout}" />
<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
<property name="minPoolSize" value="${jdbc.minPoolSize}" />
<property name="automaticTestTable" value="${jdbc.automaticTestTable}" />
<property name="testConnectionOnCheckin" value="${jdbc.testConnectionOnCheckin}" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan">
<array>
<value>org.delance.models</value>
</array>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect = org.hibernate.dialect.MySQLDialect
hibernate.cache.provider_class = org.hibernate.cache.NoCacheProvider
hibernate.show_sql = true
hibernate.hbm2ddl.auto = create
</value>
</property>
</bean>
<context:property-placeholder location="application.properties" />
</beans>
mvc-dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="org.delance" />
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
<mvc:resources mapping="/**" location="/" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="cacheSeconds" value="0" />
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
getting this issue :-
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobsController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.delenace.service.JobsService org.delenace.controllers.JobsController.jobsService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.delenace.service.JobsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
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.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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.BeanCreationException: Could not autowire field: private org.delenace.service.JobsService org.delenace.controllers.JobsController.jobsService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.delenace.service.JobsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
... 26 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.delenace.service.JobsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
... 28 more
Feb 18, 2014 5:01:17 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 'jobsController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.delenace.service.JobsService org.delenace.controllers.JobsController.jobsService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.delenace.service.JobsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
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.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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.BeanCreationException: Could not autowire field: private org.delenace.service.JobsService org.delenace.controllers.JobsController.jobsService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.delenace.service.JobsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
... 26 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.delenace.service.JobsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
... 28 more
Use the interface instead of the implementation in the JobsController since spring generates a java proxy for the JobServiceImpl bean and java Proxies are based on interfaces.
#Autowired
private JobsService jobsService;
I don't see your whole project and what's the exact configuration, but it seems to me that you are loading only mvc-dispatcher-servlet.xml without spring.xml. In your case this is OK because you have defined
<context:component-scan base-package="org.delance" />
to scan for bean definitions. So assuming you have only the mvc-dispatcher-servlet.xml loaded, you should check that both of the controller and service are in a package that has this common base package "org.delance" or otherwise spring classpath scanning won't pick them up. Also you should get rid of the qualifier - this is in case you have two or more beans of given type.
Anyway I have had this kind of problems before and I am sure it will be something small.
Regarding tha fact you have 2 configurations (or also contexts) there's something more you have to consider. You shouldn't define one bean twice (once through package scanning and second time in the xml config), except when this is done intentionally. Having this said if you fix this first issue you'll have other problems when you load both of the contexts (spring.xml and mvc-dispatcher-servlet.xm)
You need make the jobService.java class to be bean specified. Add stereo type annotation to it like #Component.
if you use such definition:
<bean id="jobsServiceImp" class="org.delance.serviceimp.JobsServiceImp" />
you are not leveraging Spring Dependency Injection feature, since there is no difference between interface and implementing class; in Spring, you might want to use interfaces throughout the code and declare their implementations in the application context configuration (this is defined as separation of concerns); this is also useful in case you decide to change the implementation because you will just need to change the xml configuration.
Please try the following:
<bean id="jobsService" class="org.delance.serviceimp.JobsServiceImp" />
Salvatore