WebSphere Application Server & Liberty

 View Only
  • 1.  How to injecting Spring Beans to JAX-RS resource running on Websphere Application Server 9 , JDK 1.8

    Posted Thu September 21, 2023 01:09 PM


    I am running WebSphere application server 9 (Java 1.8) which hosts a JAX-RS  application and would like to inject spring beans ( Spring-Core version 5.3.27) into the application. 

    Since websphere JAX-RS depends on IBMRestServlet, following the reference http://www.javavillage.in/spring-ioc-on-servlets.php,  I tried  creating a class that extends the IBMRestServlet and adding in an init() like one below

        public void init(ServletConfig config) throws ServletException {

    I had to add in was_public.jar and j2ee.jar provided in the WebSphere Dev folder as "provided" dependency in maven but maven was still complaining about following

    [INFO] -------------------------------------------------------------
    [ERROR] cannot access com.ibm.ws.ras.instrument.annotation.InjectedFFDC
      class file for com.ibm.ws.ras.instrument.annotation.InjectedFFDC not found

    I was not able to resolve the dependency. I searched IBM resources for a solution but could not find any.  Greatly appreciate if anyone can guide me here or suggest a better approach

    In meanwhile, I tried the following alternate method

    Alternate Method : Load Spring within Resource Class

    I tried loading spring context within the resource class and was successfully able to use Spring beans 

    public class MyResource {
    	TestClass testClass;
    	public Response getSomeWork(MyRequest request)  {
    		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    		TestClass tClass = applicationContext.getBean(TestClass.class);

    the Web.xml needed the following


    Unfortunately as it is obvious, there would be a big overhead of the initialization per resource along with having multiple Spring ApplicationContext ( one per resource)  for the  application which is undesirable

    Thanks in advance


    Sibi Vaithara

  • 2.  RE: How to injecting Spring Beans to JAX-RS resource running on Websphere Application Server 9 , JDK 1.8

    Posted Fri September 22, 2023 01:08 AM

    Hi All,

    Apologies, I posted the same twice, kindly respond to 



    Sibi Vaithara