Not able to initialize using Tomcat Embedded (7.0.57)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Not able to initialize using Tomcat Embedded (7.0.57)

apowell
I followed the tutorial on the web using the sample application and was able
to set up a jdbcRealm and log in. But, when I tried to get my working app to
work there is no success.

I added the correct information to my pom.xml and my config.ini is the same
that I used with the tutorial application. In the web.xml file, the listener
is setup the same as the tutorial.

Are there any suggestions.



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Not able to initialize using Tomcat Embedded (7.0.57)

Brian Demers
We need to a little more information, StackOverflow has a good doc on how to ask questions (can be applied to SO or any mailing list)

On Thu, Oct 12, 2017 at 1:23 PM, apowell <[hidden email]> wrote:
I followed the tutorial on the web using the sample application and was able
to set up a jdbcRealm and log in. But, when I tried to get my working app to
work there is no success.

I added the correct information to my pom.xml and my config.ini is the same
that I used with the tutorial application. In the web.xml file, the listener
is setup the same as the tutorial.

Are there any suggestions.



--
Sent from: http://shiro-user.582556.n2.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Not able to initialize using Tomcat Embedded (7.0.57)

apowell
Fair -
This is the output from starting the tutorial app using Jetty:
[INFO] Scanning elapsed time=1010ms
[INFO] Initializing Shiro environment
13:26:43.422 [main] INFO  o.a.shiro.web.env.EnvironmentLoader - Starting
Shiro environment initialization.
13:26:43.954 [main] INFO  o.a.s.c.IniSecurityManagerFactory - Realms have
been explicitly set on the SecurityManager instance - auto-setting of realms
will not occur.
13:26:43.961 [main] INFO  o.a.shiro.web.env.EnvironmentLoader - Shiro
environment initialized in 535 ms.
[INFO] Started
o.e.j.m.p.JettyWebAppContext@4c98a6d5{/,file:///Users/andrepowell/Documents/Projects/apache-shiro-tutorial-webapp/src/main/webapp/,AVAILABLE}{file:///Users/andrepowell/Documents/Projects/apache-shiro-tutorial-webapp/src/main/webapp/}
[INFO] Started ServerConnector@4f02e22f{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @6337ms
[INFO] Started Jetty Server


The output from Tomcat - not initializing Shiro at all:
Oct 12, 2017 3:14:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 12, 2017 3:14:08 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Tomcat
Oct 12, 2017 3:14:08 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Oct 12, 2017 3:14:08 PM org.apache.catalina.startup.ContextConfig
getDefaultWebXmlFragment
INFO: No global web.xml found
Oct 12, 2017 3:14:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]

web.xml:
<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">



  <filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>






--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Not able to initialize using Tomcat Embedded (7.0.57)

gs286k .
You also need to register listner in you are using INI configuration

<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>

Also based on your first comment it seems like you are using congig.ini instead of shiro.ini configuration file in which case you need to register it as

 <context-param>
     <param-name>shiroConfigLocations</param-name>
     <param-value>/{PATH}/config.ini</param-value>
 </context-param>



On Thu, Oct 12, 2017 at 2:36 PM, apowell <[hidden email]> wrote:
Fair -
This is the output from starting the tutorial app using Jetty:
[INFO] Scanning elapsed time=1010ms
[INFO] Initializing Shiro environment
13:26:43.422 [main] INFO  o.a.shiro.web.env.EnvironmentLoader - Starting
Shiro environment initialization.
13:26:43.954 [main] INFO  o.a.s.c.IniSecurityManagerFactory - Realms have
been explicitly set on the SecurityManager instance - auto-setting of realms
will not occur.
13:26:43.961 [main] INFO  o.a.shiro.web.env.EnvironmentLoader - Shiro
environment initialized in 535 ms.
[INFO] Started
o.e.j.m.p.JettyWebAppContext@4c98a6d5{/,file:///Users/andrepowell/Documents/Projects/apache-shiro-tutorial-webapp/src/main/webapp/,AVAILABLE}{file:///Users/andrepowell/Documents/Projects/apache-shiro-tutorial-webapp/src/main/webapp/}
[INFO] Started ServerConnector@4f02e22f{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @6337ms
[INFO] Started Jetty Server


The output from Tomcat - not initializing Shiro at all:
Oct 12, 2017 3:14:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 12, 2017 3:14:08 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Tomcat
Oct 12, 2017 3:14:08 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Oct 12, 2017 3:14:08 PM org.apache.catalina.startup.ContextConfig
getDefaultWebXmlFragment
INFO: No global web.xml found
Oct 12, 2017 3:14:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]

web.xml:
<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">



  <filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>



--
Thanks,
-Gautam
Reply | Threaded
Open this post in threaded view
|

Re: Not able to initialize using Tomcat Embedded (7.0.57)

apowell
Okay there is a listener :
<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <listener>
   
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
  </listener>

  <filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

</web-app>

And I am using shiro.ini with the same result (shiro never starting). One
weird thing is that once I run clean|compile|package (using Maven)
target/Project/WEB-INF/web.xml complains that it cannot find ShiroFilter
needs  filter mapping although the file is still:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <listener>
   
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
  </listener>

  <filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

</web-app>



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Not able to initialize using Tomcat Embedded (7.0.57)

gs286k .
Do you have shiro-web in your project classpath?

<dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>1.3.2</version> </dependency>



On Fri, Oct 13, 2017 at 2:05 PM, apowell <[hidden email]> wrote:
Okay there is a listener :
<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <listener>

<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
  </listener>

  <filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

</web-app>

And I am using shiro.ini with the same result (shiro never starting). One
weird thing is that once I run clean|compile|package (using Maven)
target/Project/WEB-INF/web.xml complains that it cannot find ShiroFilter
needs  filter mapping although the file is still:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <listener>

<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
  </listener>

  <filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

</web-app>



--
Sent from: http://shiro-user.582556.n2.nabble.com/



--
Thanks,
-Gautam
Reply | Threaded
Open this post in threaded view
|

Re: Not able to initialize using Tomcat Embedded (7.0.57)

apowell
I do. I added the relevant pieces from the demo app, that is the major cause
of my confusion.



--
Sent from: http://shiro-user.582556.n2.nabble.com/