Q:

Non-managed by Spring web-application and jar file with Spring features

My idea is to create a .jar file that contains Services
managed by Spring, that should be got by getBean()
I want to put it to WEB-INF/lib of a Web-app
Then in web-app Servlets I want to get use of the functionality of a Jar file.
1 Idea. Create classes that encapsulate invokation to Spring Context (getBean() etc)
For example, the class I'll be using will simply get a parameter and return a parameter,
but inside that class there'll be an invocation to Spring's getBean etc.

In this case, I suppose there'll be no problem in using those in Servlets through jar import.
Only thing, what kind of context I should use inside .jar to get beans so that it worked after packing into jar? ApplicationContext or what?

2 Idea. Is there another simple solution how to pack into jar and then use Services in a non-managed by Spring environment?

A:

There's a lot possibilities of doing that. To use Spring, you don't need EVERYTHING to be Spring.
For instance, you can configure Spring in your web.xml:
<web-app ...>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:com/acme/foo/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    ...
</web-app>

In your servlets you can do WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("myBean") to access beans.
Depending on the environment there are other means for integration. For instance, you can use org.springframework.web.jsf.el.SpringBeanFacesELResolver in JSF. Here is an example of JSF application with Spring-managed beans.

