나는 @Interceptors(SpringBeanAutowiringInterceptor.class)
을 사용하여 EJB에 스프링 빈을 주입하려고하는데, 내가 본 적이있는 beanRefContext.xml
예제로 작업 할 수 없다. 이 콩을 재현하는 대신 기존의 ApplicationContext를 얻는 것 같다,EJB3에 스프링 빈 삽입하기
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="...">
<!-- Have also tried with ClassPathXmlApplicationContext -->
<bean id="context"
class="org.springframework.web.context.support.XmlWebApplicationContext">
<property name="configLocations" value="/config/app-config.xml" />
</bean>
</beans>
그러나 다음과 같이 나는 beanRefContext.xml로를 제공 한
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class AlertNotificationMethodServiceImpl implements
AlertNotificationMethodService {
@Autowired
private SomeBean bean;
}
:
여기 내 EJB입니다. 내 콩 중 하나가 ServletContextAware이기 때문에 다음 예외로 끝납니다.
java.lang.IllegalArgumentException: Cannot resolve ServletContextResource
without ServletContext
는 ApplicationContext를을 얻기 대신 새로 만들 안의 SpringBeanAutowiringInterceptor
를 사용하는 경우?
또한 contextConfigLocation이 beanRefContext.xml을 가리 키도록 내 web.xml을 변경해 보았습니다. Spring 구성을로드해야하지만 위와 같은 예외가 발생하기를 바랍니다.
누구든지 올바르게 수행하는 방법을 알고 있습니까? 내가 본 예제는 내가 사용하고있는 것과 같은 방법을 사용하는 것으로 보이는데, 이는 인터셉터가 호출 될 때 빈이 다시 만들어지고 있다는 것을 의미합니다 (또는 그것이 작동하는 방법과 오해했습니다).
전체 프로세스를 설명하는 유용한 링크 : http://techo-ecco.com/blog/spring-application-context-hierarchy-and-contextsingletonbeanfactorylocator/ – omartin