Autowiring/SLF4j does not seem to work with Jubula (?) [message #808919] |
Tue, 28 February 2012 09:39 |
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.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04306 seconds