You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Markus W Mahlberg (JIRA)" <ji...@apache.org> on 2014/10/29 19:35:35 UTC

[jira] [Commented] (SHIRO-493) shiro-guice not working with the last guice 4 beta

    [ https://issues.apache.org/jira/browse/SHIRO-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14188760#comment-14188760 ] 

Markus W Mahlberg commented on SHIRO-493:
-----------------------------------------

Funny enough, most of the issues are to overcome by manually binding the FilterChainResolver interface to the PathMatchingFilterChainResolver

{code:borderStyle=solid}
    /* Is the only implementing class anyway */
    bind(FilterChainResolver.class).to(PathMatchingFilterChainResolver.class).in(Scopes.SINGLETON);
{code}

and creating providers for SecurityManager and Realm:

{code:title=YourModule.java|borderStyle=solid}
    	@Provides
	@Singleton
	WebSecurityManager securityManager(Realm realm) {
		DefaultWebSecurityManager sm = new DefaultWebSecurityManager();
		sm.setRealm(realm);
		return sm;
	}
	
	@Provides
	@Singleton
	Realm iniRealm() {
	
		return new IniRealm();
	
	}
{code}

However, when doing this and installing the filters with

{code:title=YourModule.java|borderStyle=solid}
    		YourExtensionOfShiroWebModule.bindGuiceFilter(binder());
{code}

the following exception is thrown during the servlet initialization:

{code}
[main] WARN org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED o.e.j.s.ServletContextHandler@2756b0ce{/,null,STARTING}: javax.servlet.ServletException: Filters must be bound as singletons. Key[type=org.apache.shiro.guice.web.GuiceShiroFilter, annotation=[none]] was not bound in singleton scope.
javax.servlet.ServletException: Filters must be bound as singletons. Key[type=org.apache.shiro.guice.web.GuiceShiroFilter, annotation=[none]] was not bound in singleton scope.
	at com.google.inject.servlet.FilterDefinition.init(FilterDefinition.java:98)
	at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:99)
	at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:220)
	at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:138)
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:850)
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:742)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.server.Server.start(Server.java:388)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.server.Server.doStart(Server.java:355)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        ...
{code}

But I am pretty sure this is a different problem, if I am not wrong with that.

> shiro-guice not working with the last guice 4 beta
> --------------------------------------------------
>
>                 Key: SHIRO-493
>                 URL: https://issues.apache.org/jira/browse/SHIRO-493
>             Project: Shiro
>          Issue Type: Bug
>          Components: Integration: Guice
>    Affects Versions: 1.2.3
>         Environment: java version "1.7.0_51"
> Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
> Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
>            Reporter: Filipe Sousa
>            Assignee: Jared Bunting
>
> Switching from guice 3.0 to guice 4 beta is causing some problems.
> public class SecurityModule extends ShiroWebModule {
>     public SecurityModule(ServletContext servletContext) {
>         super(servletContext);
>     }
>     @Override
>     protected void configureShiroWeb() {
>         bind(Realm.class).to(JdbcRealm.class);
>     }
> }
> com.google.inject.CreationException: Guice creation errors:
> 1) No implementation for java.util.Set<org.apache.shiro.realm.Realm> was bound.
>   at org.apache.shiro.guice.ShiroModule.configure(ShiroModule.java:74) (via modules: pt.egoi.megan.guice.MeganModule -> pt.egoi.megan.security.SecurityModule)
> 1 error
> 	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:449) ~[guice-4.0-SNAPSHOT.jar:na]
> 	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155) ~[guice-4.0-SNAPSHOT.jar:na]
> 	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107) ~[guice-4.0-SNAPSHOT.jar:na]
> 	at com.google.inject.Guice.createInjector(Guice.java:96) ~[guice-4.0-SNAPSHOT.jar:na]
> 	at com.google.inject.Guice.createInjector(Guice.java:84) ~[guice-4.0-SNAPSHOT.jar:na]
> 	at pt.egoi.megan.guice.GuiceListener.getInjector(GuiceListener.java:20) ~[classes/:na]
> 	at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:47) ~[guice-servlet-4.0-SNAPSHOT.jar:na]
> 	at pt.egoi.megan.guice.GuiceListener.contextInitialized(GuiceListener.java:31) ~[classes/:na]
> 	at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:746) ~[jetty-server-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:238) ~[jetty-servlet-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1240) ~[jetty-webapp-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:689) ~[jetty-server-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:482) ~[jetty-webapp-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:494) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:141) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:145) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:56) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:615) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:540) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:403) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:337) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:121) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:555) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:230) [jetty-deploy-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58) [jetty-server-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96) [jetty-server-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.server.Server.doStart(Server.java:281) [jetty-server-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) [jetty-util-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1274) [jetty-xml-7.6.14.v20131031.jar:7.6.14.v20131031]
> 	at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_51]
> 	at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1197) [jetty-xml-7.6.14.v20131031.jar:7.6.14.v20131031]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)