Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Jubula » Autowiring/SLF4j does not seem to work with Jubula (?)(Usage of Spring's autowiring and/or SLF4J in Swing app leads to problems)
Autowiring/SLF4j does not seem to work with Jubula (?) [message #808919] Tue, 28 February 2012 09:39 Go to next message
Sup SC
Messages: 15
Registered: February 2012
Junior Member
Hi all,

is there a special method to start AUTs which use Spring's Autowire?
When starting the AUT which uses Autowiring the app will throw exceptions which are not present when started manually which lead to an untestable application. Furthermore, depending on the AUT's start method I get exceptions at different points.
When starting the AUT with a .cmd file - be it out of Jubula (Standalone 1.1) or using autrun - I get Autowire and cast exceptions regarding the logger (the AUT, like Jubula, also uses slf4j, but 'our' lib is included before Jubula's out of the %TEMP% directory) when reaching a certain point during the login process of the AUT (see below for log), the AUT won't run any further because of these.

But when starting the AUT via the .jar file I am able to successfully test the complete login process without getting any exception. Only later, during a following test, an Autowire exceptions occur.
In both cases the exceptions of the application occur only if started as AUT, not when starte 'normally'. Furthermore they do not only appear during a test run, but also when performing the same steps manually (after having started the AUT through Jubula/autrun). As mentioned, these exceptions do not appear when started via double click on the jar or when started through the .cmd manually. It is an application which is successfully in production use to which we/I planned to start more professional GUI based tests.

The problem is reproducable with Oracle's JRE 6 and 7 and both on Windows XP (32bit) and Windows Server 2003 (32bit). The AUT itself is written based on Oracle's JDK 6.

Is there any special option, so that the application context for Spring Autowiring is held (which according to our responsible developer might be the cause)? The working path for the AUT is of course correctly set, in the .cmd the path is additionally changed explicitly to the proposed working directory.


Log extracts:

Starting as jar:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/SoftContract/PBL/LeaseContract/lib/slf4j-log4j12-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Dokumente%20und%20Einstellungen/user/Lokale%20Einstellungen/Temp/slf4j-jdk14-1.5.115070670331261601047.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See www.slf4j.org/codes.html#multiple_bindings for an explanation.
Exception in thread "Thread-5" 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openWindowService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.company.lib.framework.services.RightsService net.company.lib.framework.services.OpenWindowServiceImpl.rightsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rightsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.company.lib.framework.factory.ScreenFactory net.company.lib.framework.services.RightsServiceImpl.screenFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.company.lib.framework.factory.ScreenFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1073)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
	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.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
	at net.company.lib.util.SpringUtil.getBean(SpringUtil.java:76)
	at net.company.lib.framework.mdi.NavigationTreeMouseAdapater$1.run(NavigationTreeMouseAdapater.java:60)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.company.lib.framework.services.RightsService net.company.lib.framework.services.OpenWindowServiceImpl.rightsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rightsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.company.lib.framework.factory.ScreenFactory net.company.lib.framework.services.RightsServiceImpl.screenFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.company.lib.framework.factory.ScreenFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
	... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rightsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.company.lib.framework.factory.ScreenFactory net.company.lib.framework.services.RightsServiceImpl.screenFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.company.lib.framework.factory.ScreenFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1073)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
	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.findAutowireCandidates(DefaultListableBeanFactory.java:848)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
	... 12 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.company.lib.framework.factory.ScreenFactory net.company.lib.framework.services.RightsServiceImpl.screenFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.company.lib.framework.factory.ScreenFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
	... 23 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.company.lib.framework.factory.ScreenFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
	... 25 more





Starting with autrun / from .cmd:
AUT: Exception in thread "Thread-3"
AUT:threw exception; nested exception is java.lang.ExceptionInInitializerError
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:451)
AUT:      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
AUT:      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
AUT:      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
AUT:      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
AUT:      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
AUT:      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
AUT:      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
AUT:      at net.company.lib.util.SpringUtil.loadApplicationContext(SpringUtil.java:103)
AUT:      at net.company.lib.util.SpringUtil.loadApplicationContext(SpringUtil.java:83)
AUT:      at net.company.lib.framework.login.services.LoginServiceImpl.setProfileWasChangedStatus(LoginServiceImpl.java:766)
AUT:      at net.company.lib.framework.login.services.LoginServiceImpl.readProfile(LoginServiceImpl.java:599)
AUT:      at net.company.lib.framework.login.services.LoginServiceImpl.login(LoginServiceImpl.java:398)
AUT:      at net.company.lib.framework.login.services.LoginServiceImpl.access$000(LoginServiceImpl.java:62)
AUT:      at net.company.lib.framework.login.services.LoginServiceImpl$1.run(LoginServiceImpl.java:101)
AUT:threw exception; nested exception is java.lang.ExceptionInInitializerError
AUT:      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:982)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:878)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:484)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
AUT:      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:312)
AUT:      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
AUT:      at org.springframework.aop.target.dynamic.BeanFactoryRefreshableTargetSource.obtainFreshBean(BeanFactoryRefreshableTargetSource.java:77)
AUT:      at org.springframework.scripting.support.RefreshableScriptTargetSource.obtainFreshBean(RefreshableScriptTargetSource.java:79)
AUT:      at org.springframework.aop.target.dynamic.BeanFactoryRefreshableTargetSource.freshTarget(BeanFactoryRefreshableTargetSource.java:66)
AUT:      at org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource.refresh(AbstractRefreshableTargetSource.java:97)
AUT:      at org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource.getTargetClass(AbstractRefreshableTargetSource.java:68)
AUT:      at org.springframework.scripting.support.ScriptFactoryPostProcessor.createRefreshableProxy(ScriptFactoryPostProcessor.java:526)
AUT:      at org.springframework.scripting.support.ScriptFactoryPostProcessor.postProcessBeforeInstantiation(ScriptFactoryPostProcessor.java:307)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:847)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:819)
AUT:      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:445)
AUT:      ... 14 more
AUT:threw exception; nested exception is java.lang.ExceptionInInitializerError
AUT:      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:157)
AUT:      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
AUT:      ... 30 more
AUT: Caused by: java.lang.ExceptionInInitializerError
AUT:      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
AUT:      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
AUT:      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
AUT:      at java.lang.reflect.Constructor.newInstance(Unknown Source)
AUT:      at java.lang.Class.newInstance0(Unknown Source)
AUT:      at java.lang.Class.newInstance(Unknown Source)
AUT:      at org.springframework.scripting.groovy.GroovyScriptFactory.executeScript(GroovyScriptFactory.java:238)
AUT:      at org.springframework.scripting.groovy.GroovyScriptFactory.getScriptedObject(GroovyScriptFactory.java:185)
AUT:      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
AUT:      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
AUT:      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
AUT:      at java.lang.reflect.Method.invoke(Unknown Source)
AUT:      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:145)
AUT:      ... 31 more
AUT: Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.commons.logging.impl.Log4JLogger@b66478' with class 'org.apache.commons.logging.impl.Log4JLogger' to class 'org.apache.commons.logging.Log'
AUT:      at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
AUT:      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
AUT:      at CreateSomeReleasePostings.<clinit>(CreateSomeReleasePostings:56)


Thanks for your help, as Jubula will probably be no longer an option for us if these problems won't get solved.
Re: Autowiring/SLF4j does not seem to work with Jubula (?) [message #809204 is a reply to message #808919] Tue, 28 February 2012 15:44 Go to previous messageGo to next message
Zeb Ford-Reitz is currently offline Zeb Ford-Reitz
Messages: 32
Registered: November 2010
Member
I don't have any experience with Spring autowiring, so any advice I offer is basically guesswork. Having said that, I would assume that autowiring (in combination with Jubula's classloading) is the cause of the problem. We had an issue with classloading and logger incompatibility several years ago, which is what caused us to switch from Jakarta Commons Logging to SLF4J. The change (plus some adjustments to Jubula's classloading heirarchy) fixed the issue at the time. Perhaps Spring is overriding / ignoring Jubula's classloading strategy somehow?

The other issue that you are experiencing (when starting as JAR) is completely unfamiliar to me. I'd suggest asking the developer in question to take a look at Jubula's classloading hierarchy in order to help diagnose the problem: AutServerLauncher is the class responsible for keeping AUT and Jubula classloading separate.

Another option for further analysis of the problem would be checking out Jubula's source and remote debugging the AUT / Jubula RC.
Re: Autowiring/SLF4j does not seem to work with Jubula (?) [message #809212 is a reply to message #809204] Tue, 28 February 2012 15:54 Go to previous messageGo to next message
Sup SC
Messages: 15
Registered: February 2012
Junior Member
Zeb Ford-Reitz wrote on Tue, 28 February 2012 16:44
I'd suggest asking the developer in question to take a look at Jubula's classloading hierarchy


Thanks for your help so far, I hope I am able to convince him its worth the effort...
Maybe turning of autowiring in further modules of or app (as this has already been done in the past for many others) is also an option.


If anyone else would have furthers ideas - I still would be thankful for these nevertheless.

Thx
Re: Autowiring/SLF4j does not seem to work with Jubula (?) [message #831285 is a reply to message #809212] Wed, 28 March 2012 17:57 Go to previous messageGo to next message
Alexandra Schladebeck is currently offline Alexandra Schladebeck
Messages: 1155
Registered: July 2009
Senior Member
Crosslink to bug entry: http://www.eclipse.org/forums/index.php/t/300086/
Re: Autowiring/SLF4j does not seem to work with Jubula (?) [message #831396 is a reply to message #831285] Wed, 28 March 2012 21:18 Go to previous message
Zeb Ford-Reitz is currently offline Zeb Ford-Reitz
Messages: 32
Registered: November 2010
Member
I think you meant to crosslink to h ttps://bugs.eclipse.org/bugs/show_bug.cgi?id=375044

(STILL can't post links)

- Zeb
Previous Topic:[solved] Usage of storeProperty in 1.2.0
Next Topic:Drag & drop canvas figure item On RCP program
Goto Forum:
  


Current Time: Wed Oct 01 20:28:37 GMT 2014

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

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