You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by 0xsven <0x...@gmail.com> on 2010/09/24 13:45:19 UTC

setting path to shiro.ini


	

Hi,

I try to exclude my ini section into a file. I have a standard maven web
project and want to put the shiro.ini file into the src/main/resources
folder.

I tried to to it like that:

    <init-param>
        <param-name>configPath</param-name>
        <param-value>file:src/main/resources/shiro.ini</param-value>
    </init-param>

But it couldn't find it :-( what's wrong with my config?

Thank you

-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/setting-path-to-shiro-ini-tp5566471p5566471.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: setting path to shiro.ini

Posted by f a v <fa...@gmail.com>.
On Fri, Sep 24, 2010 at 9:00 AM, slott
<be...@atchik-realtime.com> wrote:
>
> As it says at http://incubator.apache.org/shiro/web.html
>
> "So, if you want/need to externalize your Shiro config in a file, the
> easiest thing to do is use the IniShiroFilter without any init params and
> place a shiro.ini file at the root of the classpath:"
> <filter>
>    <filter-name>ShiroFilter</filter-name>
>    <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
>    <!-- no init-param means load the INI config from classpath:shiro.ini
> -->
> </filter>
>
> So now u just need to make sure that the src/main/resources contents are
> output to the target/classes dir

And that is what maven default configuration does if you put it in
src/main/resources/ as you've already done.
=)

Re: setting path to shiro.ini

Posted by slott <be...@atchik-realtime.com>.
As it says at http://incubator.apache.org/shiro/web.html

"So, if you want/need to externalize your Shiro config in a file, the
easiest thing to do is use the IniShiroFilter without any init params and
place a shiro.ini file at the root of the classpath:"
<filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
    <!-- no init-param means load the INI config from classpath:shiro.ini
-->
</filter>

So now u just need to make sure that the src/main/resources contents are
output to the target/classes dir

voila
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/setting-path-to-shiro-ini-tp5566471p5566521.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: setting path to shiro.ini

Posted by 0xsven <0x...@gmail.com>.
...I did it as you recommended but I get following error:

java.lang.ClassNotFoundException:
org.apache.shiro.web.servlet.IniShiroFilter
	at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:269)
	at
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
	at
org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
	at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4001)
	at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4651)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	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:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/setting-path-to-shiro-ini-tp5566471p5673569.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: setting path to shiro.ini

Posted by Les Hazlewood <lh...@apache.org>.
Hi Sven,

it is not working because the file: resource prefix does not support
relative paths.  The file path must be absolute.  That is, instead of:

file:src/main/resources/shiro.ini

it would be

file:C:\Users\Les\projects\myproject\src\main\resources\shiro.ini

Now even if relative paths worked, it wouldn't make sense in your
web.xml - the servlet container is free to place your war file
wherever it wants on the file system, and then your relative path
would be unknown.  It doesn't even have to unzip the .war file, in
which case a relative path doesn't make any sense at all.  This is why
absolute paths are supported: if a war is exploded or remains
compressed, an absolute file can still be resolved.

But for maven projects, the easiest thing is to do what slott and fav
have recommended.  Remove the ShiroFilter init-params and just put
your shiro.ini in src/main/resources.  That should be good enough.

Cheers,

Les

On Fri, Sep 24, 2010 at 4:45 AM, 0xsven <0x...@gmail.com> wrote:
>
>
>
>
> Hi,
>
> I try to exclude my ini section into a file. I have a standard maven web
> project and want to put the shiro.ini file into the src/main/resources
> folder.
>
> I tried to to it like that:
>
>    <init-param>
>        <param-name>configPath</param-name>
>        <param-value>file:src/main/resources/shiro.ini</param-value>
>    </init-param>
>
> But it couldn't find it :-( what's wrong with my config?
>
> Thank you
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/setting-path-to-shiro-ini-tp5566471p5566471.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>