한참을... 헤매고.. 찾아봐도 문제가 어디부터 시작되는지 몰라서 여쭤봅니다.
환경은 struts2(2.3.1.2), spring(3.1.1.RELEASE), java 1.5, weblogic 10.0 이며
1)root applicationContext로
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/config/applicationContext.xml
/WEB-INF/classes/config/applicationContext-jdbc.xml
/WEB-INF/classes/config/spr_appCntx_common.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2)servlet context 는
<servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/config/total-applicationContext.xml
</param-value>
</init-param>
</servlet>
<beans xmlns="
http://www.springframework.org/schema/beans"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="
http://www.springframework.org/schema/context"
xmlns:aop="
http://www.springframework.org/schema/aop"
xmlns:tx="
http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" >
<context:component-scan base-package="com.my.package" />
<aop:aspectj-autoproxy />
...(생략)
</beans>
와 같이 설정된 상황입니다.
기존에 사용중인 transactionProxy 가 존재하는데. root applicationContext 상에 아래와 같이 있습니다.
<bean id="CommAroundAdvice" class="com.my.finehr.common.CommonAroundAdvice"/>
<!-- Common Advisor pointcut definition for around advice -->
<bean id="CommAroundAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref bean="CommAroundAdvice"/>
</property>
<property name="pattern">
<value>.*</value>
</property>
</bean>
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="transactionAttributes">
<props>
<prop key="retrieve*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="select*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="aut_chk">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,-NullPointerException,-DataAccessException,-BizException,+AuthException</prop>
</props>
</property>
<property name="preInterceptors">
<list>
<ref bean="CommAroundAdvisor"/>
</list>
</property>
</bean>
=================================
여기서...질문 입니다.
servlet context 에 aop 태그를 사용한 proxy 적용을 하고 싶은데.
<aop:aspectj-autoproxy /> 태그 적용 시 @Aspect annotation을 사용한 클래스를 찾는게 아닌.
root applicationContext 상의 CommAroundAdvisor 를.. 찾게 되네요.
클래스 코드는 아래와 같으며.
package com.my.total.common.aop;
import ...(생략)
@Aspect
@Component
public class SessionAspect {
@Pointcut("execution(* *(..))")
private void all() {}
@Around("all()")
public Object logJoinPoint(ProceedingJoinPoint pointCut) throws Throwable {
System.out.println("AOP 1 단계 ===========================================");
Object ret = null;
try {
ret = pointCut.proceed();
} catch (AuthException ex) {
System.out.println("야야야야야야 CommonAdvice 싫어!!!!");
}
System.out.println("===========================================AOP 1 단계 끝");
return ret;
}
}
위 와 같은 상황에서 실행 시 오류내용은 아래와 같습니다.
<2013. 2. 27 오후 5시 11분 09초 KST> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@169be56 - appName: 'fineHR', name: 'null', context-path: ''] Root cause of ServletException.
java.lang.reflect.UndeclaredThrowableException
at $Proxy368.toString(Unknown Source)
at java.lang.String.valueOf(String.java:2615)
at java.lang.StringBuilder.append(StringBuilder.java:116)
at org.springframework.web.servlet.DispatcherServlet.initLocaleResolver(DispatcherServlet.java:488)
at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:439)
Truncated. see log file for complete stacktrace
com.my.finehr.common.AuthException: 로그인 되어 있지 않습니다.
at com.my.finehr.common.CommonAroundAdvice.invoke(CommonAroundAdvice.java:48)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
Truncated. see log file for complete stacktrace
>
ㅠ.ㅠ.. 문제 원인부터 파악 할수 있었으면 좋겠네요..