Announcement Announcement Module
Collapse
No announcement yet.
How to define Filters in Manifest Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to define Filters in Manifest

    Hi All,

    I am trying to migrate web appplication to a Web Bundle in web application I am using Spring 3.0 Rest.

    My Web.xml file looks like
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>SpringFinanceManager</display-name>
    <description>Spring Finance Manager application</description>

    <!-- Comment out if using JBoss -->
    <listener>
    <listener-class>org.springframework.web.util.Log4jConfigList ener</listener-class>
    </listener>

    <!-- required to enable Spring 3.0 REST support -->
    <filter>
    <filter-name>httpMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMet hodFilter</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>httpMethodFilter</filter-name>
    <url-pattern>/hello/*</url-pattern>
    </filter-mapping>


    <session-config>
    <session-timeout>10</session-timeout>
    </session-config>

    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/WEB-INF/jsp/uncaughtException.jsp</location>
    </error-page>
    </web-app>

    I want to define filters to the manifest file

    <!-- required to enable Spring 3.0 REST support -->
    <filter>
    <filter-name>httpMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMet hodFilter</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>httpMethodFilter</filter-name>
    <url-pattern>/hello/*</url-pattern>
    </filter-mapping>




    Can any one help me in this.


    Thank you

  • #2
    I think you've posted into the wrong place (this is Spring DM forum). Do you want me to move your post to dm Server General or Web forum?

    Comment


    • #3
      Thank you for your suggetion. You can move it.

      Comment


      • #4
        No problem - but where exactly? Web or dm Server? Are you using dm Server (OSGi) or not?

        Comment


        • #5
          My Requirements are,

          I am working on Spring dmServer(OSGI), to develop a Bundle which should expose a RESTfull service using SpringFramework 3.0. for this I want to define some filters (as we did did in web.xml for web application) in Manifest.mf/module-context.xml.

          Comment


          • #6
            OKay - I'm moving the thread to the dm Server area then.

            Comment


            • #7
              We've actually come to realise that the Web-* manifest headers aren't as useful as we hoped they would be, especially as they only allow you to configure a subset of what can be configured in web.xml. Filters are one of the things that can't be configured in the manifest.

              Our recommended approach it so use web.xml for configuration in preference to the manifest headers, so just define your filters in your web.xml as you would in a standard WAR file.

              Comment


              • #8
                Hi Andy Wilkinson,

                Even I tried to use the web.xml as it is ,that I used in standard web, but my application is unable to reading web.xml. because I dont have imported http://java.sun.com/xml/ns/j2ee libraries in my bundle. Even I tried to download the theese libraries when I clicked on dependency section Download option.

                Comment


                • #9
                  As long as you have
                  Code:
                  Module-Type: Web
                  specified in your manifest, and your web.xml file in MODULE-INF/WEB-INF, this should just work.

                  Can you post some more information about your failure?

                  Comment


                  • #10
                    I declred Module-Type as Web only. But at the time of starting server Spring Dm is not able to find the <filter-type> that I have in web.xml is unable to find its correspomding name space(http://java.sun.com/xml/ns/j2ee). Even I am unable to download this using Download/Add in dependecy section of Manifest

                    any way my Manifest file looks

                    Manifest-Version: 1.0
                    Bundle-Version: 1.0.0
                    Bundle-Name: RestBundle Bundle
                    Bundle-ManifestVersion: 2
                    Bundle-SymbolicName: RestBundle
                    Module-Type: Web
                    Import-Library: org.springframework.spring;version="[3.0.0.CI-217,3.0.0.CI-217]"
                    Web-ContextPath: hello
                    Web-DispatcherServletUrlPatterns: *.html
                    Web-FilterMappings: httpMethodFilter;url-patterns:="/*"

                    and web.xml file looks like
                    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
                    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
                    <display-name>SpringFinanceManager</display-name>
                    <description>Spring Finance Manager application</description>


                    <context-param>
                    <param-name>log4jConfigLocation</param-name>
                    <param-value>log4j.properties</param-value>
                    </context-param>


                    <!-- Comment out if using JBoss -->
                    <listener>
                    <listener-class>org.springframework.web.util.Log4jConfigList ener</listener-class>
                    </listener>

                    <servlet>
                    <servlet-name>HelloWorld</servlet-name>
                    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
                    <load-on-startup>2</load-on-startup>
                    </servlet>

                    <servlet-mapping>
                    <servlet-name>HelloWorld</servlet-name>
                    <url-pattern>/</url-pattern>
                    </servlet-mapping>


                    <!-- required to enable Spring 3.0 REST support -->
                    <filter>
                    <filter-name>httpMethodFilter</filter-name>
                    <filter-class>org.springframework.web.filter.HiddenHttpMet hodFilter</filter-class>
                    </filter>

                    <filter-mapping>
                    <filter-name>httpMethodFilter</filter-name>
                    <servlet-name>HelloWorld</servlet-name>
                    </filter-mapping>


                    <session-config>
                    <session-timeout>10</session-timeout>
                    </session-config>

                    <welcome-file-list>
                    <welcome-file>index.jsp</welcome-file>
                    </welcome-file-list>

                    <error-page>
                    <exception-type>java.lang.Exception</exception-type>
                    <location>/WEB-INF/jsp/uncaughtException.jsp</location>
                    </error-page>
                    </web-app>

                    Comment


                    • #11
                      What's the failure that you're getting? Specifically, what output do you get in the console about the failed deployment, and what output do you get in serviceability/trace/RestBundle-1/trace.log?

                      I've just successfully tried this on a fairly recent CI build of 2.0 using your web.xml and manifest. The only thing I had to do was to make sure that Log4J was in my dm Server repository as it's required by the Log4jConfigListener that you've specified in your web.xml file.

                      Comment


                      • #12
                        Thank you all, this was fixed

                        Comment

                        Working...
                        X