Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader"
Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1288459] Tue, 08 April 2014 15:29 Go to next message
Randy Cuaycong is currently offline Randy CuaycongFriend
Messages: 4
Registered: April 2014
Junior Member
We are currently updating from 3.5.0.M03 to 3.6.2.RELEASE version of virgo. AspectJ weaver and spring framework have been updated to 1.7.1 and 3.2.2 respectively using the instructions in the FAQ (http://wiki.eclipse.org/Virgo/FAQ#How_can_I_change_the_version_of_Spring_framework_in_the_user_region.3F). We have isolated the issue to a bundle that relies on spring-batch-core and is failing to load "org.springframework.batch.core.repository.JobRepository". The failure as follows:


[2014-04-07 12:06:45.624] region-dm-0 <AG0000E> Application context creation failure for bundle 'com.foo.service.jobmanager.sb' version '1.0.1.201404011219'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basicStep': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: interface org.springframework.batch.core.repository.JobRepository is not visible from class loader
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
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 org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: interface org.springframework.batch.core.repository.JobRepository is not visible from class loader
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1448)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
at org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor.injectDefaults(CoreNamespacePostProcessor.java:132)
at org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor.postProcessBeforeInitialization(CoreNamespacePostProcessor.java:105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1481)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
... 16 common frames omitted
Caused by: java.lang.IllegalArgumentException: interface org.springframework.batch.core.repository.JobRepository is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:461)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:690)
at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:119)
at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:110)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:98)
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean.getObject(AbstractJobRepositoryFactoryBean.java:198)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 26 common frames omitted




I found a previous thread (http://www.eclipse.org/forums/index.php/t/433311/) that indicates that we should look into the class loader for more clues. I have enabled debugging. I see that the JobRespository class was previously loaded from the appropriate bundle:

Started bundle 'org.springframework.batch.core' version '2.1.9.RELEASE'. Bundle: Active sl = 6; Bundle 180 sl = 4
....
BundleClassLoader[org.springframework.batch.core_2.1.9.RELEASE].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleClassLoader[null].findClassImpl(org.springframework.batch.core.repository.JobRepository)
about to read 1109 bytes from org/springframework/batch/core/repository/JobRepository.class
read 1109 bytes from null/org/springframework/batch/core/repository/JobRepository.class
defining class org.springframework.batch.core.repository.JobRepository
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE] found local class org.springframework.batch.core.repository.JobRepository

Just before the failure, I see the following:

BundleClassLoader[com.foo.persistence.db_1.0.1.201404041301].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.persistence.db_1.0.1.201404041301].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.persistence.db_1.0.1.201404041301].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleClassLoader[null].findClassImpl(org.springframework.batch.core.repository.JobRepository)
BundleClassLoader[com.foo.persistence.db_1.0.1.201404041301].loadClass(org.springframework.batch.core.repository.JobRepository) fai
led.

I see the above messages occure several times in the debug output prior to the failure. What is also confusing is that the bundle com.foo.persistence.db has no references to spring-batch-core.

This is a large application and providing a sample is proving to be difficult. Does anyone have any ideas on what I can do to troubleshoot this further?
Re: Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1289672 is a reply to message #1288459] Wed, 09 April 2014 14:36 Go to previous messageGo to next message
Randy Cuaycong is currently offline Randy CuaycongFriend
Messages: 4
Registered: April 2014
Junior Member
Some developments...

The bundle that fails to load was using the Require-bundle directive (Felix plugin generates our MANIFEST.MF). I removed the required-bundle directive and replaced it with additional Import-Package entries. I read somewhere that the recommendation is that we use Import-Package over Require-Bundle.

After some additional trial and error (running out of ideas), we decided to replace the JobRepository with a Mockito mock of that interface to see if we can at least progress past the initial load. It progressed and our plan loaded!

xml:

<!-- <bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSourceA" />
<property name="transactionManager" ref="transactionManager" />
</bean> -->

<bean id="jobRepository" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.batch.core.repository.JobRepository"></constructor-arg>
</bean>

<!-- <batch:job-repository id="jobRepository" isolation-level-for-create="READ_COMMITTED"/> -->


Looking through the debug output:

BundleClassLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE] found local class org.springframework.batch.core.repository.JobRepository
BundleClassLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE] found local class org.springframework.batch.core.repository.JobRepository
BundleClassLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE] found local class org.springframework.batch.core.repository.JobRepository
BundleClassLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE] found local class org.springframework.batch.core.repository.JobRepository
BundleClassLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[com.foo.service.jobmanager.sb_1.0.1.201404081555].loadBundleClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE].findLocalClass(org.springframework.batch.core.repository.JobRepository)
BundleLoader[org.springframework.batch.core_2.1.9.RELEASE] found local class org.springframework.batch.core.repository.JobRepository
BundleClassLoader[org.mockito.mockito-all_1.9.0].loadClass(org.mockito.internal.progress.ThreadSafeMockingProgress)
BundleLoader[org.mockito.mockito-all_1.9.0].loadBundleClass(org.mockito.internal.progress.ThreadSafeMockingProgress)
BundleLoader[org.mockito.mockito-all_1.9.0].findLocalClass(org.mockito.internal.progress.ThreadSafeMockingProgress)
BundleClassLoader[null].findClassImpl(org.mockito.internal.progress.ThreadSafeMockingProgress)
about to read 3206 bytes from org/mockito/internal/progress/ThreadSafeMockingProgress.class
read 3206 bytes from null/org/mockito/internal/progress/ThreadSafeMockingProgress.class
defining class org.mockito.internal.progress.ThreadSafeMockingProgress

So it seems that with mockito-mock of the JobRepository class in our plan, the BundleLoader/BundleClassLoader was able to successfully load JobRepository but fails when we try to wire up the JobRepository implementation vai the JobRepositoryFactoryBean. Not sure why....
Re: Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1289673 is a reply to message #1289672] Wed, 09 April 2014 14:39 Go to previous messageGo to next message
Randy Cuaycong is currently offline Randy CuaycongFriend
Messages: 4
Registered: April 2014
Junior Member
incidentally...

Even with the mockito-mock in place, I still see a lot of the failure:

BundleClassLoader[com.foo.persistence.db_1.0.1.201404041301].loadClass(org.springframework.batch.core.repository.JobRepository) failed.
java.lang.ClassNotFoundException: org.springframework.batch.core.repository.JobRepository

Not sure why.. as I do not see a direct coorelation between our db related bundles and those that use batch.
Re: Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1299245 is a reply to message #1289673] Wed, 16 April 2014 20:50 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
Hi Randy,

any update on this?

Regards,
florian
Re: Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1302198 is a reply to message #1299245] Fri, 18 April 2014 15:31 Go to previous messageGo to next message
Jay Hamilton is currently offline Jay HamiltonFriend
Messages: 26
Registered: October 2011
Junior Member
Florian,
Randy was able to get past the class loader problem. Once he gets a chance he will update the forum with more info.
Re: Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1307685 is a reply to message #1302198] Mon, 21 April 2014 18:30 Go to previous messageGo to next message
Randy Cuaycong is currently offline Randy CuaycongFriend
Messages: 4
Registered: April 2014
Junior Member
Hello Florian,

Yes we were able to work around the issue through trial and error last week. Our plan successfully loads within the new 3.6.2.RELEASE Virgo.

First, we commented out our "batch:job-repository" that was operational in 3.0.5.M03. We replaced it with an explicit bean definition as follows:

    <!--  Work around for class loading issue   https://www.eclipse.org/forums/index.php/t/688116/ -->
	<bean id="jobRepository"
		class="com.foo.service.jobmanager.impl.WrappedJobRepositoryFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="transactionManager" ref="transactionManager" />
		<property name="isolationLevelForCreate" value="ISOLATION_READ_COMMITTED"/>
	</bean>
	
	<!-- <batch:job-repository id="jobRepository" isolation-level-for-create="READ_COMMITTED"/> -->



Second, we created a new class "WrappedJobRepositoryFactoryBean" that simply extends JobRepositoryFactoryBean and sets the contextClassLoader as follows:


public class WrappedJobRepositoryFactoryBean extends JobRepositoryFactoryBean {
    public WrappedJobRepositoryFactoryBean() {
        Thread.currentThread().setContextClassLoader(
                JobRepositoryFactoryBean.class.getClassLoader());
    }
}



Once that was done, the classloader was able to resolve the JobRepository class and allows the load to continue. As to an explanation of the behavior, we did not dig any deeper once the workaround was discovered. We can only conclude that it is some strange behavior with the BundleClassLoader. Any insight would be great.
Re: Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader" [message #1310569 is a reply to message #1307685] Wed, 23 April 2014 09:05 Go to previous message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
Hi Randy,

thanks for posting your workaround. I am glad you are making progress with your migration.

I'll try to setup a small Spring Batch example and share my insights.

Regards,
florian
Previous Topic:Can Spring be used in host and in snaps?
Next Topic:Virgo 3.5+ hibernate 4 + spring 3.1.1 unknown entity problem
Goto Forum:
  


Current Time: Sun Nov 10 19:44:52 GMT 2024

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

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

Back to the top