[ https://issues.apache.org/jira/browse/MSITE-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16918920#comment-16918920 ]
Abel Salgado Romero commented on MSITE-849: ------------------------------------------- Adding {{SessionScoped}} causes the following error and component not even starts. {code:java} com.google.inject.ProvisionException: Unable to provision, see the following errors: 1) Error in custom provider, com.google.inject.OutOfScopeException: Cannot access Key[type=org.asciidoctor.maven.site.AsciidoctorDoxiaParser, annotation=[none]] outside of a scoping block at org.asciidoctor.maven.site.AsciidoctorDoxiaParser.class(Unknown Source) while locating org.asciidoctor.maven.site.AsciidoctorDoxiaParser at ClassRealm[plugin>org.apache.maven.plugins:maven-site-plugin:3.8.2, parent: sun.misc.Launcher$AppClassLoader@18b4aac2] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule) while locating org.apache.maven.doxia.parser.Parser annotated with @com.google.inject.name.Named(value=asciidoc) {code} And injecting {{MavenSession}} has the same effect as the {{MavenProject}}. Checking the whole stacktrace I realize that during {{site:run}}, the Doxia component runs inside a web context. And the call stack is completely different from the one when building with {{site:site}} (see attachment below), there's no Mojo involved. That makes me think that no Maven context is created and that the error does in fact make a lot of sense. I can see how the web context is created... {code:java} Caused by: com.google.inject.OutOfScopeException: Cannot access Key[type=org.apache.maven.project.MavenProject, annotation=[none]] outside of a scoping block at org.apache.maven.execution.scope.internal.MojoExecutionScope$2.get (MojoExecutionScope.java:122) at com.google.inject.internal.InternalFactoryToProviderAdapter.get (InternalFactoryToProviderAdapter.java:39) at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1050) at org.asciidoctor.maven.site.AsciidoctorDoxiaParser.parse (AsciidoctorDoxiaParser.java:81) at org.apache.maven.doxia.DefaultDoxia.parse (DefaultDoxia.java:65) at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderDocument (DefaultSiteRenderer.java:436) at org.apache.maven.doxia.siterenderer.DoxiaDocumentRenderer.renderDocument (DoxiaDocumentRenderer.java:52) at org.apache.maven.plugins.site.run.DoxiaFilter.doFilter (DoxiaFilter.java:144) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle (Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable (HttpConnection.java:258) at org.eclipse.jetty.io.AbstractConnection$2.run (AbstractConnection.java:544) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555) at java.lang.Thread.run (Thread.java:748) {code} !site_site.png! > Unable to inject MavenProject when using `mvn site:run` > ------------------------------------------------------- > > Key: MSITE-849 > URL: https://issues.apache.org/jira/browse/MSITE-849 > Project: Maven Site Plugin > Issue Type: New Feature > Affects Versions: 3.7.1, 3.8.2 > Reporter: Abel Salgado Romero > Assignee: Michael Osipov > Priority: Major > Attachments: site_site.png > > > In https://github.com/asciidoctor/asciidoctor-maven-plugin we inject a > MavenProject to obtain addition configurations from the pom.xml > (https://github.com/asciidoctor/asciidoctor-maven-plugin/blob/a4d86a949643ab68c124fd4c1b9b936412637d93/src/main/java/org/asciidoctor/maven/site/AsciidoctorDoxiaParser.java#L54). > This works fine with {{site:site}}, but when using {{site:run}} and accessing > one of the Asciidoc generated pages we get the error below. > I saw that: > * The error occurs when trying to retrieve the instance of the MavenProject. > * Behavior is the same if I directly inject the MavenProject instead of using > a provider. That is, {{site:site}} works, {{site:run}} fails because it > cannot find the instance. > {code:java} > HTTP ERROR 500 > Problem accessing /hello.html. Reason: > Server Error > Caused by: > com.google.inject.ProvisionException: Unable to provision, see the following > errors: > 1) Error in custom provider, com.google.inject.OutOfScopeException: Cannot > access Key[type=org.apache.maven.project.MavenProject, annotation=[none]] > outside of a scoping block > at > org.apache.maven.execution.scope.internal.MojoExecutionScopeModule.configure(MojoExecutionScopeModule.java:55) > (via modules: org.eclipse.sisu.wire.WireModule -> > org.apache.maven.execution.scope.internal.MojoExecutionScopeModule) > while locating org.apache.maven.project.MavenProject > 1 error > at > com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226) > at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053) > at > org.asciidoctor.maven.site.AsciidoctorDoxiaParser.parse(AsciidoctorDoxiaParser.java:78) > at org.apache.maven.doxia.DefaultDoxia.parse(DefaultDoxia.java:65) > {code} > * How to reproduce: > # clone https://github.com/asciidoctor/asciidoctor-maven-examples > # cd asciidoc-maven-site-example > # mvn site:run > # Access {{http://localhost:8080/hello.html}} > * Env: > {code} > $ mvn -v > Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; > 2019-04-04T21:00:29+02:00) > Maven home: /home/----/.sdkman/candidates/maven/current > Java version: 1.8.0_222, vendor: AdoptOpenJDK, runtime: > /home/-----/.sdkman/candidates/java/8.0.222.hs-adpt/jre > Default locale: en_US, platform encoding: UTF-8 > OS name: "linux", version: "5.1.21-1-manjaro", arch: "amd64", family: "unix > {code} -- This message was sent by Atlassian Jira (v8.3.2#803003)