AOP 설정에서요...

1,723 views
Skip to first unread message

가마우치

unread,
Mar 24, 2011, 10:08:49 PM3/24/11
to Korea Spring User Group
context:component-scan 으로 설정잡구 작업하는데 ..
AOP 포인트컷 표현식이 잘안되서 낑낑대다가 전체를 한번 걸어 봤는데요...
즉 execution(* *(..)) 이런식으로요...그랬더니 페이지 마다 에러가 빵빵 뜨던데...잘쓰던 DAO 쪽
sqlMapClientTemplate 찾을수 없다고...걍 막막
사실 설정을 이렇게 잡진 않을테니 문제는 없는데요..왜그런지 궁금하네욤....@_@ 혹 아시는분..ㅎㅎ

error creating bean with name
'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0'
defined in file [D:\Web\eclipse\workspace\.metadata\.plugins
\org.eclipse.wst.server.core\tmp2\wtpwebapps\p3Sample\WEB-INF\classes
\conf\dispatcher-servlet.xml]:
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mainController': Injection of resource
dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'UserServiceImpl': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Could not autowire field: p3.sample.web.dao.UserDao
p3.sample.web.service.impl.UserServiceImpl.userDao; nested exception
is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'UserDaoImpl': Injection of autowired
dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: org.springframework.orm.ibatis.SqlMapClientTemplate
p3.sample.web.dao.UserDaoImpl.sqlMapClientTemplate; nested exception
is org.springframework.beans.factory.NoSuchBeanDefinitionException: No
matching bean of type
[org.springframework.orm.ibatis.SqlMapClientTemplate] found for
dependency: expected at least 1 bean which qualifies as autowire
candidate for this dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}

Sanghyuk Jung

unread,
Mar 24, 2011, 10:12:53 PM3/24/11
to ks...@googlegroups.com
jdk proxy로 적용되고 있었다면 AOP 적용한후로는 sqlMapClientTemplate 가 더이상 sqlMapClientTemplate가 아니고 SqlMapClientOperations형인 proxy가 생성되어서 그럴지도 모르겠네요
 
proxy-target-class='true' 하면 될지도 몰라요


 
2011년 3월 25일 오전 11:08, 가마우치 <yabg...@gmail.com>님의 말:

--
Google 그룹스 'Korea Spring User Group' 그룹에 가입했으므로 본 메일이 전송되었습니다.
이 그룹에 게시하려면 ks...@googlegroups.com(으)로 이메일을 보내세요.
그룹에서 탈퇴하려면 ksug+uns...@googlegroups.com로 이메일을 보내주세요.
더 많은 옵션을 보려면 http://groups.google.com/group/ksug?hl=ko에서 그룹을 방문하세요.


가마우치

unread,
Mar 24, 2011, 10:28:25 PM3/24/11
to Korea Spring User Group
ㅎ 추가해봤더니 새로운 에러가 뜨네요... 아예 컨테이너 올릴때 발생하네요...><

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sqlMapClientTemplate' defined in class path
resource [conf/applicationContext.xml]: Cannot resolve reference to
bean 'sqlMapClient' while setting bean property 'sqlMapClient'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlMapClient': Post-processing of the
FactoryBean's object failed; nested exception is
org.springframework.aop.framework.AopConfigException: Could not
generate CGLIB subclass of class [class
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl]: Common causes of this
problem include using a final class or a non-visible class; nested
exception is java.lang.IllegalArgumentException: Superclass has no
null constructors but no arguments were given

On 3월25일, 오전11시12분, Sanghyuk Jung <bene...@gmail.com> wrote:
> jdk proxy로 적용되고 있었다면 AOP 적용한후로는 sqlMapClientTemplate 가 더이상
> sqlMapClientTemplate가 아니고 SqlMapClientOperations형인 proxy가 생성되어서 그럴지도 모르겠네요
>
> proxy-target-class='true' 하면 될지도 몰라요
>
> 2011년 3월 25일 오전 11:08, 가마우치 <yabgar...@gmail.com>님의 말:
> > {...@org.springframework.beans.factory.annotation.Autowired(required=true)}

Sungchul Park

unread,
Mar 24, 2011, 10:39:18 PM3/24/11
to ks...@googlegroups.com
CGLIB로 프락싱하려면 클래스에 인자가 없는 생성자가 있어야 하는 걸로 압니다.
SqlMapClient에 그런 생성자가 없어서 난 오류 같네요.

Sanghyuk Jung

unread,
Mar 24, 2011, 10:41:18 PM3/24/11
to ks...@googlegroups.com, 가마우치
final이라서 CGLIB로 생성해서 덮어쓸 수 없는 부분이 있나보네요.
AOP선언에서 범위를 좁히시는 것이 좋을듯합니다.
아니면 정말 전체 모든 메소드를 AOP로 쓰시고 싶으시다면 아까처럼 jdk-proxy로 돌려놓으시고, 'UserDaoImpl'에서 sqlMapClientTemplate가 아닌 SqlMapClientOperations로 참조하시는 방법도 있습니다. 대부분 AOP선언을 고치는 방법을 쓸 것 같네요

2011년 3월 25일 오전 11:28, 가마우치 <yabg...@gmail.com>님의 말:

arawn

unread,
Mar 24, 2011, 10:43:01 PM3/24/11
to ks...@googlegroups.com
예외를 잘 보시면 아시겠지만..

proxy-target-class='true' 설정으로 CGLIB 을 통해 proxy 를 생성 중
FactoryBean 을 통해 sqlMapClient bean 을 생성할때 proxy 적용이 안되는거 같네요..

AOP 의 제약사항에 대해서 한번 찾아보시구요.

포인터컷은 최소한의 것만 적용하셔야합니다.
한번에 여러개의 조건이 걸리도록 설정하는건 그닥 권장되지 않습니다.


11. 3. 25. 오전 11:28, 가마우치 쓴 글:

가마우치

unread,
Mar 24, 2011, 11:21:00 PM3/24/11
to Korea Spring User Group
휴 역시 쉽지 않네요...오늘 또 많이 알아가네요..답변주신분드 모두 감사요..
Reply all
Reply to author
Forward
0 new messages