Spring Component Scan
keremyzc May 16, 2013 10:02 AMHi, I've been trying to get the spring component scanning working but getting the error below
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.DisposableBean not found by fuse-hello-service [108]
I've a very simple setup with a single bean class and a spring configuration class
@Configuration public class HelloSpringConf { @Bean public Hello getHello() { return new Hello(); } }
and a single line in the spring configuration file
<context:annotation-config/> <context:component-scan base-package="com.company.spring"/>
my dependencies as below
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.3.RELEASE</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>3.1.3.RELEASE</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.servicemix.bundles</groupId> <artifactId>org.apache.servicemix.bundles.cglib</artifactId> <version>2.2.2_1</version> </dependency> </dependencies>
and the full stacktrace;
2013-05-16 14:41:34,271 | ERROR | ExtenderThread-4 | WaiterApplicationContextExecutor | WaiterApplicationContextExecutor 424 | 74 - org.springframework.osgi.extender - 1.2.1 | Unable to create application context for [com.company.fuse-hello-service], unsatisfied dependencies: none java.lang.IllegalStateException: Cannot load configuration class: com.company.spring.HelloSpringConf at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:371)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:246)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:479)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:467)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:395)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:281)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:214)[74:org.springframework.osgi.extender:1.2.1] at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)[74:org.springframework.osgi.extender:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)[74:org.springframework.osgi.extender:1.2.1] at java.lang.Thread.run(Thread.java:662)[:1.6.0_39] Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method)[:1.6.0_39] at java.lang.Class.forName(Class.java:249)[:1.6.0_39] at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:386) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:149)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:108)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:361)[96:org.springframework.context:3.1.3.RELEASE] ... 12 more Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.DisposableBean not found by com.company.fuse-hello-service [108] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_39] at java.lang.Class.forName0(Native Method)[:1.6.0_39] at java.lang.Class.forName(Class.java:171)[:1.6.0_39] at com.company.spring.HelloSpringConf$$EnhancerByCGLIB$$f6a5a00.CGLIB$STATICHOOK4(<generated>)[108:com.company.fuse-hello-service:1.0.9.SNAPSHOT] at com.company.spring.HelloSpringConf$$EnhancerByCGLIB$$f6a5a00.<clinit>(<generated>)[108:com.company.fuse-hello-service:1.0.9.SNAPSHOT] ... 21 more 2013-05-16 14:41:34,273 | ERROR | ExtenderThread-4 | ContextLoaderListener | BundleApplicationContextListener 50 | 74 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=com.company.fuse-hello-service, config=osgibundle:/META-INF/spring/*.xml)) java.lang.IllegalStateException: Cannot load configuration class: com.company.spring.HelloSpringConf at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:371)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:246)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:479)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:467)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:395)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:281)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:214)[74:org.springframework.osgi.extender:1.2.1] at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)[74:org.springframework.osgi.extender:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)[99:org.springframework.osgi.core:1.2.1] at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)[74:org.springframework.osgi.extender:1.2.1] at java.lang.Thread.run(Thread.java:662)[:1.6.0_39] Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method)[:1.6.0_39] at java.lang.Class.forName(Class.java:249)[:1.6.0_39] at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:386) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:149)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:108)[96:org.springframework.context:3.1.3.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:361)[96:org.springframework.context:3.1.3.RELEASE] ... 12 more Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.DisposableBean not found by com.company.fuse-hello-service [108] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_39] at java.lang.Class.forName0(Native Method)[:1.6.0_39] at java.lang.Class.forName(Class.java:171)[:1.6.0_39] at com.company.spring.HelloSpringConf$$EnhancerByCGLIB$$f6a5a00.CGLIB$STATICHOOK4(<generated>)[108:com.company.fuse-hello-service:1.0.9.SNAPSHOT] at com.company.spring.HelloSpringConf$$EnhancerByCGLIB$$f6a5a00.<clinit>(<generated>)[108:com.company.fuse-hello-service:1.0.9.SNAPSHOT] ... 21 more
karaf@con1> osgi:headers 108 fuse-hello-service (108) ------------------------ Manifest-Version = 1.0 Bnd-LastModified = 1368711631782 Tool = Bnd-1.50.0 Built-By = yazicik Build-Jdk = 1.6.0_34 Created-By = Apache Maven Bundle Plugin Bundle-SybolicName = fuse-hello-service Bundle-Activator = com.company.osgi.Activator Bundle-Name = fuse-hello-service Bundle-SymbolicName = com.company.fuse-hello-service Bundle-Version = 1.0.9.SNAPSHOT Bundle-ManifestVersion = 2 Import-Package = org.osgi.framework;version="[1.7,2)", org.springframework.context.annotation;version="[3.1,4)" Export-Package = com.company;version=1.0.9.SNAPSHOT, com.company.osgi;uses:=org.osgi.framework;version=1.0.9.SNAPSHOT, com.company.spring;uses:="com.company,org.springframework.context.annotation";version=1.0.9.SNAPSHOT
profile
JBossFuse:karaf@root> profile-display --overlay calc-consumer Profile id: calc-consumer Version : 1.0 Attributes: parents: camel2 Containers: con1 Container settings ---------------------------- Repositories : mvn:org.fusesource.fabric/fuse-fabric/7.2.0.redhat-024/xml/features mvn:org.apache.karaf.assemblies.features/enterprise/2.3.0.redhat-60024/xml/features mvn:org.apache.camel.karaf/apache-camel/2.11.0/xml/features mvn:com.company/fuse-hello-features/1.0.9-SNAPSHOT/xml/features mvn:org.apache.karaf.assemblies.features/standard/2.3.0.redhat-60024/xml/features mvn:com.company/calculator-features/2.2.54-SNAPSHOT/xml/features Features : karaf camel-spring jolokia fuse-hello-service camel-core fabric-core fabric-camel camel-spring-javaconfig camel-jetty fabric-jaas fabric-agent camel-context Agent Properties : patch.repositories = http://repo.fusesource.com/nexus/content/repositories/releases, http://repo.fusesource.com/nexus/content/groups/ea obr.resolve.optional.imports = true org.ops4j.pax.url.mvn.defaultRepositories = file:${karaf.home}/${karaf.default.repository}@snapshots@id=karaf-default, file:${karaf.home}/local-repo@snapshots@id=karaf-local org.ops4j.pax.url.mvn.repositories = http://repo1.maven.org/maven2@id=central, http://repo.fusesource.com/nexus/content/groups/public@id=fusepublic, http://repo.fusesource.com/nexus/content/repositories/releases@id=fusereleases, http://repo.fusesource.com/nexus/content/groups/ea@id=fuseearlyaccess, http://repository.springsource.com/maven/bundles/release@id=ebrreleases, http://repository.springsource.com/maven/bundles/external@id=ebrexternal, http://scala-tools.org/repo-releases@id=scala, http://lonrs03296:8081/nexus/content/groups/phoenix@snapshots Configuration details ---------------------------- PID: org.ops4j.pax.url.mvn org.ops4j.pax.url.mvn.useFallbackRepositories false org.ops4j.pax.url.mvn.disableAether true org.ops4j.pax.url.mvn.repositories ${profile:org.fusesource.fabric.agent/org.ops4j.pax.url.mvn.repositories},file:${karaf.data}/maven/agent@snapshots@id=agent-local org.ops4j.pax.url.mvn.defaultRepositories ${profile:org.fusesource.fabric.agent/org.ops4j.pax.url.mvn.defaultRepositories} PID: org.fusesource.fabric.zookeeper zookeeper.password ${zk:/fabric/configs/ensemble/password} zookeeper.url ${zk:/fabric/configs/ensemble/url} PID: org.fusesource.fabric.jolokia jolokia.realm karaf jolokia.role admin
I've also have a simple integration test which works fine but couldn't get it working on the fuse fabric
I am using the latest jboss-fuse-6.0.0.redhat-024 and I've been trying to figure out what might be the problem for the last two days, any help is appreciated