← Back to team overview

dhis2-devs team mailing list archive

[Bug 1073864] [NEW] [branch web-api-test specific] tests fails when has data in DB

 

Public bug reported:

This bug is branch web-api-test specific!

The Controller specific tests, which utilized spring-test-mvc framework,
could not work when there are data resides in the database. The
following is the exception log.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.hisp.dhis.organisationunit.OrganisationUnit.groups, no session or session was closed
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.springframework.test.web.server.MockMvc.perform(MockMvc.java:77)
	at org.hisp.dhis.api.controller.organisationunit.OUCT.testGetOrgUnitList(OUCT.java:38)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.hisp.dhis.organisationunit.OrganisationUnit.groups, no session or session was closed
	at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:393)
	at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:385)
	at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:378)
	at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
	at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:180)
	at org.hisp.dhis.api.utils.WebUtils.generateLinks(WebUtils.java:136)
	at org.hisp.dhis.api.utils.WebUtils.generateLinks(WebUtils.java:74)
	at org.hisp.dhis.api.controller.AbstractCrudController.getObjectList(AbstractCrudController.java:82)
	at org.hisp.dhis.api.controller.AbstractCrudController$$FastClassByCGLIB$$3565baa0.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:618)
	at org.hisp.dhis.api.controller.organisationunit.OrganisationUnitController$$EnhancerByCGLIB$$40e80b0.getObjectList(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.test.web.server.TestDispatcherServlet.doService(TestDispatcherServlet.java:73)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	... 29 more

** Affects: dhis2
     Importance: Undecided
         Status: New

** Branch linked: lp:~dhis-academy/dhis2/web_api_test

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/1073864

Title:
  [branch web-api-test specific] tests fails when has data in DB

Status in DHIS 2 - District Health Information Software:
  New

Bug description:
  This bug is branch web-api-test specific!

  The Controller specific tests, which utilized spring-test-mvc
  framework, could not work when there are data resides in the database.
  The following is the exception log.

  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.hisp.dhis.organisationunit.OrganisationUnit.groups, no session or session was closed
  	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
  	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
  	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
  	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  	at org.springframework.test.web.server.MockMvc.perform(MockMvc.java:77)
  	at org.hisp.dhis.api.controller.organisationunit.OUCT.testGetOrgUnitList(OUCT.java:38)
  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  	at java.lang.reflect.Method.invoke(Method.java:601)
  	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
  	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
  	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
  	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
  	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
  	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
  	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
  	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
  	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
  	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
  	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
  	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
  	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.hisp.dhis.organisationunit.OrganisationUnit.groups, no session or session was closed
  	at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:393)
  	at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:385)
  	at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:378)
  	at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
  	at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:180)
  	at org.hisp.dhis.api.utils.WebUtils.generateLinks(WebUtils.java:136)
  	at org.hisp.dhis.api.utils.WebUtils.generateLinks(WebUtils.java:74)
  	at org.hisp.dhis.api.controller.AbstractCrudController.getObjectList(AbstractCrudController.java:82)
  	at org.hisp.dhis.api.controller.AbstractCrudController$$FastClassByCGLIB$$3565baa0.invoke(<generated>)
  	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:618)
  	at org.hisp.dhis.api.controller.organisationunit.OrganisationUnitController$$EnhancerByCGLIB$$40e80b0.getObjectList(<generated>)
  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  	at java.lang.reflect.Method.invoke(Method.java:601)
  	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
  	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
  	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
  	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
  	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
  	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
  	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
  	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
  	at org.springframework.test.web.server.TestDispatcherServlet.doService(TestDispatcherServlet.java:73)
  	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
  	... 29 more

To manage notifications about this bug go to:
https://bugs.launchpad.net/dhis2/+bug/1073864/+subscriptions


Follow ups

References