Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Place your Spring xml files under /META-INF/spring in the bundle jar file
  2. Copy all the bundle jar files into /WEB-INF/classes/bundles in your application
  3. Make sure that the following properties are set in struts.xml or struts.properties in your application:
    Code Block
    XML
    XML
    <constant name="struts.objectFactory" value="osgi" />
    <constant name="struts.objectFactory.delegate" value="springOsgi" />
    <constant name="struts.freemarker.manager.classname" value="org.apache.struts2.osgi.BundleFreemarkerManager" />
    
  4. Install the Struts 2 Spring plugin in your application, like in normal Struts 2 applications.
  5. Configure your web.xml like:
    Code Block
    XML
    XML
        <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
        <display-name>Struts Blank</display-name>
    
        <filter>
            <filter-name>struts2-execute<prepare</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter<StrutsPrepareFilter</filter-class>
        </filter>
    
        <filter>
            <filter-name>struts2-prepare<execute</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter<StrutsExecuteFilter</filter-class>
        </filter>
    
         <filter-mapping>
            <filter-name>struts2-prepare</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <filter-mapping>
            <filter-name>struts2-execute</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <listener>
            <listener-class>org.apache.struts2.osgi.StrutsOsgiListener</listener-class>
        </listener>
    
        <listener>
            <listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
        </listener>
    
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
        <context-param>
            <param-name>contextClass</param-name>
            <param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
        </context-param>
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>osgibundle:/META-INF/spring/*.xml</param-value>
        </context-param>
        <context-param>
            <param-name>parentContextKey</param-name>
            <param-value>parent-context-bean</param-value>
        </context-param>
    </web-app>
    
  1. Add the Spring OSGi dependency , and Spring Web dependencies to your web app, if you are using maven:
    Code Block
    xml
    xml
    
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>2.5.5</version>
    </dependency>
    <dependency>
         <groupId>org.springframework.osgi</groupId>
         <artifactId>spring-osgi-web</artifactId>
         <version>1.1.2</version>
    </dependency>
    
  2. Download Spring OSGi and copy all the required bundles under /classes/bundles/other. For Struts OSGi 1.1.2, these are the required bundles:
    No Format
    com.springsource.org.aopalliance-1.0.0.jar
    com.springsource.org.apache.commons.logging-1.1.1.jar
    org.springframework.aop-2.5.5.A.jar
    org.springframework.beans-2.5.5.A.jar
    org.springframework.context-2.5.5.A.jar
    org.springframework.core-2.5.5.A.jar
    org.springframework.osgi.core-1.1.2.A.jar
    org.springframework.osgi.extender-1.1.2.A.jar
    org.springframework.osgi.io-1.1.2.A.jar
    org.springframework.osgi.web-1.1.2.A.jar
    org.springframework.web-2.5.5.A.jar
    

...