Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » interface org.springframework.aop.SpringProxy is not visible from class loader(Receive "interface org.springframework.aop.SpringProxy is not visible from class loader" when wiring an osgi:reference)
interface org.springframework.aop.SpringProxy is not visible from class loader [message #724213] Sun, 11 September 2011 13:25 Go to next message
Branden Visser is currently offline Branden VisserFriend
Messages: 5
Registered: September 2011
Junior Member
Hi Everyone,

I'm converting a couple spring projects to run in an OSGi container and decided to use Eclipse Gemini, what a great tool!

I've run into a problem though, which maybe has to do with using annotation-driven transactions. Here is the stack-trace:

10.09.2011 23:36:27.704 *ERROR* [EclipseGeminiBlueprintExtenderThread-4] org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=com.filterengine.client, config=osgibundle:/META-INF/spring/*.xml)) org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.filterengine.entity.api.EntityDao' defined in URL [bundle://106.0:0/META-INF/spring/dao-context.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: interface org.springframework.aop.SpringProxy is not visible from class loader
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: interface org.springframework.aop.SpringProxy is not visible from class loader
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:117)
	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	... 13 more
10.09.2011 23:36:27.706 *INFO* [EclipseGeminiBlueprintExtenderThread-4] org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext Application Context service already unpublished
10.09.2011 23:36:27.706 *INFO* [EclipseGeminiBlueprintExtenderThread-4] org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener Application context succesfully closed (OsgiBundleXmlApplicationContext(bundle=com.filterengine.client, config=osgibundle:/META-INF/spring/*.xml))
10.09.2011 23:36:27.706 *ERROR* [EclipseGeminiBlueprintExtenderThread-4] org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor Unable to create application context for [com.filterengine.client], unsatisfied dependencies: none org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.filterengine.entity.api.EntityDao' defined in URL [bundle://106.0:0/META-INF/spring/dao-context.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: interface org.springframework.aop.SpringProxy is not visible from class loader
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: interface org.springframework.aop.SpringProxy is not visible from class loader
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:117)
	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	... 13 more


This is how I declare my transaction support:

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
	<property name="dataSource" ref="javax.sql.DataSource" />
</bean>

<tx:annotation-driven transaction-manager="txManager"/>


This is how my bean is created:

	<bean 	id="com.filterengine.entity.api.EntityDao"
		class="com.filterengine.entity.impl.SpringJdbcEntityDaoImpl"
		init-method="init">
			
		<property name="dataSource" ref="javax.sql.DataSource" />
		<property name="sqlManager" ref="com.filterengine.sql.SqlManager" />
		<property name="ddlService" ref="ca.mrvisser.dynamicdb.api.DdlService" />
		<property name="ddbSupport" ref="com.filterengine.data.impl.DynamicDBSupport" />
	</bean>


And finally, in the EntityDao bean, the "ddlService" property is actually an external service registered in the context:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans ...>

    <reference id="ca.mrvisser.dynamicdb.api.DdlService" interface="ca.mrvisser.dynamicdb.api.DdlService" availability="mandatory"/>
    <reference id="ca.mrvisser.dynamicdb.api.DmlService" interface="ca.mrvisser.dynamicdb.api.DmlService" availability="mandatory"/>

</beans:beans>


I do have another bundle (the "dynamicdb" bundle that this one references) that starts up using transaction annotations without any trouble, however this one is having problems, which is maybe due to trying to inject service references?

Also, Spring AOP is installed in my OSGi container, but when I install this bundle, it doesn't appear to import those packages -- not sure if that is the problem..

Have I done something wrong here? Any help is greatly appreciated!

Thanks,
Branden

[Updated on: Sun, 11 September 2011 13:28]

Report message to a moderator

Re: interface org.springframework.aop.SpringProxy is not visible from class loader [message #729263 is a reply to message #724213] Sun, 25 September 2011 16:44 Go to previous messageGo to next message
Branden Visser is currently offline Branden VisserFriend
Messages: 5
Registered: September 2011
Junior Member
Does anyone have any advice (pun intended) regarding this error? I did notice that it is the blueprint extender bundle that claims to need AOP, however when I look at the imported dependencies of that bundle in my OSGi container, it doesn't seem to want to import any. Also, I found some Spring-DM documentation that suggests spring-aop is a required dependency. I do have spring-aop installed in my container, but the bluepring extender isn't trying to import them.

Could this be the problem?
Re: interface org.springframework.aop.SpringProxy is not visible from class loader [message #729278 is a reply to message #729263] Sun, 25 September 2011 18:01 Go to previous message
Branden Visser is currently offline Branden VisserFriend
Messages: 5
Registered: September 2011
Junior Member
Ok, so I think I've solved this.

The problem seems to be that the manifest generator isn't including some of the indirect dependencies. In this case org.springframework.aop, org.springframework.aop.framework and org.aopalliance.aop. I couldn't seem to get blueprint to generate the import for any of those unless I created a fake bean in my application context that instantiates a class from those packages. Example being:

<bean id="proxy" class="org.springframework.aop.SpringProxy" />


Then this leads to other obvious problems. Trying to set the scope of the maven dependency to "runtime" didn't seem to have any impact either.

What I ended up doing was copying the list of imports generated by blueprint, and sticking them in the maven-bundle-plugin Import-Package definition, then add the ones that blueprint refused to generate. Example:

			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<extensions>true</extensions>
				<version>2.0.1</version>
				<configuration>
					<instructions>
						<Import-Package>
							...
							org.aopalliance.aop,
							org.springframework.aop,
							org.springframework.aop.framework,
							...
						</Import-Package>
					</instructions>
				</configuration>
			</plugin>


Where "..." is replaced by whatever other imports blueprint had generated. Adding these 3 was a trial an error process. Add one, then deploy and check for the next error. Add another, then deploy and check for the next error.

So, maybe there is room to improve blueprint's abilities to detect runtime dependencies, or possibly a way for a user to add additional ones (e.g., blueprint could detect user-added Import-Package entries in the MANIFEST, and could gracefully merge).

Hope this helps someone!

Branden
Previous Topic:Tomcat server embedded in OSGI responds only to http://localhost:8080
Next Topic:Gemini DBAccess for MySQL
Goto Forum:
  


Current Time: Mon Dec 22 12:51:20 GMT 2014

Powered by FUDForum. Page generated in 0.02118 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software