|
|
@Autowired doesn't work with non-spring bean
I'm trying to upgrade my application from spring 2.5.6 to 3.0.2.RELEASE
In non-spring beans (annotated with @Configurable(preConstruction = true) ), @Autowired annotation doesn't work and objects are not injected.MyNonSpringBean.java
Code:
@Configurable(preConstruction = true)
public class MyNonSpringBean {
@Autowired
private transient MyService myService;
...}Istantiating an object in this way:Code:
MyNonSpringBean myNonSpringBean = new MyNonSpringBean();
myService is not injected. With Spring 2.5.6 it was.
I suspect some issues on apectJ configuration, but I can't figure out where I am wrong. I post my configuration. Can anyone help me?
Thank you, Francesco
applicationContext.xmlCode:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;beans xmlns=quot;schema/beansquot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xmlns:context=quot;schema/contextquot;
xsi:schemaLocation=quot;schema/beans schema/beans/spring-beans-3.0.xsd
schema/context schema/context/spring-context-3.0.xsdquot;gt;
lt;context:property-placeholder location=quot;classpath*:*.propertiesquot; /gt;
lt;context:spring-configured /gt;
lt;context:annotation-config/gt;
lt;context:component-scan base-package=quot;com.vaadin.incubator.springquot; /gt;
lt;bean class=quot;org..beans.factory.annotation.AutowiredAnnotationBeanPostProcessorquot; /gt;
lt;bean class=quot;org..context.annotation.CommonAnnotationBeanPostProcessorquot; /gt;lt;bean class=quot;org..jdbc.datasource.DriverManagerDataSourcequot; id=quot;dataSourcequot;gt;
lt;property name=quot;driverClassNamequot; value=quot;${database.driverClassName}quot; /gt;
lt;property name=quot;uclquot; value=quot;${database.ucl}quot; /gt;
lt;property name=quot;usernamequot; value=quot;${database.username}quot; /gt;
lt;property name=quot;passwordquot; value=quot;${database.password}quot; /gt;
lt;/beangt;
lt;bean class=quot;org..jdbc.datasource.DriverManagerDataSourcequot; id=quot;securityDataSourcequot;gt;
lt;property name=quot;driverClassNamequot; value=quot;${database.driverClassName}quot; /gt;
lt;property name=quot;uclquot; value=quot;${database.ucl}quot; /gt;
lt;property name=quot;usernamequot; value=quot;${database.username}quot; /gt;
lt;property name=quot;passwordquot; value=quot;${database.password}quot; /gt;
lt;/beangt;lt;bean class=quot;org..orm.jpa.LocalContainerEntityManagerFactoryBeanquot; id=quot;entityManagerFactoryquot;gt;
lt;property name=quot;dataSourcequot; ref=quot;dataSourcequot; /gt;
lt;property name=quot;jpaVendorAdapterquot;gt;
lt;bean id=quot;jpaAdapterquot; class=quot;org..orm.jpa.vendor.HibernateJpaVendorAdapterquot;gt;
lt;property name=quot;generateDdlquot; value=quot;truequot; /gt;
lt;property name=quot;showSqlquot; value=quot;truequot; /gt;
lt;/beangt;
lt;/propertygt;
lt;/beangt;lt;bean id=quot;transactionManagerquot; class=quot;org..orm.jpa.JpaTransactionManagerquot;gt;
lt;property name=quot;entityManagerFactoryquot; ref=quot;entityManagerFactoryquot; /gt;
lt;/beangt;lt;bean id=quot;messageSourcequot; class=quot;org..context.support.ResourceBundleMessageSourcequot;gt;
lt;property name=quot;basenamequot; value=quot;fooMessagesquot; /gt;
lt;/beangt;
lt;bean id=quot;localeResolverquot; class=quot;org..web.servlet.i18n.SessionLocaleResolverquot;gt;
lt;property name=quot;defaultLocalequot; value=quot;it_ITquot; /gt;
lt;/beangt;
lt;bean class=quot;com.vaadin.incubator.spring.util.VaadinApplicationObjectSupportquot;/gt;
lt;/beansgt;extract of pom.xmlCode:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;project xmlns=quot OM/4.0.0quot; xmlns:xsi=quot;2001/XMLSchema-instancequot;
xsi:schemaLocation=quot OM/4.0.0 maven-v4_0_0.xsdquot;gt;
lt;modelVersiongt;4.0.0lt;/modelVersiongt;
lt;groupIdgt;com.vaadin.incubator.springlt;/groupIdgt;
lt;artifactIdgt;TrasferteVaadinlt;/artifactIdgt;
lt;packaginggt;warlt;/packaginggt;
lt;versiongt;0.0.1-SNAPSHOTlt;/versiongt;
lt;namegt;SpringApplicationlt;/namegt;lt;propertiesgt;
lt;java-versiongt;1.6lt;/java-versiongt;
lt;org.-versiongt;3.0.2.RELEASElt;/org.-versiongt;
lt;org..security-versiongt;3.0.2.RELEASElt;/org..security-versiongt;
lt;org.aspectj-versiongt;1.6.8lt;/org.aspectj-versiongt;
lt;org.slf4j-versiongt;1.5.10lt;/org.slf4j-versiongt;
lt;/propertiesgt;
lt;dependenciesgt;
lt;!-- Spring --gt;
lt;dependencygt;
lt;groupIdgt;org.lt;/groupIdgt;
lt;artifactIdgt;spring-contextlt;/artifactIdgt;
lt;versiongt;${org.-version}lt;/versiongt;
lt;exclusionsgt;
lt;!-- Exclude Commons Logging in favor of SLF4j --gt;
lt;exclusiongt;
lt;groupIdgt;commons-logginglt;/groupIdgt;
lt;artifactIdgt;commons-logginglt;/artifactIdgt;lt;/exclusiongt;
lt;/exclusionsgt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org.lt;/groupIdgt;
lt;artifactIdgt;spring-jdbclt;/artifactIdgt;
lt;versiongt;${org.-version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org.lt;/groupIdgt;
lt;artifactIdgt;spring-ormlt;/artifactIdgt;
lt;versiongt;${org.-version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org.lt;/groupIdgt;
lt;artifactIdgt;spring-webmvclt;/artifactIdgt;
lt;versiongt;${org.-version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org..securitylt;/groupIdgt;
lt;artifactIdgt;spring-security-weblt;/artifactIdgt;
lt;versiongt;${org..security-version}lt;/versiongt;
lt;exclusionsgt;
lt;!-- Exclude Commons Logging in favor of SLF4j --gt;
lt;exclusiongt;
lt;groupIdgt;commons-logginglt;/groupIdgt;
lt;artifactIdgt;commons-logginglt;/artifactIdgt;lt;/exclusiongt;
lt;/exclusionsgt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org..securitylt;/groupIdgt;
lt;artifactIdgt;spring-security-taglibslt;/artifactIdgt;
lt;versiongt;${org..security-version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org..securitylt;/groupIdgt;
lt;artifactIdgt;spring-security-configlt;/artifactIdgt;
lt;versiongt;${org..security-version}lt;/versiongt;
lt;exclusionsgt;
lt;!-- Exclude Commons Logging in favor of SLF4j --gt;
lt;exclusiongt;
lt;groupIdgt;commons-logginglt;/groupIdgt;
lt;artifactIdgt;commons-logginglt;/artifactIdgt;lt;/exclusiongt;
lt;/exclusionsgt; lt;/dependencygt;
lt;!-- AspectJ --gt;
lt;dependencygt;
lt;groupIdgt;org.aspectjlt;/groupIdgt;
lt;artifactIdgt;aspectjrtlt;/artifactIdgt;
lt;versiongt;${org.aspectj-version}lt;/versiongt;
lt;/dependencygt;
lt;!-- @Inject --gt;
lt;dependencygt;
lt;groupIdgt;javax.injectlt;/groupIdgt;
lt;artifactIdgt;javax.injectlt;/artifactIdgt;
lt;versiongt;1lt;/versiongt;
lt;/dependencygt;
lt;!-- Servlet --gt;
lt;dependencygt;
lt;groupIdgt;javax.servletlt;/groupIdgt;
lt;artifactIdgt;servlet-apilt;/artifactIdgt;
lt;versiongt;2.5lt;/versiongt;
lt;scopegt;providedlt;/scopegt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;javax.servlet.jsplt;/groupIdgt;
lt;artifactIdgt;jsp-apilt;/artifactIdgt;
lt;versiongt;2.1lt;/versiongt;
lt;scopegt;providedlt;/scopegt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;javax.servletlt;/groupIdgt;
lt;artifactIdgt;jstllt;/artifactIdgt;
lt;versiongt;1.2lt;/versiongt;
lt;/dependencygt;lt;!-- Hibernate JPA 2 Provider --gt;
lt;dependencygt;
lt;groupIdgt;org.hibernatelt;/groupIdgt;
lt;artifactIdgt;hibernate-entitymanagerlt;/artifactIdgt;
lt;versiongt;3.5.0-Finallt;/versiongt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org.hibernatelt;/groupIdgt;
lt;artifactIdgt;hibernate-validatorlt;/artifactIdgt;
lt;versiongt;4.0.2.GAlt;/versiongt;
lt;/dependencygt;
lt;dependencygt; lt;groupIdgt;org.lt;/groupIdgt; lt;artifactIdgt;spring-aspectslt;/artifactIdgt; lt;versiongt;2.5.6lt;/versiongt;
lt;/dependencygt;
lt;/dependenciesgt;
lt;buildgt;
lt;pluginsgt;
lt;plugingt;
lt;groupIdgt;org.apache.maven.pluginslt;/groupIdgt;
lt;artifactIdgt;maven-compiler-pluginlt;/artifactIdgt;
lt;configurationgt;
lt;sourcegt;${java-version}lt;/sourcegt;
lt;targetgt;${java-version}lt;/targetgt;
lt;/configurationgt;
lt;/plugingt;
lt;plugingt;
lt;groupIdgt;org.codehaus.mojolt;/groupIdgt;
lt;artifactIdgt;aspectj-maven-pluginlt;/artifactIdgt;
lt;!-- Have to use version 1.2 since version 1.3 does not appear to work with ITDs --gt;
lt;versiongt;1.2lt;/versiongt;
lt;dependenciesgt;
lt;!-- You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) --gt;
lt;dependencygt;
lt;groupIdgt;org.aspectjlt;/groupIdgt;
lt;artifactIdgt;aspectjrtlt;/artifactIdgt;
lt;versiongt;${org.aspectj-version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;
lt;groupIdgt;org.aspectjlt;/groupIdgt;
lt;artifactIdgt;aspectjtoolslt;/artifactIdgt;
lt;versiongt;${org.aspectj-version}lt;/versiongt;
lt;/dependencygt;
lt;/dependenciesgt;
lt;executionsgt;
lt;executiongt;
lt;goalsgt;
lt;goalgt;compilelt;/goalgt;
lt;goalgt;test-compilelt;/goalgt;
lt;/goalsgt;
lt;/executiongt;
lt;/executionsgt;
lt;configurationgt;
lt;outxmlgt;truelt;/outxmlgt;
lt;sourcegt;${java-version}lt;/sourcegt;
lt;targetgt;${java-version}lt;/targetgt;
lt;/configurationgt;
lt;/plugingt;
lt;/pluginsgt;
lt;/buildgt;
lt;profilesgt;
lt;profilegt;
lt;idgt;jetty6xlt;/idgt;
lt;buildgt;
lt;pluginsgt;
lt;plugingt;
lt;artifactIdgt;tc-maven-pluginlt;/artifactIdgt;
lt;versiongt;1.4.0lt;/versiongt;
lt;groupIdgt;org.terracotta.maven.pluginslt;/groupIdgt;
lt;configurationgt;
lt;processesgt;
lt;process nodeName=quot;cargoquot; count=quot;2quot;gt;
lt;containergt;
lt;containerIdgt;jetty6xlt;/containerIdgt;
lt;zipuclInstallergt;
lt;uclgt;file--/${basedir}/src/main/jetty/jetty-6.1.15.ziplt;/uclgt;
lt;installDirgt;target/installslt;/installDirgt;
lt;/zipuclInstallergt;
lt;/containergt;
lt;configurationgt;
lt;deployablesgt;
lt;deployablegt;
lt;propertiesgt;
lt;contextgt;/${pom.artifactId}lt;/contextgt;
lt;/propertiesgt;
lt;/deployablegt;
lt;/deployablesgt;
lt;/configurationgt;
lt;/processgt;
lt;/processesgt;
lt;/configurationgt;
lt;/plugingt;
lt;/pluginsgt;
lt;/buildgt;
lt;/profilegt;
lt;/profilesgt;
lt;/projectgt; |
|