Grails

Integration test causes NPE related to transaction handling

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.0.2
  • Component/s: None
  • Labels:
    None

Description

A plugin's test-app is failing with NPE on this test suite:

class FeedsTagLibTests extends GroovyTestCase {

	void testSomething() {
		
	}
}

Yes its a dummy test case that causes the NPE, probably because there is no transaction used (indirectly). The exception:

Running test FeedsTagLibTests...
Error executing tests null ...
java.lang.NullPointerException
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:765)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
at TestApp_groovy$_run_closure10_closure28.doCall(TestApp_groovy:365)

Activity

Hide
Marc Palmer added a comment -

The issue applies only to environments where there is no datasource, i.e. the feeds plugin has none, so there is no transaction manager.

The solution is two-fold:

  • Integration tests that need no datasource/txns should add: static transactional = false
  • TestApp should be improved to survive this and log that there is no DataSource
Show
Marc Palmer added a comment - The issue applies only to environments where there is no datasource, i.e. the feeds plugin has none, so there is no transaction manager. The solution is two-fold:
  • Integration tests that need no datasource/txns should add: static transactional = false
  • TestApp should be improved to survive this and log that there is no DataSource

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: