Announcement Announcement Module
Collapse
No announcement yet.
Problem with ProxyFactoryBean Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with ProxyFactoryBean

    I am getting Null pointer exception

    at $Proxy0.getAll(Unknown Source)

    while trying to access Bean through ProxyFactoryBean. However if I directly use Impl class then I am getting all the values etc.

    Here are XML entries


    <bean id="deviceManager" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces" value="com.xyz.jdbc.DeviceManager"/>
    <property name="interceptorNames">
    <list>
    <idref local="transactionInterceptor"/>
    <idref bean="deviceManagerSecurity"/>
    <idref local="deviceManagerTarget"/>
    </list>
    </property>
    </bean>
    <bean id="deviceManagerTarget" class="com.xyz.jdbc.DeviceManagerImpl">
    <property name="deviceDao">
    <bean class="com.xyz.jdbc.DeviceDaoSpring">
    <property name="dataSource" ref="dataSource"/>
    </bean>
    </property>
    <property name="mutableAclService" ref="aclService"/>
    </bean>

    <bean id="contactDataStore" class="com.xyz.domain.ContactDataStore">
    <property name="deviceManager" ref="deviceManager"/>
    </bean>


    Exception details

    [ERROR,ApplicationLifecycleAdvisor,AWT-EventQueue-0]
    java.lang.NullPointerException
    at com.cisco.csm.rbac.ui.ContactView.onApplicationEve nt(ContactView.java:219)
    at org.springframework.context.event.SimpleApplicatio nEventMulticaster$1.run(SimpleApplicationEventMult icaster.java:77)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
    at org.springframework.context.event.SimpleApplicatio nEventMulticaster.multicastEvent(SimpleApplication EventMulticaster.java:75)
    at org.springframework.context.support.AbstractApplic ationContext.publishEvent(AbstractApplicationConte xt.java:246)
    at org.springframework.security.intercept.AbstractSec urityInterceptor.publishEvent(AbstractSecurityInte rceptor.java:492)
    at org.springframework.security.intercept.AbstractSec urityInterceptor.beforeInvocation(AbstractSecurity Interceptor.java:338)
    at org.springframework.security.intercept.method.aopa lliance.MethodSecurityInterceptor.invoke(MethodSec urityInterceptor.java:63)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :166)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:107)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :166)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy0.getAll(Unknown Source)


    I am developing acegi sample app using SpringRichClient and I am using acegi core tiger 1.0.5.

    I would appreciate any help.
    Last edited by sat; Dec 4th, 2007, 05:00 AM.

  • #2
    When posting code, please use [ code][/code ] tags. Next to that your configuration is wrong. You want to add a target, the bean you want to target is not an interceptor!

    Code:
    <property name="interceptorNames">
    <list>
    <idref local="transactionInterceptor"/>
    <idref bean="deviceManagerSecurity"/>
    <idref local="deviceManagerTarget"/>
    </list>
    </property>
    The line in red is your TARGET it isn't an interceptor which should be applied to your TARGET! Also it are interceptorNames not the actuall instances! As another improvement I would suggest registering the target as an anonymous inner bean, this prevents you from getting the wrong (non-proxied) one.

    Which would result in something like this.

    Code:
    <bean id="deviceManager" class="org.springframework.aop.framework.ProxyFactoryBean">
      <property name="proxyInterfaces" value="com.xyz.jdbc.DeviceManager"/>
      <propert name="target">
        <bean class="com.xyz.jdbc.DeviceManagerImpl">
          <property name="deviceDao">
            <bean class="com.xyz.jdbc.DeviceDaoSpring">
              <property name="dataSource" ref="dataSource"/>
            </bean>
          </property>
          <property name="mutableAclService" ref="aclService"/>
        </bean>
      </property>
      <property name="interceptorNames">
        <list>
        <value>transactionInterceptor</value>
        <value>deviceManagerSecurity</value>
      </list>
      </property>
    </bean>
    
    <bean id="contactDataStore" class="com.xyz.domain.ContactDataStore">
      <property name="deviceManager" ref="deviceManager"/>
    </bean>

    Comment


    • #3
      Problem with ProxyFactoryBean

      I am still getting the same exception even with changed configuration

      Code:
         <bean id="deviceManager" class="org.springframework.aop.framework.ProxyFactoryBean">
           <property name="proxyInterfaces" value="com.xyz.jdbc.DeviceManager"/>
           	<property name="target">
           	   <bean class="com.xyz.jdbc.DeviceManagerImpl">
           	      	<property name="deviceDao">
             				<bean class="com.xyz.jdbc.DeviceDaoSpring">
      	       				<property name="dataSource" ref="dataSource"/>
             				</bean>
             			</property>
             			<property name="mutableAclService" ref="aclService"/>
             		</bean>
             	</property>
         	   <property name="interceptorNames">
             <list>
               <idref local="transactionInterceptor"/>
               <idref bean="deviceManagerSecurity"/>
             </list>
           </property>
         </bean>
      
          <bean id="contactDataStore" class="com.xyz.domain.ContactDataStore">
          	<property name="deviceManager" ref="deviceManager"/>
          </bean>
      Exception
      at org.springframework.context.event.SimpleApplicatio nEventMulticaster$1.run(SimpleApplicationEventMult icaster.java:77)
      at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
      at org.springframework.context.event.SimpleApplicatio nEventMulticaster.multicastEvent(SimpleApplication EventMulticaster.java:75)
      at org.springframework.context.support.AbstractApplic ationContext.publishEvent(AbstractApplicationConte xt.java:246)
      at org.springframework.security.intercept.AbstractSec urityInterceptor.publishEvent(AbstractSecurityInte rceptor.java:492)
      at org.springframework.security.intercept.AbstractSec urityInterceptor.beforeInvocation(AbstractSecurity Interceptor.java:328)
      at org.springframework.security.intercept.method.aopa lliance.MethodSecurityInterceptor.invoke(MethodSec urityInterceptor.java:63)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :166)
      at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:107)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :166)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
      at $Proxy0.getAll(Unknown Source)


      This is very much the same from acegi contact sample but somehow I am not able to figure what is missing from my code/xml file

      Here is the configuration from sample contact application
      Code:
         <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
           <property name="proxyInterfaces" value="sample.contact.ContactManager"/>
           <property name="interceptorNames">
             <list>
               <idref local="transactionInterceptor"/>
               <idref bean="contactManagerSecurity"/>
               <idref local="contactManagerTarget"/>
             </list>
           </property>
         </bean>
      
         <bean id="contactManagerTarget" class="sample.contact.ContactManagerBackend">
      	   <property name="contactDao">
             <bean class="sample.contact.ContactDaoSpring">
      	       <property name="dataSource"><ref local="dataSource"/></property>
             </bean>
           </property>
           <property name="mutableAclService" ref="aclService"/>
         </bean>
      Last edited by sat; Dec 4th, 2007, 07:36 AM. Reason: added sample XML

      Comment


      • #4
        As I stated before the interceptorNames are the NAMES of the interceptors NOT the interceptors themselves!!!!!

        Comment

        Working...
        X