Results 1 to 4 of 4

Thread: My bundle can't find its own source code when building beans

  1. #1
    Join Date
    Jun 2009
    Posts
    16

    Default My bundle can't find its own source code when building beans

    I have an application that consists of a dozen or so bundles at present. When I try running it, one of the bundles, when Spring DM tries creating the beans defined in my XML, throws class not found exceptions, despite the fact that the class it can't find is in its own bundle. I'll include the stacktrace in hte first reply, as it is long.

    I'm developing in Eclipse, and did have an issue where Eclipse, after treating my bundle as any other for a while, suddenly decided it wasn't a bundle and refused to build it because it wouldn't use the Plug-In Dependencies container to provision imports from other bundles, but that is finally fixed.

    Still, when I try to start this bundle in Equinox, I get an exception. While the exception itself seems to give no clue which bundle is throwing it, the only currently installed bundle that uses the missing class is the bundle trying to instantiate it.

    I checked my bin directory and all of my code has been properly compiled there. I'll include my META-INF/spring/*.xml files below. Note if I comment out the osgi:service for featureManager I get the same stack trace, but missing FeatureManagerImpl instead of FeatureManager.

    Thanks,
    Mike

    My bundle-context-osgi.xml:
    HTML Code:
    <?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:osgi="http://www.springframework.org/schema/osgi"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                          http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
    
     		<osgi:service ref="featureManager" 
    			interface="mike.test.feature.manager.FeatureManager">
    		</osgi:service>
    
    
    	 	<osgi:reference id="hibernateManager" 
    			interface="mike.test.hibernatemgr.HibernateManager">
    		</osgi:reference>
    		
    </beans>
    My bundle-context.xml:
    HTML Code:
    <?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:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <bean id="featureManager" class="mike.test.feature.manager.impl.FeatureManagerImpl">
    		<property name="hibernateManager" ref="hibernateManager"/>
    	</bean>
    
    <!--
     	<bean id="eventGenerator" class="mike.test.feature.manager.impl.EventGenerator" init-method="init" destroy-method="stop">
    		<property name="featureManager" ref="featureManager"/> 
    		<property name="eventManager" ref="eventManager"/>
    	</bean>
    -->
    	<bean id="bundleTracker" class="mike.test.feature.manager.impl.BundleTracker" init-method="init" destroy-method="stop">
    		<property name="bundleContext" ref="bundleContext"/>
    		<property name="featureManager" ref="featureManager"/>
    	</bean>
    
    </beans>

  2. #2
    Join Date
    Jun 2009
    Posts
    16

    Default the stacktrace:

    And my stacktrace:

    2009-08-19 18:22:22,946; ERROR [SpringOsgiExtenderThread-14] OsgiBundleXmlApplicationContext: Post refresh error
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.osgi.service.exporter.support .OsgiServiceFactoryBean#0': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class[]] for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [mike.test.feature.manager.FeatureManager]
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.completeRefres h(AbstractDelegatedExecutionApplicationContext.jav a:288)
    at org.springframework.osgi.extender.internal.depende ncies.startup.DependencyWaiterApplicationContextEx ecutor$CompleteRefreshTask.run(DependencyWaiterApp licationContextExecutor.java:145)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class[]] for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [mike.test.feature.manager.FeatureManager]
    at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:391)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.convertForProperty(Abst ractAutowireCapableBeanFactory.java:1289)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1250)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    ... 13 more
    Caused by: java.lang.IllegalArgumentException: Cannot find class [mike.test.feature.manager.FeatureManager]
    at org.springframework.util.ClassUtils.resolveClassNa me(ClassUtils.java:233)
    at org.springframework.beans.propertyeditors.ClassArr ayEditor.setAsText(ClassArrayEditor.java:66)
    at org.springframework.beans.TypeConverterDelegate.do ConvertTextValue(TypeConverterDelegate.java:382)
    at org.springframework.beans.TypeConverterDelegate.do ConvertValue(TypeConverterDelegate.java:358)
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:173)
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:138)
    at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:386)
    ... 17 more
    Caused by: java.lang.ClassNotFoundException: mike.test.feature.manager.FeatureManager not found from bundle [mike.test.feature.manager]
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :103)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.loadClass(BundleDelegatingClassLoader.java :156)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:211)
    at org.springframework.util.ClassUtils.resolveClassNa me(ClassUtils.java:230)
    ... 23 more
    Caused by: java.lang.ClassNotFoundException: mike.test.feature.manager.FeatureManager
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClassInternal(BundleLoader.java:481)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:397)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:385)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.loadClass(DefaultClassLoader.java:87)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.loadClass(BundleLoader.java:313)
    at org.eclipse.osgi.framework.internal.core.BundleHos t.loadClass(BundleHost.java:227)
    at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadClass(AbstractBundle.java:1274)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :99)
    ... 27 more
    Exception in thread "SpringOsgiExtenderThread-14" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.osgi.service.exporter.support .OsgiServiceFactoryBean#0': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class[]] for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [mike.test.feature.manager.FeatureManager]
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.completeRefres h(AbstractDelegatedExecutionApplicationContext.jav a:288)
    at org.springframework.osgi.extender.internal.depende ncies.startup.DependencyWaiterApplicationContextEx ecutor$CompleteRefreshTask.run(DependencyWaiterApp licationContextExecutor.java:145)
    at java.lang.Thread.run(Thread.java:619)

  3. #3
    Join Date
    Jun 2009
    Posts
    16

    Default Stacktrace part 2

    Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class[]] for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [mike.test.feature.manager.FeatureManager]
    at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:391)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.convertForProperty(Abst ractAutowireCapableBeanFactory.java:1289)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1250)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    ... 13 more
    Caused by: java.lang.IllegalArgumentException: Cannot find class [mike.test.feature.manager.FeatureManager]
    at org.springframework.util.ClassUtils.resolveClassNa me(ClassUtils.java:233)
    at org.springframework.beans.propertyeditors.ClassArr ayEditor.setAsText(ClassArrayEditor.java:66)
    at org.springframework.beans.TypeConverterDelegate.do ConvertTextValue(TypeConverterDelegate.java:382)
    at org.springframework.beans.TypeConverterDelegate.do ConvertValue(TypeConverterDelegate.java:358)
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:173)
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:138)
    at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:386)
    ... 17 more
    Caused by: java.lang.ClassNotFoundException: mike.test.feature.manager.FeatureManager not found from bundle [mike.test.feature.manager]
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :103)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.loadClass(BundleDelegatingClassLoader.java :156)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:211)
    at org.springframework.util.ClassUtils.resolveClassNa me(ClassUtils.java:230)
    ... 23 more
    Caused by: java.lang.ClassNotFoundException: mike.test.feature.manager.FeatureManager
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClassInternal(BundleLoader.java:481)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:397)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:385)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.loadClass(DefaultClassLoader.java:87)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.loadClass(BundleLoader.java:313)
    at org.eclipse.osgi.framework.internal.core.BundleHos t.loadClass(BundleHost.java:227)
    at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadClass(AbstractBundle.java:1274)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :99)
    ... 27 more

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    From the stracktrace, the problem clearly seems to be that the FeatureManager is not found. Since you mentioned Eclipse PDE, I would suggest to get a hold of the generated bundle, see what exactly it contain and what packages it imports/exports.
    My guess would be that for whatever reason, either the bundle doesn't contain the class you mentioned or that it expects to find it somewhere else.
    Note that the bundle classpath might be different, meaning the class might be there (potentially packed) but in different location then the one used by the bundle to load its classes.

    Hope this helps,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •