java - Exception when using @Scheduled spring annotation (Cannot find class [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]) -
i have created scheduled job using @scheduled
annotation. looks this:
package example.tools.rr; public class requestprocessorjob { private requestservice requestservice; ... @scheduled(fixedrate = 10000) public void process() { ... } public requestservice getrequestservice() { return requestservice; } public void setrequestservice(requestservice requestservice) { this.requestservice = requestservice; } }
i've put inside bundle a, can use class in other bundles. imported inside bundle b. b's blueprint.xml looks this:
<?xml version="1.0" encoding="utf-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:cm="http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium" xmlns:ctx="http://www.springframework.org/schema/context" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" xsi:schemalocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium/gemini-blueprint-compendium.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd "> ... <bean id="handsetservice" class="example.handset.impl.handsetserviceimpl"> ... </bean> <task:scheduler id="taskscheduler" /> <task:executor id="taskexecutor" pool-size="1" /> <task:annotation-driven executor="taskexecutor" scheduler="taskscheduler" /> <bean class="example.tools.rr.requestprocessorjob"> <cm:managed-properties persistent-id="example.handset.processing" autowire-on-update="true" /> <property name="requestservice" ref="handsetservice" /> </bean> </blueprint>
when install bundle (inside apache felix) following exception thrown:
unable create application context [example.handset], unsatisfied dependencies: none org.springframework.beans.factory.cannotloadbeanclassexception: cannot find class [org.springframework.scheduling.annotation.asyncannotationbeanpostprocessor] bean name 'org.springframework.context.annotation.internalasyncannotationprocessor' defined in null; nested exception java.lang.classnotfoundexception: org.springframework.scheduling.annotation.asyncannotationbeanpostprocessor not found bundle [example.handset] @ org.springframework.beans.factory.support.abstractbeanfactory.resolvebeanclass(abstractbeanfactory.java:1262) ~[na:na] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.predictbeantype(abstractautowirecapablebeanfactory.java:576) ~[na:na] @ org.springframework.beans.factory.support.abstractbeanfactory.isfactorybean(abstractbeanfactory.java:1331) ~[na:na] @ org.springframework.beans.factory.support.abstractbeanfactory.isfactorybean(abstractbeanfactory.java:897) ~[na:na] @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:566) ~[na:na] @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:913) ~[na:na] @ org.eclipse.gemini.blueprint.context.support.abstractdelegatedexecutionapplicationcontext.access$1600(abstractdelegatedexecutionapplicationcontext.java:60) ~[na:na] @ org.eclipse.gemini.blueprint.context.support.abstractdelegatedexecutionapplicationcontext$4.run(abstractdelegatedexecutionapplicationcontext.java:325) ~[na:na] @ org.eclipse.gemini.blueprint.util.internal.privilegedutils.executewithcustomtccl(privilegedutils.java:85) ~[na:na] @ org.eclipse.gemini.blueprint.context.support.abstractdelegatedexecutionapplicationcontext.completerefresh(abstractdelegatedexecutionapplicationcontext.java:290) ~[na:na] @ org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.dependencywaiterapplicationcontextexecutor$completerefreshtask.run(dependencywaiterapplicationcontextexecutor.java:137) ~[na:na] @ java.lang.thread.run(unknown source) [na:1.7.0_67] caused by: java.lang.classnotfoundexception: org.springframework.scheduling.annotation.asyncannotationbeanpostprocessor not found bundle [example.handset] @ org.eclipse.gemini.blueprint.util.bundledelegatingclassloader.findclass(bundledelegatingclassloader.java:101) ~[na:na] @ org.eclipse.gemini.blueprint.util.bundledelegatingclassloader.loadclass(bundledelegatingclassloader.java:155) ~[na:na] @ java.lang.classloader.loadclass(unknown source) ~[na:1.7.0_67] @ org.springframework.util.classutils.forname(classutils.java:257) ~[na:na] @ org.springframework.beans.factory.support.abstractbeandefinition.resolvebeanclass(abstractbeandefinition.java:417) ~[na:na] @ org.springframework.beans.factory.support.abstractbeanfactory.doresolvebeanclass(abstractbeanfactory.java:1283) ~[na:na] @ org.springframework.beans.factory.support.abstractbeanfactory.resolvebeanclass(abstractbeanfactory.java:1254) ~[na:na] ... 11 common frames omitted caused by: java.lang.classnotfoundexception: org.springframework.scheduling.annotation.asyncannotationbeanpostprocessor not found example.handset [443] @ org.apache.felix.framework.bundlewiringimpl.findclassorresourcebydelegation(bundlewiringimpl.java:1499) ~[felix.jar:na] @ org.apache.felix.framework.bundlewiringimpl.access$400(bundlewiringimpl.java:75) ~[felix.jar:na] @ org.apache.felix.framework.bundlewiringimpl$bundleclassloader.loadclass(bundlewiringimpl.java:1882) ~[felix.jar:na] @ java.lang.classloader.loadclass(unknown source) ~[na:1.7.0_67] @ org.apache.felix.framework.felix.loadbundleclass(felix.java:1793) ~[felix.jar:na] @ org.apache.felix.framework.bundleimpl.loadclass(bundleimpl.java:929) ~[felix.jar:na] @ org.eclipse.gemini.blueprint.util.bundledelegatingclassloader.findclass(bundledelegatingclassloader.java:97) ~[na:na] ... 17 common frames omitted
if add empty class has @scheduled
annotation inside bundle b, works fine , requestprocessorjob scheduled (the empty class not used, makes error not occur).
public class mockjob { @scheduled(fixedrate = 10000) public void process() { } }
i've tried include module inside of b in pom.xml
<scope>provided</scope>
<scope>compile</scope>
, result same.
having reduntant class make work doesn't sounds solution. have ideas this? bug, or maybe somehow supposed work strangely?
ok, missing org.springframework.scheduling.annotation in <import-package> section in pom.xml. quite obvious after all, behaviour of spring still weird here.
Comments
Post a Comment