Good day. The situation is this - there is a Tomcat, Alfresco ( ECM ) and BIRT (reports) are spinning on it. It is necessary to make it so that from the modules (jar) or pages (jsp) of BIRT you can have access to the “services” of Alfresco (in simple terms: they provide access to different types of ECM repository data). Alfresco uses the Spring Framework . There is a java-class that receives the current servlet (BIRT).
public void initialize(HttpServlet servlet) { servletContext = servlet.getServletContext(); }
I am trying to access the bean as follows:
ServletContext alfrescoWebContext = servletContext.getContext("/alfresco"); WebApplicationContext alfrescoSpringContext = WebApplicationContextUtils .getWebApplicationContext(alfrescoWebContext); // serviceRegistry объект типа ServiceRegistry - относится к API Alfresco serviceRegistry = (ServiceRegistry) AlfrescoSpringContext .getBean(ServiceRegistry.SERVICE_REGISTRY);
When you try to work the same way, the following crashes:
java.lang.IllegalStateException: Context attribute is not of type WebApplicationContext: Root WebApplicationContext: startup date [Thu Aug 01 10:01:04 MSK 2013]; root of context hierarchy
The project structure is as follows:
tomcat |_ webapps |_ alfresco |_ birt
How to solve this? Maybe there is another way?
============================================
The question was solved by pulling the attributes out of context, thanks @Barmaley for the tip.