Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-1393

Maven swagger goal failed: No Session opened for this thread

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.12.1
    • Fix Version/s: 1.13.0
    • Component/s: Core: Maven Plugin
    • Labels:
      None

      Description

      In addition to ISIS-1315, there seems to be another problem not related to action contributions.

      As described in http://markmail.org/message/n33avio7bu6ynsi2:

      I have the same error with 1.12.1 (cf. stack trace below) while running
      in my integration test module and using the real AppManifest as
      suggested in ISIS-1295 [1] (although I had to comment out the security
      module temporarily because it led to another error) .

      I am trying to debug it and it seems like the session is already closed
      by the time IsisContext.getPersistenceSession is called in below stack.

      [ERROR] Failed to execute goal org.apache.isis.tool:isis-maven-plugin:1.12.1:swagger (default) on project message-service-integration: Execution default of goal org.apache.isis.tool:isis-maven-plugin:1.12.1:swagger failed: No Session opened for this thread -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.isis.tool:isis-maven-plugin:1.12.1:swagger (default) on project message-service-integration: Execution default of goal org.apache.isis.tool:isis-maven-plugin:1.12.1:swagger failed: No Session opened for this thread
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
      	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
      	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
      Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.apache.isis.tool:isis-maven-plugin:1.12.1:swagger failed: No Session opened for this thread
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
      	... 19 more
      Caused by: java.lang.IllegalStateException: No Session opened for this thread
      	at org.apache.isis.core.runtime.system.context.IsisContext.getSession(IsisContext.java:455)
      	at org.apache.isis.core.runtime.system.context.IsisContext.getPersistenceSession(IsisContext.java:483)
      	at org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession.getPersistenceSession(RuntimeContextFromSession.java:268)
      	at org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession.access$000(RuntimeContextFromSession.java:61)
      	at org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$2.adapterFor(RuntimeContextFromSession.java:102)
      	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionContributee.getServiceAdapter(ObjectActionContributee.java:328)
      	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionContributee.getParameters(ObjectActionContributee.java:140)
      	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionDefault.getParameterTypes(ObjectActionDefault.java:209)
      	at org.apache.isis.core.metamodel.services.swagger.internal.ClassExcluder.exclude(ClassExcluder.java:44)
      	at org.apache.isis.core.metamodel.services.swagger.internal.Util$2.accept(Util.java:145)
      	at org.apache.isis.core.metamodel.services.swagger.internal.Util$2.accept(Util.java:142)
      	at org.apache.isis.applib.filter.Filters$6.apply(Filters.java:101)
      	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:675)
      	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
      	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
      	at com.google.common.collect.Iterators.addAll(Iterators.java:364)
      	at com.google.common.collect.Lists.newArrayList(Lists.java:162)
      	at com.google.common.collect.Collections2$FilteredCollection.toArray(Collections2.java:215)
      	at java.util.ArrayList.addAll(ArrayList.java:577)
      	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectSpecificationAbstract.getObjectActions(ObjectSpecificationAbstract.java:766)
      	at org.apache.isis.core.metamodel.services.swagger.internal.Util.actionsOf(Util.java:142)
      	at org.apache.isis.core.metamodel.services.swagger.internal.Generation.appendObjectPathsAndDefinitions(Generation.java:213)
      	at org.apache.isis.core.metamodel.services.swagger.internal.Generation.generate(Generation.java:124)
      	at org.apache.isis.core.metamodel.services.swagger.internal.SwaggerSpecGenerator.generate(SwaggerSpecGenerator.java:44)
      	at org.apache.isis.core.metamodel.services.swagger.SwaggerServiceDefault.generateSwaggerSpec(SwaggerServiceDefault.java:69)
      	at org.apache.isis.tool.mavenplugin.IsisMojoSwagger.writeSwaggerSpec(IsisMojoSwagger.java:120)
      	at org.apache.isis.tool.mavenplugin.IsisMojoSwagger.doExecute(IsisMojoSwagger.java:89)
      	at org.apache.isis.tool.mavenplugin.IsisMojoAbstract.execute(IsisMojoAbstract.java:68)
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
      	... 20 more
      [DEBUG] finalizing hash of pojos
      [ERROR] 
      [DEBUG] finalizing persistence session
      

        Issue Links

          Activity

          Hide
          darabi Kambiz Darabi added a comment -

          I tried to debug the issue and it seems as if the session in closed too early, although I didn't find out why.

          The maven build seems to be single-threaded, as the stack which leads to closeSessionInstance suggests:

          	at org.apache.isis.core.runtime.system.context.IsisContext.closeSessionInstance(IsisContext.java:256)
          	at org.apache.isis.core.runtime.system.context.IsisContext.closeSession(IsisContext.java:353)
          	at org.apache.isis.core.runtime.system.IsisSystem.shutdownServices(IsisSystem.java:384)
          	at org.apache.isis.core.runtime.system.IsisSystem.shutdown(IsisSystem.java:353)
          	at org.apache.isis.tool.mavenplugin.IsisMojoAbstract.execute(IsisMojoAbstract.java:75)
          	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
          	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
          	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
          	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
          	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
          	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
          	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
          	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
          	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
          	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
          

          But the original exception (cf. description) appears after this call
          to closeSessionInstance, so it might be a concurrency issue,
          though.

          I also noted that when I run both the PUBLIC and PRIVATE visibilities
          with the following configuration, swagger-PUBLIC.json is always
          generated and the error occurs reproducibly during generation of
          swagger-PRIVATE.json, which is much bigger and takes longer to
          generate.

          <plugin>
          	<groupId>org.apache.isis.tool</groupId>
          	<artifactId>isis-maven-plugin</artifactId>
          ...
          	<visibilities>
          		<visibility>PUBLIC</visibility>
          		<visibility>PRIVATE</visibility>
          	</visibilities>
          ...
          	<executions>
          		<execution>
          			<phase>package</phase>
          			<goals>
          				<goal>swagger</goal>
          			</goals>
          		</execution>
          	</executions>
          

          Whatever the reason, this commit fixes the issue but I guess this is
          not the proper way of solving the problem:

          https://github.com/m-creations/isis/tree/mcreations-maven-swagger-no-session

          HTH

          Kambiz

          Show
          darabi Kambiz Darabi added a comment - I tried to debug the issue and it seems as if the session in closed too early, although I didn't find out why. The maven build seems to be single-threaded, as the stack which leads to closeSessionInstance suggests: at org.apache.isis.core.runtime.system.context.IsisContext.closeSessionInstance(IsisContext.java:256) at org.apache.isis.core.runtime.system.context.IsisContext.closeSession(IsisContext.java:353) at org.apache.isis.core.runtime.system.IsisSystem.shutdownServices(IsisSystem.java:384) at org.apache.isis.core.runtime.system.IsisSystem.shutdown(IsisSystem.java:353) at org.apache.isis.tool.mavenplugin.IsisMojoAbstract.execute(IsisMojoAbstract.java:75) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) But the original exception (cf. description) appears after this call to closeSessionInstance , so it might be a concurrency issue, though. I also noted that when I run both the PUBLIC and PRIVATE visibilities with the following configuration, swagger-PUBLIC.json is always generated and the error occurs reproducibly during generation of swagger-PRIVATE.json, which is much bigger and takes longer to generate. <plugin> <groupId>org.apache.isis.tool</groupId> <artifactId>isis-maven-plugin</artifactId> ... <visibilities> <visibility>PUBLIC</visibility> <visibility>PRIVATE</visibility> </visibilities> ... <executions> <execution> <phase> package </phase> <goals> <goal>swagger</goal> </goals> </execution> </executions> Whatever the reason, this commit fixes the issue but I guess this is not the proper way of solving the problem: https://github.com/m-creations/isis/tree/mcreations-maven-swagger-no-session HTH Kambiz
          Hide
          danhaywood Dan Haywood added a comment -

          Implemented as part of ISIS-1406.

          Show
          danhaywood Dan Haywood added a comment - Implemented as part of ISIS-1406 .
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 18a18bf73289514ccc52345aa390936dd765bb3e in isis's branch refs/heads/master from Dan Haywood
          [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=18a18bf ]

          ISIS-1393: if IsisSystem fails to init (for any reason), then fail the mojo

          Show
          jira-bot ASF subversion and git services added a comment - Commit 18a18bf73289514ccc52345aa390936dd765bb3e in isis's branch refs/heads/master from Dan Haywood [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=18a18bf ] ISIS-1393 : if IsisSystem fails to init (for any reason), then fail the mojo
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 786e882a8da1009c2a6279220dbfab58ee44dfaa in isis's branch refs/heads/ISIS-1391 from Dan Haywood
          [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=786e882 ]

          ISIS-1393: removes MessageServiceInternal as an internal API, and instead has two implementations of MessageService (a noop one, and a default one)

          Show
          jira-bot ASF subversion and git services added a comment - Commit 786e882a8da1009c2a6279220dbfab58ee44dfaa in isis's branch refs/heads/ ISIS-1391 from Dan Haywood [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=786e882 ] ISIS-1393 : removes MessageServiceInternal as an internal API, and instead has two implementations of MessageService (a noop one, and a default one)
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 786e882a8da1009c2a6279220dbfab58ee44dfaa in isis's branch refs/heads/master from Dan Haywood
          [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=786e882 ]

          ISIS-1393: removes MessageServiceInternal as an internal API, and instead has two implementations of MessageService (a noop one, and a default one)

          Show
          jira-bot ASF subversion and git services added a comment - Commit 786e882a8da1009c2a6279220dbfab58ee44dfaa in isis's branch refs/heads/master from Dan Haywood [ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=786e882 ] ISIS-1393 : removes MessageServiceInternal as an internal API, and instead has two implementations of MessageService (a noop one, and a default one)

            People

            • Assignee:
              danhaywood Dan Haywood
              Reporter:
              darabi Kambiz Darabi
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development