HI,I am using the FeatureProxyFactoryBean class toggle between the two service classes below. The code works and the toggle feature works, but I kept on getting the NullPointerException below. It always show up on startup.<bean id="aboutless" class="com.util.AboutProcessLess"/><bean id="aboutmore" class="com.util.AboutProcessMore"/><bean id="about" class="org.togglz.spring.proxy.FeatureProxyFactoryBean"><property name="feature" value="ABOUT_WITHOUT_HOSTNAME" /><property name="active" ref="aboutless" /><property name="inactive" ref="aboutmore" /></bean>
2013-12-03 15:26:34.452 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.BeanUtils - No property editor [org.springframework.data.mongodb.core.WriteResultCheckingEditor] found for type org.springframework.data.mongodb.core.WriteResultChecking according to 'Editor' suffix convention2013-12-03 15:26:34.459 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.b.f.s.DefaultListableBeanFactory - FactoryBean threw exception from getObjectType, despite the contract saying that it should return null if the type of its object cannot be determined yetjava.lang.NullPointerException: nullat org.togglz.spring.proxy.FeatureProxyFactoryBean.getEffectiveProxyType(FeatureProxyFactoryBean.java:77) ~[togglz-spring-2.0.0.Final.jar:na]at org.togglz.spring.proxy.FeatureProxyFactoryBean.getObjectType(FeatureProxyFactoryBean.java:102) ~[togglz-spring-2.0.0.Final.jar:na]at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getTypeForFactoryBean(FactoryBeanRegistrySupport.java:65) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:713) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:523) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:357) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:335) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:322) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1174) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]The problem caused by the method below from the class FeatureProxyFactoryBeanprivate Class<?> getEffectiveProxyType() {// prefer the business interface manually set by the userif (proxyType != null) {return proxyType;}// check which interfaces the both delegates implementsHashSet<Class<?>> activeInterfaces = new HashSet<Class<?>>(Arrays.asList(active.getClass().getInterfaces()));HashSet<Class<?>> inactiveInterfaces = new HashSet<Class<?>>(Arrays.asList(inactive.getClass().getInterfaces()));// build the intersectionactiveInterfaces.retainAll(inactiveInterfaces);// we need exactly one interface to shareif (activeInterfaces.size() != 1) {throw new IllegalArgumentException("The active and the inactive class must share exactly one interface");}return activeInterfaces.iterator().next();}During Spring initialization all the properties in FeatureProxyFactoryBean are nulls. when active.getClass() is called, it caused a NullPointerException.I wonder if anybody have seen this problem?To fix this I have added:package com.util.togglz;import org.togglz.spring.proxy.FeatureProxyFactoryBean;public class MyFeatureProxyFactoryBean extends FeatureProxyFactoryBean{@Overridepublic Class<?> getObjectType(){if (this.getProxyType() == null){return null;}return super.getObjectType();}}and in the xml file I used:<bean id="about" class="com.util.togglz.MyFeatureProxyFactoryBean "><property name="feature" value="ABOUT_WITHOUT_HOSTNAME" /><property name="active" ref="aboutless" /><property name="inactive" ref="aboutmore" /></bean>This fixed the NullPointerException, but is this the best way to solve this?Please advise. Thanks.Don