Thanks for letting us know Pete!  Hopefully this helps someone else
until the Jetty team can fix that feature in the 9.x release.

Best,
--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282


On Tue, Apr 16, 2013 at 7:40 PM, Pete Poulos <[email protected]> wrote:
> Alright, so I switched to version 8 of the jetty-maven-plugin and everything
> is working now.  It appears that jetty 9 doesn't reload
> ServletContextListeners correctly at this time.
>
>  Thanks for prompting me to spend a little more time with this Les
> (sometimes all it takes is a nudge) :)
>
> Pete
>
>
> On Tue, Apr 16, 2013 at 7:50 PM, Pete Poulos <[email protected]> wrote:
>>
>> Hi Les,
>>
>> Thanks for getting back to me.  Your reply prompted me to dink around with
>> this a bit more.  I just created a stub ServletContextListener to see
>> whether jetty calls "contextInitialized" again after it recreates the
>> WebEnvironment during a reload and it appears that the
>> ServletContextListener.contextDestroyed(ServletContextEvent) gets called,
>> but that ServletContextListener.contextInitialized(ServletContextEvent) is
>> not called again.
>>
>> That being the case, I think it's safe to assume, for now, that this is a
>> jetty issue and not a Shiro issue.  I'll be sure to post any work around I
>> find here in case someone else comes across this problem in the future.
>>
>>
>> On Tue, Apr 16, 2013 at 7:24 PM, Les Hazlewood <[email protected]>
>> wrote:
>>>
>>> Hi Pete,
>>>
>>> Did you figure out what was happening here?
>>>
>>> Shiro's default web integration requires a WebEnvironment instance be
>>> present in the ServletContext.  This is referenced by the ShiroFilter at
>>> runtime.  It appears that the WebUtils.getRequiredWebEnvironment is not
>>> finding the expected WebEnvironment instance.  Perhaps Jetty is wiping out
>>> the ServletContext and creating a new one without Shiro's knowledge?
>>>
>>> --
>>> Les Hazlewood | @lhazlewood
>>> CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
>>>
>>>
>>> On Tue, Mar 26, 2013 at 11:08 AM, Pete Poulos <[email protected]>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm not sure if this is a jetty issue or an issue with shiro, but I am
>>>> trying to use the Jetty-Maven plugin for development and one of the
>>>> key features I want is Jetty's hot redeployment when files are
>>>> changed. However, Shiro is throwing the following exception when jetty
>>>> attempts to reload the application and I am not certain what can be
>>>> done to correct this.
>>>>
>>>> [Scanner-0] ERROR org.apache.shiro.web.servlet.AbstractFilter - Unable
>>>> to start Filter: [No WebEnvironment found: no
>>>> EnvironmentLoaderListener registered?].
>>>> java.lang.IllegalStateException: No WebEnvironment found: no
>>>> EnvironmentLoaderListener registered?
>>>>         at
>>>> org.apache.shiro.web.util.WebUtils.getRequiredWebEnvironment(WebUtils.java:276)
>>>>         at
>>>> org.apache.shiro.web.servlet.ShiroFilter.init(ShiroFilter.java:73)
>>>>         at
>>>> org.apache.shiro.web.servlet.AbstractShiroFilter.onFilterConfigSet(AbstractShiroFilter.java:152)
>>>>         at
>>>> org.apache.shiro.web.servlet.AbstractFilter.init(AbstractFilter.java:97)
>>>>         at
>>>> org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:123)
>>>>         at
>>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
>>>>         at
>>>> org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:732)
>>>>         at
>>>> org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:279)
>>>>         at
>>>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1314)
>>>>         at
>>>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:722)
>>>>         at
>>>> org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
>>>>         at
>>>> org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:275)
>>>>         at
>>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
>>>>         at
>>>> org.eclipse.jetty.maven.plugin.JettyRunMojo.restartWebApp(JettyRunMojo.java:527)
>>>>         at
>>>> org.eclipse.jetty.maven.plugin.JettyRunMojo$1.filesChanged(JettyRunMojo.java:481)
>>>>         at
>>>> org.eclipse.jetty.util.Scanner.reportBulkChanges(Scanner.java:676)
>>>>         at
>>>> org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:539)
>>>>         at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
>>>>         at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
>>>>         at java.util.TimerThread.mainLoop(Timer.java:555)
>>>>         at java.util.TimerThread.run(Timer.java:505)
>>>>
>>>> My web.xml looks like the following:
>>>>
>>>> <?xml version="1.0" ?>
>>>> <web-app xmlns="http://java.sun.com/xml/ns/j2ee";
>>>>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>>>     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>>>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
>>>>     version="2.4">
>>>>
>>>>     <!-- SHIRO CONFIGURATION
>>>> ============================================== -->
>>>>
>>>>     <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>
>>>>
>>>>     <!-- DATA SOURCE
>>>> ====================================================== -->
>>>>
>>>>     <resource-ref>
>>>>         <description>Account Data Source</description>
>>>>         <res-ref-name>jdbc/AccountDB</res-ref-name>
>>>>         <res-type>javax.sql.DataSource</res-type>
>>>>         <res-auth>Container</res-auth>
>>>>     </resource-ref>
>>>>
>>>> </web-app>
>>>>
>>>>
>>>> And finally, here is the relevant portion of my maven pom file:
>>>>
>>>>
>>>>   <build>
>>>>     <plugins>
>>>>         <plugin>
>>>>                 <groupId>org.eclipse.jetty</groupId>
>>>>                 <artifactId>jetty-maven-plugin</artifactId>
>>>>                 <version>9.0.0.RC2</version>
>>>>                 <configuration>
>>>>                         <jettyXml>src/jetty/jetty.xml</jettyXml>
>>>>                         <scanIntervalSeconds>1</scanIntervalSeconds>
>>>>                         <webApp>
>>>>                                 <contextPath>/</contextPath>
>>>>
>>>> <overrideDescriptor>src/jetty/override-web.xml</overrideDescriptor>
>>>>                         </webApp>
>>>>                 </configuration>
>>>>                 <dependencies>
>>>>                         <dependency>
>>>>                                 <groupId>mysql</groupId>
>>>>
>>>> <artifactId>mysql-connector-java</artifactId>
>>>>                                 <version>5.1.24</version>
>>>>                         </dependency>
>>>>                 </dependencies>
>>>>         </plugin>
>>>>     </plugins>
>>>
>>>
>>
>

Reply via email to