Grails support for Togglz?

508 views
Skip to first unread message

ron rittinger

unread,
Oct 27, 2014, 10:43:39 AM10/27/14
to togglz...@googlegroups.com
I'd like to add the togglz infrastructure to my grails 2.3.5 project (which uses maven to manage my dependencies).

Is this possible? Can someone provide an example?

ron rittinger

unread,
Oct 28, 2014, 1:16:52 PM10/28/14
to togglz...@googlegroups.com
always getting the same error no matter how I try to configure the FeatureManager:
2014-10-28 13:11:15,236 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver  - IllegalStateException occurred when processing request: 
Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.. Stacktrace follows:
Message: Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.

also creating an implementation of the TogglzBootstrap class:
@Component("togglzBootstrap")
public class TogglzBootstraper implements TogglzBootstrap {
public FeatureManager createFeatureManager(){
return new FeatureManagerBuilder().togglzConfig(new MyTogglzConfiguration()).build();
}

}

Which is called (as I added debug statements within the MyTogglzConfiguration class) but nothing works.

Christian Kaltepoth

unread,
Oct 30, 2014, 4:16:25 AM10/30/14
to togglz...@googlegroups.com
Could you tell us more about your setup. Which dependencies did you add to your project? Did you add anything to web.xml manually?

ron rittinger

unread,
Oct 30, 2014, 8:27:03 AM10/30/14
to togglz...@googlegroups.com
Even though this is a grails project, we use maven to manage our dependencies. The following dependencies are found in my pom:
      • togglz-core
      • togglz-servlet
      • togglz-spring
      • togglz-console
      • togglz-slf4j
Once I adjusted the log level to debug, I see the following in the console:
2014-10-29 15:40:57,154 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No cached FeatureManager for class loader: org.grails.plugins.tomcat.ParentDelegatingClassLoader@42404f33
2014-10-29 15:40:57,157 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - Found 5 FeatureManagerProvider implementations...
2014-10-29 15:40:57,157 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.ThreadLocalFeatureManagerProvider
2014-10-29 15:40:57,162 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.BeanFinderFeatureManagerProvider
2014-10-29 15:40:57,163 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.StaticFeatureManagerProvider
2014-10-29 15:40:57,163 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.ContextClassLoaderFeatureManagerProvider
2014-10-29 15:40:57,163 [http-bio-8080-exec-1] DEBUG context.JNDIFeatureManagerProvider  - FeatureMananger not found: Name [FeatureManager] is not bound in this Context. Unable to find [FeatureManager].
2014-10-29 15:40:57,163 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.JNDIFeatureManagerProvider


I know my 'TogglzConfig' implementation is being loaded by spring as I added a print statement in the no args constructor.

I think the problem is, where Grails loads it's spring beans is not the same place Togglz is looking for them?  I'm looking at the source code for the BeanFinderFeatureManagerProvider class to see how this works.




On Monday, October 27, 2014 10:43:39 AM UTC-4, ron rittinger wrote:

Christian Kaltepoth

unread,
Oct 30, 2014, 2:09:16 PM10/30/14
to togglz...@googlegroups.com
It would be interesting to see what happens in this class:


That's the code that should "find" your Spring managed TogglzBootstrap class.

ron rittinger

unread,
Oct 30, 2014, 2:43:30 PM10/30/14
to togglz...@googlegroups.com
I copied code from Togglz into my controller, the bottom bit is from the SpringBeanFinder and in my Controller, it finds the been.  Below is my code and the output to the console:

The code in the controller (I just used a dummy action to trigger this logic):
Iterator<FeatureManagerProvider> iterator = ServiceLoader.load(FeatureManagerProvider.class).iterator();
while (iterator.hasNext()) {
println "Looking for FeatureManagerProvider="+iterator.next()
}
iterator = ServiceLoader.load(BeanFinder.class).iterator();
while (iterator.hasNext()) {
def beanFinder = iterator.next()
println "found a BeanFinder: $beanFinder"
Collection<FeatureManager> result = beanFinder.find(FeatureManager.class, null);
if (result != null) {
println "Found a featureManager, result=$result"
}
}
iterator = ServiceLoader.load(FeatureManager.class).iterator();
while (iterator.hasNext()) {
println "Looking for FeatureManager="+iterator.next()
}
println "end of our ServiceLoader logic"
def context = servletContext
def clazz = FeatureManager.class
// use the Spring API to obtain the WebApplicationContext
WebApplicationContext applicationContext = null;
Collection<Object> result = new ArrayList<Object>();
if (context instanceof ServletContext) {
applicationContext = WebApplicationContextUtils.getWebApplicationContext((ServletContext) context);
}
if (applicationContext == null) {
applicationContext = ContextLoader.getCurrentWebApplicationContext();
}

// may be null if Spring hasn't started yet
if (applicationContext != null) {

// ask spring about beans of this type
result.addAll(applicationContext.getBeansOfType(clazz).values());

}
println "result=$result"

==================================
and from the console:
==================================
|Loading Grails 2.3.5
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
...............
|Compiling 1 source files
...............................
|Running Grails application
in MyTogglzConfiguration.constructor
in MyTogglzConfiguration.getStateRepository
in MyTogglzConfiguration.getFeatureClass
in MyTogglzConfiguration.getUserProvider
in MyFeatureManagerProvider.constructor
in MyTogglzBootstrapper.constructor
|Server running. Browse to http://localhost:8080/GrailsTest
Looking for FeatureManagerProvider=org.togglz.core.context.ThreadLocalFeatureManagerProvider@6fb15612
Looking for FeatureManagerProvider=org.togglz.core.context.BeanFinderFeatureManagerProvider@4ba294ce
Looking for FeatureManagerProvider=org.togglz.core.context.JNDIFeatureManagerProvider@45984163
Looking for FeatureManagerProvider=org.togglz.core.context.StaticFeatureManagerProvider@562b2efc
Looking for FeatureManagerProvider=org.togglz.core.context.ContextClassLoaderFeatureManagerProvider@25b3a1b4
found a BeanFinder: org.togglz.servlet.spi.ServletContextBeanFinder@25534253
Found a featureManager, result=[]
found a BeanFinder: org.togglz.spring.spi.SpringBeanFinder@278102ae
Found a featureManager, result=[]
end of our ServiceLoader logic
result=[togglz.MyFeatureManager@646fdbc6, togglz.MyFeatureManagerService@433c6c40]
2014-10-30 14:38:58,931 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No cached FeatureManager for class loader: org.grails.plugins.tomcat.ParentDelegatingClassLoader@28f67ca7
2014-10-30 14:38:58,933 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - Found 5 FeatureManagerProvider implementations...
2014-10-30 14:38:58,933 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.ThreadLocalFeatureManagerProvider
2014-10-30 14:38:58,934 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.BeanFinderFeatureManagerProvider
2014-10-30 14:38:58,934 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.StaticFeatureManagerProvider
2014-10-30 14:38:58,934 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.ContextClassLoaderFeatureManagerProvider
2014-10-30 14:38:58,934 [http-bio-8080-exec-1] DEBUG context.JNDIFeatureManagerProvider  - FeatureMananger not found: Name [FeatureManager] is not bound in this Context. Unable to find [FeatureManager].
2014-10-30 14:38:58,934 [http-bio-8080-exec-1] DEBUG context.FeatureContext  - No FeatureManager provided by org.togglz.core.context.JNDIFeatureManagerProvider
Error |
2014-10-30 14:38:58,968 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver  - IllegalStateException occurred when processing request: [GET] /GrailsTest/book/welcome
Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.. Stacktrace follows:
Message: Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.
    Line | Method
->>   49 | getFeatureManager in org.togglz.core.context.FeatureContext
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     20 | isActive          in togglz.MyFeatures
|     69 | doCall . . . . .  in test.BookController$_closure1
|    200 | doFilter          in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter . . . .  in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker         in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run               in java.lang.Thread

ron rittinger

unread,
Oct 30, 2014, 2:50:09 PM10/30/14
to togglz...@googlegroups.com

ron rittinger

unread,
Oct 30, 2014, 2:54:49 PM10/30/14
to togglz...@googlegroups.com
I also tried to supply my own FeatureManagerProvider but using the ServiceLoader within Grails doesn't appear to work.  There is a single post on another forum (and copied elsewhere) where someone complains about this (ServiceLoader not working in grails) but no one has a fix.

If I could use my own FeatureManagerProvider, I think I could get it to work.

Pulling my hair out, I REALLY need this to work as we plan on using the same togglz infrastructure to toggle funtionality on/off in our service and Grails apps.  Thanks a LOT for helping me with this.

Christian Kaltepoth

unread,
Oct 31, 2014, 9:19:06 AM10/31/14
to togglz...@googlegroups.com
Hey,

maybe it helps if I explain some general and important concepts of the inner workings of Togglz. I think this may help to find the root cause of this problem.

The main class in Togglz is the FeatureManager. You have basically three options on how to handle the feature Manager

  1. Let Togglz create and manage the FeatureManager: With this option Togglz will automatically create and instance of FeatureManager and use it for the application. To allow you to tell Togglz about how it should create the FeatureManager, you can provide either an implementation of TogglzConfig or TogglzBootstrap. Togglz will perform this initialization when TogglzFilter.init() gets called by the container. It will then try to find TogglzConfig or TogglzBootstrap using the BeanFinder SPI. In most deployment scenarios Togglz will find Spring managed implementations of these interface and use them for building the FeatureManager.
  2. Let Togglz use an already existing FeatureManager: In this scenario you can use the IoC container of choice (like Spring, CDI, Guice) to manage the lifecycle of the FeatureManager. Togglz will try to find this managed instance and use it instead of creating its own instance. If you are using Spring you can either use 
  3. FeatureManagerFactory if use prefer XML configuration or use FeatureManagerBuilder together with Springs's Java Config style. 
  4. Use a custom strategy to lookup an existing FeatureManager: You can always use a custom strategy to lookup the FeatureManager. To do so just implement a FeatureManagerProvider that obtains the FeatureManager from wherever you want.
In most cases users typically use the first approach. However, there are deployment scenarios for with the first option doesn't work well. Especially if the TogglzFilter is initialized by the container BEFORE Spring starts up. In this case you should try the second option. To force Togglz to skip the creation of its own FeatureManager, you have to set the context parameter org.togglz.FEATURE_MANAGER_PROVIDED to "true". See this page for details:

http://www.togglz.org/documentation/advanced-config.html

I hope this helps a bit.

Christian

ron rittinger

unread,
Oct 31, 2014, 9:43:19 AM10/31/14
to togglz...@googlegroups.com
I tried option #1 first, which is of course the easiest.  I was able to configure my Spring MVC application (provides RESTFul services for my Grails app) in under 5 minutes.  Had Togglz installed, configured (all I did was add a MyFeatures and MyTogglzConfig class) and it worked.

I tried the same with Grails but Togglz can't find MyTogglzConfig class even though I know it was loaded by the Spring underpinnings found in Grails.I think it has something do with different contexts or class loaders or something like that.

Once the easy path failed, I tried everything else I could think of but it's always the same problem.  The togglz infrastructure can't find any Spring beans within Grails.

I don't think it's a togglz problem really, more likely something Grails is doing wrong or slightly different from a pure Spring (no Grails) implementation.

As a result, I'm punting.  I'm going to configure togglz in my Spring MVC App and make a separate, custom REST call from my Grails app to obtain the togglz data.  I'l have to implement my own toggling tag libs/if checks/etc.

PS> it would be great if you created a Togglz plugin for Grails.  Grails has at least two other "toggling" plugins but Togglz is much more robust (nice console and different persistence options).  I'd be happy to help you test it!

Thanks for all your help.

Christian Kaltepoth

unread,
Nov 1, 2014, 7:13:54 AM11/1/14
to togglz...@googlegroups.com
Hey,

I don't think there will be a Grails integration module without some kind of community contribution in the near future. Especially because I'm not familiar with Grails. However, any kind of contribution is welcome.

But I really think that your problem with the Togglz + Grails integration is caused by the fact that the SpringBeanFinder cannot find the current WebApplicationContext. It looks like this line doesn't work:


This works fine in a standard Spring environment. I've no idea why it doesn't work for your app. However, I'm really sure that there is a way to get the ApplicationContext in Grails. I just did some research and it looks like something like this _could_ work:

ApplicationContext context = GrailsWebUtil.currentApplication().getMainContext();

So you could try to create a custom BeanFinder similar to the SpringBeanFinder and use this code to lookup the ApplicationContext. If this works, this would be a perfect first feature for a Grails integration module. ;)

Christian


ron rittinger

unread,
Nov 6, 2014, 10:38:21 AM11/6/14
to togglz...@googlegroups.com
I'm unable to integrate togglz into my "real" spring project as well.  I'm able to integrate toggles in a clean, simple Spring project but anymore more complicated and something is getting in the way.  Below is from my logs from my working example:
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - Found 5 FeatureManagerProvider implementations...
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - No FeatureManager provided by org.togglz.core.context.ThreadLocalFeatureManagerProvider
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - No FeatureManager provided by org.togglz.core.context.BeanFinderFeatureManagerProvider
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - No FeatureManager provided by org.togglz.core.context.StaticFeatureManagerProvider
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - No FeatureManager provided by org.togglz.core.context.ContextClassLoaderFeatureManagerProvider
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - FeatureMananger not found: Name [FeatureManager] is not bound in this Context. Unable to find [FeatureManager].
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - No FeatureManager provided by org.togglz.core.context.JNDIFeatureManagerProvider
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - Could not find any existing FeatureManager
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - Starting FeatureManager bootstrap process
DEBUG [localhost-startStop-1] (AbstractBeanFactory.java:246) - Returning cached instance of singleton bean 'myTogglzConfig'
DEBUG [localhost-startStop-1] (Slf4jLogProvider.java:42) - FeatureManager has been created: FeatureManager[MyFeatures]

notice the "Starting FeatureManager bootstrap process".  The FeatureManagerProviders are unable to find a custom feature manager (which is correct) and a default one is created for me, which is what I want.  And it works.

Below is from my Spring application that does not work:
2014-11-06 10:34:12,943 DEBUG [org.togglz.core.context.FeatureContext] - Found 5 FeatureManagerProvider implementations...
2014-11-06 10:34:12,943 DEBUG [org.togglz.core.context.FeatureContext] - No FeatureManager provided by org.togglz.core.context.ThreadLocalFeatureManagerProvider
2014-11-06 10:34:12,948 DEBUG [org.togglz.core.context.FeatureContext] - No FeatureManager provided by org.togglz.core.context.BeanFinderFeatureManagerProvider
2014-11-06 10:34:12,948 DEBUG [org.togglz.core.context.FeatureContext] - No FeatureManager provided by org.togglz.core.context.StaticFeatureManagerProvider
2014-11-06 10:34:12,948 DEBUG [org.togglz.core.context.FeatureContext] - No FeatureManager provided by org.togglz.core.context.ContextClassLoaderFeatureManagerProvider
2014-11-06 10:34:12,948 DEBUG [org.togglz.core.context.JNDIFeatureManagerProvider] - FeatureMananger not found: Name [FeatureManager] is not bound in this Context. Unable to find [FeatureManager].
2014-11-06 10:34:12,948 DEBUG [org.togglz.core.context.FeatureContext] - No FeatureManager provided by org.togglz.core.context.JNDIFeatureManagerProvider
2014-11-06 10:34:12,950 DEBUG [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] - Resolving exception from handler [public

and an exception is thrown.

Why isn't the bootstrap process happening?

ron rittinger

unread,
Nov 6, 2014, 3:38:39 PM11/6/14
to togglz...@googlegroups.com
Sorry that I'm a bit off topic now as I can't get it to work in a working, more complex, Spring MVC application.

Would it be possible to get some more logging added to the startup process of togglz?

I never see this output in my log: Togglz 2.0.1.Final started

More logging in the TogglzFilter and bootstrapping process would be very helpful.

I'm in a web 3.0 container, yet the TogglzFilter does not appear to be loaded.


On Monday, October 27, 2014 10:43:39 AM UTC-4, ron rittinger wrote:

Christian Kaltepoth

unread,
Nov 10, 2014, 11:26:45 AM11/10/14
to togglz...@googlegroups.com
Could you please post the full stacktrace you are getting? It would be interesting to see _what_ is triggering the first feature manager lookup...

ron rittinger

unread,
Nov 10, 2014, 2:34:31 PM11/10/14
to togglz...@googlegroups.com
Below is the stacktrace when I hit the following test code:
if( MyFeatures.FEATURE_ONE.isActive()){
System.out.println("Feature one is active");
}

Up until this point, the log contains no errors.

2014-11-10 14:26:28,384 DEBUG [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] - Invoking @ExceptionHandler method: public org.springframework.http.ResponseEntity<?> com.elsevier.aesvc.ErrorHandler.handleException(java.lang.Exception)
java.lang.IllegalStateException: Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.
at org.togglz.core.context.FeatureContext.getFeatureManager(FeatureContext.java:49)
at togglz.MyFeatures.isActive(MyFeatures.java:18)
at com.elsevier.aesvc.config.country.v1.CountryController.getCountryList(CountryController.java:203)
at com.elsevier.aesvc.config.country.v1.CountryController$$FastClassByCGLIB$$8ae27989.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:51)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.elsevier.aesvc.aop.SecurityAspect.security(SecurityAspect.java:149)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.elsevier.aesvc.config.country.v1.CountryController$$EnhancerByCGLIB$$c5e9732c.getCountryList(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter.doFilter(AbstractPreAuthenticatedProcessingFilter.java:94)
at com.elsevier.aesvc.security.filter.AEPreAuthenticatedProcessingFilter.doFilter(AEPreAuthenticatedProcessingFilter.java:82)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.elsevier.aesvc.slae.ipaccess.filter.AESvcIPFilter.doFilter(AESvcIPFilter.java:171)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.elsevier.aesvc.filter.AESvcLoggingContextFilter.doFilter(AESvcLoggingContextFilter.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

The TogglzFilter is never initialized. There is no reference to the TogglzFilter in the log before this point.

I am using a web 3.0 servlet container, but as a test I added the changes to my web.xml file per your installation instructions.  I get a different error on startup.
Nov 10, 2014 2:33:51 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter TogglzFilter
java.lang.IllegalStateException: Could not find any implementation of TogglzConfig or TogglzBootstrap. Please make sure that you have added the required integration modules to your project or register the implementation in your web.xml as described in the 'Configuration' chapter of the documentation.
at org.togglz.core.bootstrap.FeatureManagerBootstrapper.createFeatureManager(FeatureManagerBootstrapper.java:73)
at org.togglz.servlet.TogglzFilter.init(TogglzFilter.java:72)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4656)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5309)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Nov 10, 2014 2:33:51 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Nov 10, 2014 2:33:51 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/ae/config] startup failed due to previous errors
2014-11-10 14:33:51,462 INFO [com.elsevier.aesvc.filter.AESvcLoggingContextFilter] - AESvcLoggingContextFilter: destroy (should only happen on shutdown)
2014-11-10 14:33:51,462 INFO [com.elsevier.aesvc.slae.ipaccess.filter.AESvcIPFilter] - AESvcIPFilter: destroy (should only happen on shutdown)
2014-11-10 14:33:51,462 INFO [SmapiDebug] - SMAPI J2eeInitializer terminating
2014-11-10 14:33:51,462 DEBUG [SmapiDebug] - Notification timestamp = 14:33:51:462, Current Date = 14:33:51:462
2014-11-10 14:33:51,463 INFO [SmapiDebug] - JMXAgent stopping
2014-11-10 14:33:51,464 WARN [SmapiDebug] - SysmanInitializer: terminate complete
Nov 10, 2014 2:33:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.XmlWebApplicationContext).
log4j:WARN Please initialize the log4j system properly.
[EL Config]: connection: 2014-11-10 14:33:51.514--ServerSession(39724588)--Connection(1035850785)--Thread(Thread[localhost-startStop-1,5,main])--disconnect
[EL Info]: connection: 2014-11-10 14:33:51.515--ServerSession(39724588)--Thread(Thread[localhost-startStop-1,5,main])--file:/C:/Data/eclipse/CHIEF/master/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/AEConfigSvc/WEB-INF/classes_AESvcSysConfig-PU logout successful
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/ae/config] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/ae/config] appears to have started a thread named [Thread-1] but has failed to stop it. This is very likely to create a memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/ae/config] appears to have started a thread named [MultiThreadedHttpConnectionManager cleanup] but has failed to stop it. This is very likely to create a memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/ae/config] appears to have started a thread named [SLAEClientThread] but has failed to stop it. This is very likely to create a memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ae/config] created a ThreadLocal with key of type [org.apache.axiom.util.UIDGenerator$1] (value [org.apache.axiom.util.UIDGenerator$1@6b5d991]) and a value of type [long[]] (value [[J@cdec208]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ae/config] created a ThreadLocal with key of type [com.sun.xml.bind.v2.ClassFactory$1] (value [com.sun.xml.bind.v2.ClassFactory$1@7494a1d1]) and a value of type [java.util.WeakHashMap] (value [{class com.elsevier.webservices.schemas.ae.runtimesvc.types.v4.ContentType=java.lang.ref.WeakReference@4a0bdc22, class com.elsevier.webservices.schemas.ae.runtimesvc.types.v4.AEStatusType=java.lang.ref.WeakReference@50a16228, class com.elsevier.webservices.schemas.ae.runtimesvc.types.v4.GetContentTypesRspPayloadType=java.lang.ref.WeakReference@13335973, class com.elsevier.webservices.schemas.easi.headers.types.v1.ResponseHeaderType=java.lang.ref.WeakReference@103596de, class com.elsevier.webservices.schemas.ae.runtimesvc.types.v4.GetContentTypesResponseType=java.lang.ref.WeakReference@2e43d122, class java.util.ArrayList=java.lang.ref.WeakReference@665726e8, class javax.xml.bind.annotation.W3CDomHandler=java.lang.ref.WeakReference@63bb7dd5}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ae/config] created a ThreadLocal with key of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value [com.sun.xml.bind.v2.runtime.Coordinator$1@2a425e1a]) and a value of type [com.sun.xml.bind.v2.runtime.Coordinator[]] (value [[Lcom.sun.xml.bind.v2.runtime.Coordinator;@6b3012a2]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ae/config] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@211780a8]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ae/config] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@dffa691]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Nov 10, 2014 2:33:51 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ae/config] created a ThreadLocal with key of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value [com.sun.xml.bind.v2.runtime.Coordinator$1@2a425e1a]) and a value of type [com.sun.xml.bind.v2.runtime.Coordinator[]] (value [[Lcom.sun.xml.bind.v2.runtime.Coordinator;@b1080c5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Nov 10, 2014 2:33:51 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8180"]
Nov 10, 2014 2:33:51 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8109"]
Nov 10, 2014 2:33:51 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 84362 ms
Nov 10, 2014 2:33:54 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load com.ctc.wstx.compat.QNameCreator.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1599)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at com.ctc.wstx.sr.NsInputElementStack.getCurrentElementName(NsInputElementStack.java:652)
at com.ctc.wstx.sr.BasicStreamReader.getName(BasicStreamReader.java:723)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.getName(XMLStreamReaderWrapper.java:120)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.getName(XMLStreamReaderWrapper.java:120)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.logParserState(StAXOMBuilder.java:371)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:244)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:199)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:155)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:89)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:95)
at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:242)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:179)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:578)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:127)
at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:373)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:171)
at com.sun.proxy.$Proxy98.clientUpdate(Unknown Source)
at com.elsevier.webservices.ae.runtime.client.v4.CacheRefreshNotifier.doClientUpdate(CacheRefreshNotifier.java:372)
at com.elsevier.webservices.ae.runtime.client.v4.CacheRefreshNotifier.execute(CacheRefreshNotifier.java:167)
at com.elsevier.webservices.ae.schedule.AESchedule.run(AESchedule.java:36)

Nov 10, 2014 2:33:54 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.apache.axis2.jaxws.ExceptionFactory.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1599)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:583)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:127)
at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:373)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:171)
at com.sun.proxy.$Proxy98.clientUpdate(Unknown Source)
at com.elsevier.webservices.ae.runtime.client.v4.CacheRefreshNotifier.doClientUpdate(CacheRefreshNotifier.java:372)
at com.elsevier.webservices.ae.runtime.client.v4.CacheRefreshNotifier.execute(CacheRefreshNotifier.java:167)
at com.elsevier.webservices.ae.schedule.AESchedule.run(AESchedule.java:36)

ron rittinger

unread,
Nov 11, 2014, 8:40:01 AM11/11/14
to togglz...@googlegroups.com
My latest guess is the web-fragment.xml file is not being loaded in this application or the order of web-fragments (how to tell how many are at play) is for some reason stopping the TogglzFilter of initializing.  I don't see an error in the logs but the debug statements from the TogglzFilter are never displayed in my "real" app, while they are in my simple "test" app.  the big difference: Way more complex web.xml (many filters include Shiro, Spring Security, etc.) and pom.xml.

Christian Kaltepoth

unread,
Nov 11, 2014, 10:58:15 AM11/11/14
to togglz...@googlegroups.com
Hey,

I just had a look at the logs you included in your mail.

In the first example it looks like the TogglzFilter isn't automatically registered via web-fragment.xml. This may be caused by various things:
  • The version attribute on the root element in your web.xml should be "3.0" or newer.
  • The "metadata-complete" attribute on the root element in your web.xml should be either absent or "false".
  • It may be a problem if you have and <absolute-ordering> element in your web.xml.
However, to solve this, you can just register the TogglzFilter manually in your web.xml. That's absolutly OK if your container/configuration should do auto-registration. You can copy&paste the relevant part directly from web-fragment.xml:


In your second example it looks like the TogglzFilter is initialized before Spring has started. Could this be the case? You could check the logs to find clues about this. You could try to change the filter ordering fix this.

Could you perhaps post your web.xml content? This may be helpful to tell you what is wrong.

You could also give #2 a try which I described in my mail sent on 31-Oct. There is also an integration test that covers this setup. Have a look at the test here:


And the two config files used:



Christian

ron rittinger

unread,
Nov 11, 2014, 3:52:30 PM11/11/14
to togglz...@googlegroups.com
The "metadata-complete" attribute was the key!  it is set to true within my web.xml file.  Now I need to find out WHY it was set to true.

thanks so much for your help Christian
...

Christian Kaltepoth

unread,
Nov 12, 2014, 10:17:07 AM11/12/14
to togglz...@googlegroups.com

I'm curious. Did this fix all of your problems or just the auto registration issue?

Reply all
Reply to author
Forward
0 new messages