PDA

View Full Version : PerformanceMonitorInceptor



chenrici
Jul 15th, 2005, 04:42 AM
i want to monitor different implementations of the same interface.
using the PerformanceMonitorInterceptor i am getting"only" the name of Interface logged.
Is it in any way possible to get the name of the implementing class?

best thanx for any advice.
Christoph

robh
Jul 15th, 2005, 10:58 AM
Christoph,

Can you post the configuration you are using to define the monitored proxies along with snippets of code for the objects being proxied.

Rob

chenrici
Jul 15th, 2005, 12:17 PM
Rob,

here a snippet from my configuration:


<bean id="rabattDao" class="com.apgsga.vk.preisermittlung.db.RabattDaoImpl">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>
<bean id="monitoredrabattDao"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.apgsga.vk.preisermittlung.db.ContextLoadingDao</value>
</property>
<property name="target">
<ref local="rabattDao"/>
</property>
<property name="interceptorNames">
<list>
<value>performanceMontitor</value>
</list>
</property>
</bean>

and the performance monitor:


<bean id="performanceMontitor"
class="org.springframework.aop.interceptor.PerformanceMon itorInterceptor">
</bean>

I have different Dao's like the one above (rabattDao) all implementing the same Interface.
My problem is that the name, which is logged is for all the same: the interface they implement.
I would actually like to see the class name of the target.

Christoph

robh
Jul 15th, 2005, 06:22 PM
Christoph,

Try setting the 'proxyTargetClass' property of ProxyFactoryBean to true.

Rob

chenrici
Jul 18th, 2005, 01:58 AM
Hi Rob,

somehow the bean's don't load after setting the proxyTargetClass in the ProxyFactoryBean to true.

I get the following exception stack:


&#91;junit&#93; 1&#41; testService&#40;com.apgsga.vk.preisermittlung.service. BatchServiceInterfaceImplTests&#41;org.springframework .beans.factory.BeanCreationException&#58; Error creating bean with name 'monitoredrabattDao' defined in class path resource &#91;batchtestbeans.xml&#93;&#58; Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException&#58; null
&#91;junit&#93; java.lang.IllegalStateException&#58; Callback Lnet/sf/cglib/proxy/MethodInterceptor; is not assignable to Lnet/sf/cglib/proxy/MethodInterceptor;
&#91;junit&#93; at net.sf.cglib.proxy.Enhancer.validate&#40;Enhancer.java &#58;374&#41;
&#91;junit&#93; at net.sf.cglib.proxy.Enhancer.createHelper&#40;Enhancer. java&#58;399&#41;
&#91;junit&#93; at net.sf.cglib.proxy.Enhancer.create&#40;Enhancer.java&#58;3 18&#41;
&#91;junit&#93; at org.springframework.aop.framework.Cglib2AopProxy.g etProxy&#40;Cglib2AopProxy.java&#58;194&#41;
&#91;junit&#93; at org.springframework.aop.framework.Cglib2AopProxy.g etProxy&#40;Cglib2AopProxy.java&#58;150&#41;
&#91;junit&#93; at org.springframework.aop.framework.ProxyFactoryBean .getSingletonInstance&#40;ProxyFactoryBean.java&#58;256&#41;
&#91;junit&#93; at org.springframework.aop.framework.ProxyFactoryBean .setBeanFactory&#40;ProxyFactoryBean.java&#58;220&#41;
&#91;junit&#93; at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean&#40;AbstractAuto wireCapableBeanFactory.java&#58;349&#41;
&#91;junit&#93; at org.springframework.beans.factory.support.Abstract BeanFactory.getBean&#40;AbstractBeanFactory.java&#58;223&#41;
&#91;junit&#93; at org.springframework.beans.factory.support.Abstract BeanFactory.getBean&#40;AbstractBeanFactory.java&#58;147&#41;
&#91;junit&#93; at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons&#40;Defaul tListableBeanFactory.java&#58;271&#41;
&#91;junit&#93; at org.springframework.context.support.AbstractApplic ationContext.refresh&#40;AbstractApplicationContext.ja va&#58;312&#41;
&#91;junit&#93; at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
&#91;junit&#93; at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
&#91;junit&#93; at org.springframework.test.AbstractSpringContextTest s.loadContextLocations&#40;AbstractSpringContextTests. java&#58;113&#41;
&#91;junit&#93; at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.loadContextLocations&#40;Abstract DependencyInjectionSpringContextTests.java&#58;147&#41;
&#91;junit&#93; at org.springframework.test.AbstractSpringContextTest s.getContext&#40;AbstractSpringContextTests.java&#58;95&#41;
&#91;junit&#93; at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp&#40;AbstractDependencyInjec tionSpringContextTests.java&#58;114&#41;


Probably did something wrong?


<bean id="monitoredlokalDispoPositionenDao"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.apgsga.vk.preisermittlung.db.LokalDispoDao</value>
</property>
<property name="target">
<ref local="lokalDispoPositionenDao"/>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="interceptorNames">
<list>
<value>performanceMontitor</value>
</list>
</property>
</bean>

robh
Jul 18th, 2005, 03:53 AM
Ah, you need to upgrade the version of CGLIB you are using. I've seen that particular error in an older version of CGLIB (can't remember which one exactly). Try using the CGLIB jar pacakged with the latest Spring release.

Rob

chenrici
Jul 18th, 2005, 06:24 AM
I updated the cglib to the newest version. That got me further.
But now i get a null pointer exception on the jdbcTemplate for the second invocation of a dao:


&#91;junit&#93; .com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.KdvtSelektionDaoI mpl.load &#58; 0&#58;00&#58;09.994
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.KdvtSelektionDaoI mpl.load &#58; 0&#58;00&#58;09.994
&#91;junit&#93; jdbcTemplate&#58; null
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.createQuery &#58; 0&#58;00&#58;00.000
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.createQuery &#58; 0&#58;00&#58;00.000
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.AbstractContextCr eatingQueryDaoImpl.getParameterValueMap &#58; 0&#58;00&#58;00.000
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.AbstractContextCr eatingQueryDaoImpl.getParameterValueMap &#58; 0&#58;00&#58;00.000
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - Severe Error&#58; java.lang.NullPointerException
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - Stacktrace&#58;

I have tried different DataSource implementations:

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>oracle.jdbc.OracleDriver</value>
</property>
<property name="url">
<value>jdbc&#58;oracle&#58;thin&#58;@testserver&#58;1521&#58;test1</value>
</property>
<property name="password">
<value>xxxxx</value>
</property>
<property name="username">
<value>vk</value>
</property>
</bean>

All fail. I am not sure, if the problem is restricted to the JdbcTemplate.
I am still debugging, but maybe you saw already something similiar?

chenrici
Jul 18th, 2005, 08:21 AM
Additional information to above:
I construct the JdbcTemplate with the datasource property the afterPropertiesSet Method of a Dao Bean and store it locally.
When i retrieve the JdbcTemplate in the proxied Dao via getter Method it is null. Without the proxy it works fine?

robh
Jul 18th, 2005, 08:32 AM
Can you show the full stack trace and the test code?

Rob

chenrici
Jul 18th, 2005, 09:28 AM
Great thanx Rob for your help.
The log4j console output of the junit run, with debug enabled is quite extensive (1386).
Shall i post it?

Christoph

robh
Jul 18th, 2005, 01:38 PM
Just need the few lines that show the NullPointerException - say 10 lines.

Rob

chenrici
Jul 19th, 2005, 04:18 AM
The stack trace:


&#91;junit&#93; org.springframework.jdbc.datasource.DataSourceTran sactionManager - Using transaction object &#91;org.springframework.jdbc.datasource.DataSourceTra nsactionManager$DataSourceTransactionObject@147358 f&#93;
&#91;junit&#93; org.springframework.jdbc.datasource.DataSourceTran sactionManager - Creating new transaction with name &#91;null&#93;
&#91;junit&#93; org.springframework.jdbc.datasource.DataSourceTran sactionManager - Acquired Connection &#91;org.apache.commons.dbcp.PoolableConnection@12c8fa 8&#93; for JDBC transaction
&#91;junit&#93; org.springframework.jdbc.datasource.DataSourceTran sactionManager - Switching JDBC Connection &#91;org.apache.commons.dbcp.PoolableConnection@12c8fa 8&#93; to manual commit
&#91;junit&#93; org.springframework.transaction.support.Transactio nSynchronizationManager - Bound value &#91;org.springframework.jdbc.datasource.ConnectionHol der@d5eb7&#93; for key &#91;org.apache.commons.dbcp.BasicDataSource@d6a05e &#93; to thread &#91;main&#93;
&#91;junit&#93; org.springframework.transaction.support.Transactio nSynchronizationManager - Initializing transaction synchronization
&#91;junit&#93; com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl$$EnhancerByCGLIB$$a73652c7 - getJdbcTemplate&#40;&#41; &#58; null
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.createQuery &#58; 0&#58;00&#58;00.000
&#91;junit&#93; com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl - Invoking dummy get getParameterValueMap with &#58; com.apgsga.vk.preisermittlung.db.LoaderContext@4a7 df6, parameter&#58; <sprachid> &#58; 1, <mitAnnullationen> &#58; false, <annullationenAb> &#58; null, <nurAktVertragsAbschnitte> &#58; false, <nurPositiverFeedback> &#58; false, <mitOptionen> &#58; false, <pseudoBuchnungen> &#58; false, <flaechenseltyp> &#58; com.apgsga.vk.preisermittlung.service.FlaechenSele ktionsTyp@3, code&#58; 3, type&#58; Faktura, <kdvtId&#40;s&#41;> &#58; 15, 4, 16, 205664, 18, 3, 102864, 12, 102967, 205660, 17, 2, 13, 102968, 6, 308746, 14, 102965, 10, 308655
&#91;junit&#93; com.apgsga.common.utils.PerformanceMonitor - com.apgsga.vk.preisermittlung.db.AbstractContextCr eatingQueryDaoImpl.getParameterValueMap &#58; 0&#58;00&#58;00.000
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - Severe Error&#58; java.lang.NullPointerException
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - Stacktrace&#58;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - com.apgsga.vk.preisermittlung.db.AbstractDaoImpl$Q ueryByIdsWithINClause.execute&#40;AbstractDaoImpl.java &#58;335&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - com.apgsga.vk.preisermittlung.db.AbstractContextCr eatingQueryDaoImpl.load&#40;AbstractContextCreatingQue ryDaoImpl.java&#58;73&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - com.apgsga.vk.preisermittlung.db.LoaderImpl.loadZe ntralDispo&#40;LoaderImpl.java&#58;60&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - com.apgsga.vk.preisermittlung.db.LoaderImpl.load&#40;L oaderImpl.java&#58;51&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl.berechne&#40;BatchingServiceInterface Impl.java&#58;153&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - com.apgsga.vk.preisermittlung.service.BatchService InterfaceImplTests.testService&#40;BatchServiceInterfa ceImplTests.java&#58;49&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Nativ e Method&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknow n Source&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Un known Source&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestCase.runTest&#40;TestCase.java&#58;154 &#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestCase.runBare&#40;TestCase.java&#58;127 &#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestResult$1.protect&#40;TestResult.ja va&#58;106&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestResult.runProtected&#40;TestResult .java&#58;124&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestResult.run&#40;TestResult.java&#58;109 &#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestCase.run&#40;TestCase.java&#58;118&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestSuite.runTest&#40;TestSuite.java&#58;2 08&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestSuite.run&#40;TestSuite.java&#58;203&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestSuite.runTest&#40;TestSuite.java&#58;2 08&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.framework.TestSuite.run&#40;TestSuite.java&#58;203&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.textui.TestRunner.doRun&#40;TestRunner.java&#58;116&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.textui.TestRunner.start&#40;TestRunner.java&#58;172&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - junit.textui.TestRunner.main&#40;TestRunner.java&#58;138&#41;
&#91;junit&#93; com.apgsga.vk.preisermittlung.service.BatchingServ iceInterfaceImpl - Stacktrace finished.

Here the Bean and Proxy configuration:


&#91;junit&#93; org.springframework.beans.CachedIntrospectionResul ts - Getting BeanInfo for class &#91;com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoI mpl&#93;
&#91;junit&#93; org.springframework.beans.CachedIntrospectionResul ts - Caching PropertyDescriptors for class &#91;com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoI mpl&#93;
&#91;junit&#93; org.springframework.beans.CachedIntrospectionResul ts - Found property 'class' of type &#91;java.lang.Class&#93;
&#91;junit&#93; org.springframework.beans.CachedIntrospectionResul ts - Found property 'dataSource' of type &#91;javax.sql.DataSource&#93;
&#91;junit&#93; org.springframework.beans.CachedIntrospectionResul ts - Class &#91;com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoI mpl&#93; is cache-safe
&#91;junit&#93; org.springframework.beans.factory.support.BeanDefi nitionValueResolver - Resolving reference from property 'dataSource' in bean 'auftraegeAgpsFlDao' to bean 'dataSource'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'dataSource'
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - About to invoke write method &#91;public final void com.apgsga.vk.preisermittlung.db.AbstractDaoImpl.s etDataSource&#40;javax.sql.DataSource&#41;&#93; on object of class &#91;com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoI mpl&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Invoked write method &#91;public final void com.apgsga.vk.preisermittlung.db.AbstractDaoImpl.s etDataSource&#40;javax.sql.DataSource&#41;&#93; with value of type &#91;javax.sql.DataSource&#93;
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking BeanPostProcessors before initialization of bean 'auftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking afterPropertiesSet&#40;&#41; on bean with name 'auftraegeAgpsFlDao'
&#91;junit&#93; com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl - datasource in afterProperties set&#58; org.apache.commons.dbcp.BasicDataSource@d6a05e
&#91;junit&#93; com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl - jdbcTemplate in afterProperties set&#58; org.springframework.jdbc.core.JdbcTemplate@193c0cf
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking BeanPostProcessors after initialization of bean 'auftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating shared instance of singleton bean 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Creating instance of bean 'monitoredauftraegeAgpsFlDao' with merged definition &#91;Root bean with class &#91;org.springframework.aop.framework.ProxyFactoryBea n&#93; defined in class path resource &#91;batchtestbeans.xml&#93;&#93;
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking BeanPostProcessors before instantiation of bean 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.core.CollectionFactory - Creating java.util.IdentityHashMap
&#91;junit&#93; org.springframework.beans.CachedIntrospectionResul ts - Using cached introspection results for class &#91;org.springframework.aop.framework.ProxyFactoryBea n&#93;
&#91;junit&#93; org.springframework.beans.factory.support.BeanDefi nitionValueResolver - Resolving reference from property 'target' in bean 'monitoredauftraegeAgpsFlDao' to bean 'auftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.core.CollectionFactory - Creating java.util.LinkedHashSet
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'auftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Converting String to &#91;class &#91;Ljava.lang.String;&#93; using property editor &#91;org.springframework.beans.propertyeditors.StringA rrayPropertyEditor@1576e70&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - About to invoke write method &#91;public void org.springframework.aop.framework.ProxyFactoryBean .setProxyInterfaces&#40;java.lang.String&#91;&#93;&#41; throws java.lang.ClassNotFoundException&#93; on object of class &#91;org.springframework.aop.framework.ProxyFactoryBea n&#93;
&#91;junit&#93; org.springframework.aop.framework.ProxyFactoryBean - Added new aspect interface&#58; com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDao
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Invoked write method &#91;public void org.springframework.aop.framework.ProxyFactoryBean .setProxyInterfaces&#40;java.lang.String&#91;&#93;&#41; throws java.lang.ClassNotFoundException&#93; with value of type &#91;&#91;Ljava.lang.String;&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - About to invoke write method &#91;public void org.springframework.aop.framework.AdvisedSupport.s etTarget&#40;java.lang.Object&#41;&#93; on object of class &#91;org.springframework.aop.framework.ProxyFactoryBea n&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Invoked write method &#91;public void org.springframework.aop.framework.AdvisedSupport.s etTarget&#40;java.lang.Object&#41;&#93; with value of type &#91;java.lang.Object&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Converting String to &#91;boolean&#93; using property editor &#91;org.springframework.beans.propertyeditors.CustomB ooleanEditor@11381e7&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - About to invoke write method &#91;public void org.springframework.aop.framework.ProxyConfig.setP roxyTargetClass&#40;boolean&#41;&#93; on object of class &#91;org.springframework.aop.framework.ProxyFactoryBea n&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Invoked write method &#91;public void org.springframework.aop.framework.ProxyConfig.setP roxyTargetClass&#40;boolean&#41;&#93; with value of type &#91;boolean&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - About to invoke write method &#91;public void org.springframework.aop.framework.ProxyFactoryBean .setInterceptorNames&#40;java.lang.String&#91;&#93;&#41;&#93; on object of class &#91;org.springframework.aop.framework.ProxyFactoryBea n&#93;
&#91;junit&#93; org.springframework.beans.BeanWrapperImpl - Invoked write method &#91;public void org.springframework.aop.framework.ProxyFactoryBean .setInterceptorNames&#40;java.lang.String&#91;&#93;&#41;&#93; with value of type &#91;&#91;Ljava.lang.String;&#93;
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking setBeanFactory on BeanFactoryAware bean 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.aop.framework.ProxyFactoryBean - Configuring advisor or advice 'performanceMontitor'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'performanceMontitor'
&#91;junit&#93; org.springframework.aop.framework.ProxyFactoryBean - Adding advisor or TargetSource &#91;com.apgsga.common.utils.PerformanceMonitor@7f4 ec&#93; with name &#91;performanceMontitor&#93;
&#91;junit&#93; org.springframework.aop.framework.ProxyFactoryBean - Adding advisor with name &#91;performanceMontitor&#93;
&#91;junit&#93; org.springframework.aop.framework.ProxyFactoryBean - Not refreshing target&#58; bean name not specified in interceptorNames
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Creating CGLIB2 proxy for &#91;com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoI mpl&#93;
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public com.apgsga.vk.preisermittlung.db.AbstractDaoImpl$A bstractQuery com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.createQuery&#40;org.springframework.jdbc.core.JdbcT emplate,com.apgsga.vk.preisermittlung.db.LoaderCon text&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateSqlBlockFromParameter&#40;com.apgsga.vk.pre isermittlung.db.LoaderContext,java.lang.StringBuff er&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateSqlBlockForAg&#40;com.apgsga.vk.preisermitt lung.db.LoaderContext,java.lang.StringBuffer&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateAnnullationsBlkFuerAg&#40;com.apgsga.vk.pre isermittlung.db.LoaderContext,java.lang.StringBuff er&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateSqlBlockForAgps&#40;com.apgsga.vk.preisermi ttlung.db.LoaderContext,java.lang.StringBuffer&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateAnnullationsBlkFuerAgps&#40;com.apgsga.vk.p reisermittlung.db.LoaderContext,java.lang.StringBu ffer&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateSqlBlockForFlzo&#40;com.apgsga.vk.preisermi ttlung.db.LoaderContext,java.lang.StringBuffer&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public void com.apgsga.vk.preisermittlung.db.KdvtAgAgpsFlDaoIm pl.generateAnnullationsBlkFuerFlzo&#40;com.apgsga.vk.p reisermittlung.db.LoaderContext,java.lang.StringBu ffer&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public java.util.Map com.apgsga.vk.preisermittlung.db.AbstractContextCr eatingQueryDaoImpl.getParameterValueMap&#40;com.apgsga .vk.preisermittlung.db.LoaderContext&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public native int java.lang.Object.hashCode&#40;&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Found equals&#40;&#41; method - using INVOKE_EQUALS
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Unable to apply any optimisations to advised method public java.lang.String java.lang.Object.toString&#40;&#41; - using AOP_PROXY
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract int org.springframework.aop.framework.Advised.indexOf&#40; org.springframework.aop.Advisor&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract org.springframework.aop.TargetSource org.springframework.aop.framework.Advised.getTarge tSource&#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract org.springframework.aop.Advisor&#91;&#93; org.springframework.aop.framework.Advised.getAdvis ors&#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.addAdvis or&#40;org.springframework.aop.Advisor&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.addAdvis or&#40;int,org.springframework.aop.Advisor&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.setTarge tSource&#40;org.springframework.aop.TargetSource&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract java.lang.Class&#91;&#93; org.springframework.aop.framework.Advised.getProxi edInterfaces&#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.addAdvic e&#40;int,org.aopalliance.aop.Advice&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.addAdvic e&#40;org.aopalliance.aop.Advice&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.isInterf aceProxied&#40;java.lang.Class&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.removeAd vice&#40;org.aopalliance.aop.Advice&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.removeAd visor&#40;int&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.removeAd visor&#40;org.springframework.aop.Advisor&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.replaceA dvisor&#40;org.springframework.aop.Advisor,org.springf ramework.aop.Advisor&#41; throws org.springframework.aop.framework.AopConfigExcepti on is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract java.lang.String org.springframework.aop.framework.Advised.toProxyC onfigString&#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.isFrozen &#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.isProxyT argetClass&#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract void org.springframework.aop.framework.Advised.setExpos eProxy&#40;boolean&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.aop.framework.Cglib2AopProxy - Method public abstract boolean org.springframework.aop.framework.Advised.isExpose Proxy&#40;&#41; is declared on Advised - using DISPATCH_ADVISED
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking BeanPostProcessors before initialization of bean 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Invoking BeanPostProcessors after initialization of bean 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Calling code asked for FactoryBean instance for name 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'monitoredauftraegeAgpsFlDao'
&#91;junit&#93; org.springframework.beans.factory.support.DefaultL istableBeanFactory - Bean with name 'monitoredauftraegeAgpsFlDao' is a factory bean

robh
Jul 19th, 2005, 04:46 AM
Can you show this method: AbstractDaoImpl$QueryByIdsWithINClause.execute

It looks from the stack trace that this is where the NPE is occuring on line 335

Rob

chenrici
Jul 19th, 2005, 07:54 AM
protected static class QueryByIdsWithINClause extends AbstractQuery {

private final transient String sqlTempl;

private final transient String wherePlceHolder;

protected QueryByIdsWithINClause(final JdbcTemplate jdbtTempl,
final String sqlTempl, final String wherePlceHolder) {
super(jdbtTempl);
this.sqlTempl = sqlTempl;
this.wherePlceHolder = wherePlceHolder;
}

protected Object execute(final QueryParameters paramter) {
final StringBuffer buffer = new StringBuffer();
boolean first = true;
final Iterator it = paramter.getParentKeyMap().mapIterator();
while (it.hasNext()) {
final Number kdvtId = (Number) it.next();
if (first) {
first = false;
} else {
buffer.append(", ");
}
buffer.append(kdvtId.toString());
}
final String sql = sqlTempl.replaceFirst(wherePlceHolder, buffer
.toString());
return jdbcTml.query(sql, paramter.getRsExtractor());
}
}

The npe comes from jdbcTml being null.
jdbcTml is initialized in the constructor of the superclass:


protected static abstract class AbstractQuery &#123;

/**
* Logger available to subclasses.
*/
protected final Log logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;

protected transient final JdbcTemplate jdbcTml;

protected AbstractQuery&#40;final JdbcTemplate jdbcTml&#41; &#123;
super&#40;&#41;;
this.jdbcTml = jdbcTml;
&#125;

protected abstract Object execute&#40;final QueryParameters parameter&#41;;
&#125;

Both are innerclasses of a abstract superclass of the dao bean, which is proxyed:


public abstract class AbstractDaoImpl implements InitializingBean &#123;

/**
* Logger available to subclasses.
*/
protected final Log logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;

// Kolonnen Namen

protected final static String COL_KDVT_ID = Messages
.getString&#40;"Db.Column.kdvt_id"&#41;;

protected final static String COL_SPRACHE_ID = Messages
.getString&#40;"Db.Column.sprache_id"&#41;;

// Exception Texte

protected final static String EXC_MAPPING = Messages
.getString&#40;"Db.Exception.Mapping"&#41;;

final static String EXC_NULL = Messages.getString&#40;"Db.Exception.Null"&#41;;

private DataSource dataSource;

private JdbcTemplate jdbcTemplate;

/**
*
*/
public AbstractDaoImpl&#40;&#41; &#123;
super&#40;&#41;;
&#125;

/**
* @return Returns the dataSource.
*/
public final DataSource getDataSource&#40;&#41; &#123;
return dataSource;
&#125;

/**
* @param dataSource
* The dataSource to set.
*/
public final void setDataSource&#40;final DataSource dataSource&#41; &#123;
this.dataSource = dataSource;

&#125;

/*
* &#40;non-Javadoc&#41;
*
* @see org.springframework.beans.factory.InitializingBean #afterPropertiesSet&#40;&#41;
*/
final public void afterPropertiesSet&#40;&#41; &#123;
jdbcTemplate = new JdbcTemplate&#40;dataSource&#41;;
doInAfterPropertiesSet&#40;&#41;;
&#125;

protected final JdbcTemplate getJdbcTemplate&#40;&#41; &#123;
return jdbcTemplate;
&#125;

The JdbcTemplate is created in the afterPropertiesSet method of AbstractDaoImpl .

QueryByIdsWithINClause ist created and executed in the proxied Bean:


/*
* &#40;non-Javadoc&#41;
*
* @see com.apgsga.vk.preisermittlung.db.DetailLoadingDao# loadForParents&#40;java.util.Collection&#41;
*/
public final void load&#40;final LoaderContext loaderContext&#41; &#123;

final IterableMap keysMap = getKeysMap&#40;loaderContext&#41;;
final ResultSetExtractor rex = createResultSetExtractor&#40;loaderContext&#41;;
final AbstractQuery theQuery = createQuery&#40;getJdbcTemplate&#40;&#41;,
loaderContext&#41;;
if &#40;theQuery == null&#41; &#123;
return;
&#125;
final QueryParameters qparm = new QueryParameters&#40;keysMap,
loaderContext, rex&#41;;
qparm.add&#40;getParameterValueMap&#40;loaderContext&#41;&#41;;
theQuery.execute&#40;qparm&#41;;
&#125;


The JdbcTemplate is already null in the getJdbcTemplate() method.

chenrici
Aug 15th, 2005, 08:04 AM
Setting "proxyTargetClass" to "true", as Rob suggested, was the solution:

The reason for the NPE, was that the proxied method from the interface of the Bean Class, where final, so CGLIB could'nt subclass them as decribed in the Spring Reference Dokumentation: 5.5.4. Proxying classes.

To see the invoking class - instead of the implementing super class, i had to change the Performance Monitor a bit:


String name = invocation.getThis&#40;&#41;.getClass&#40;&#41;.getName&#40;&#41;
+ "." + invocation.getMethod&#40;&#41;.getName&#40;&#41;;

instead of:


String name = invocation.getMethod&#40;&#41;.getDeclaringClass&#40;&#41;.getName &#40;&#41; + "." + invocation.getMethod&#40;&#41;.getName&#40;&#41;;

chenrici
May 18th, 2006, 04:28 PM
There was an issue with cglib and non public methods.
It "simply" did'nt see them .... as an afterthought probably quite understandable.
So beware using cglib: "what you see is what you get" ;-)