Hi all. I am fairly new to Spring, mostly relying on the Spring in Action book to get started. I followed a design that uses a BeanNameAutoProxyCreator (pp. 124-6 for those with the book). I am trying to get cross-cutting logging working, but I get the subject error and don't see what it's referring to. Files included below. Any help would be greatly appreciated...Mark
--- applicationContext-services.xml (portion) ---
<!-- =============== Logging advice ==================== -->
<!-- this pointcut will apply to any method of any Class that ends with “Manager”
(i.e. all service layer classes) -->
<bean id="methodLoggingInterceptor" name="methodLoggingInterceptor" class="com.labcorp.cels.pla.common.logging.MethodL oggingInterceptor"/>
<bean id="methodLoggingProxyCreator" name="methodLoggingProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator"/>
<bean>
<property name="beanNames">
<list>
<value>*Manager</value>
</list>
</property>
<property name="interceptorNames">
<value>methodLoggingInterceptor</value>
</property>
</bean>
--- MethodLoggingInterceptor ---
/**
*
*/
package com.labcorp.cels.pla.common.logging;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
/**
*
* @author lorenzm
*/
public class MethodLoggingInterceptor implements MethodInterceptor {
private static Logger log = Logger.getLogger("pla-service");
/**
* Constructor
*/
public MethodLoggingInterceptor() {
// nothing to do on construction...
}
/* (non-Javadoc)
* @see org.aopalliance.intercept.MethodInterceptor#invoke (org.aopalliance.intercept.MethodInvocation)
*/
public Object invoke(MethodInvocation invocation) throws Throwable {
if( log.isEnabledFor(Level.INFO) ) {
StringBuffer sb = new StringBuffer(invocation.getClass() + "." + invocation.getMethod()
+ " called with: [");
Object[] args = invocation.getArguments();
for(int i = 0; i < invocation.getArguments().length; i++) {
Object o = args[i];
sb.append(o);
sb.append((i == args.length - 1) ? "]" : ", ");
}
log.info(sb);
}
return invocation.proceed();
}
}
---- Console -----
ERROR [main] (ContextLoader.java:205) - Context initialization failed
org.springframework.beans.factory.BeanDefinitionSt oreException:
Unexpected exception parsing XML document from class path resource [applicationContext-services.xml];
nested exception is org.springframework.beans.factory.BeanDefinitionSt oreException: Error registering bean with name '' defined in class path resource [applicationContext-services.xml]: Unnamed bean definition specifies neither 'class' nor 'parent' nor 'factory-bean' - can't generate bean name


Reply With Quote