Search code examples
javacorsput

CORS thetransactioncompany does not work for one specific path


Currently i'm facing the problem that my thetransactioncompany corsfilter on an Tomcat 7 with Jersey 1.18 (can't update) works for the path /v2/users on PUT but not on /v2/plans. There is no difference between those - same package only the class is different. I also need to say that GET, POST works fine only PUT doesn't work.

My web.xml looks like this:

<!-- CORS FILTER FOR ALLOWING CROSS DOMAIN ACCESS -->
    <filter>
        <filter-name>CORS</filter-name>
        <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
        <init-param>
            <param-name>cors.allowGenericHttpRequests</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>cors.allowOrigin</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>cors.allowSubdomains</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>cors.supportedMethods</param-name>
            <param-value>GET, POST, PUT, DELETE, OPTIONS, HEAD </param-value>
        </init-param>
        <init-param>
            <param-name>cors.supportedHeaders</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>cors.supportsCredentials</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>cors.maxAge</param-name>
            <param-value>-1</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>CORS</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

this should allow PUT on all paths after root - or am i wrong?

  • also the OPTIONS on /v2/plans would give me the allowed methods: GET, POST, PUT, DELETE, OPTIONS, HEAD

Solution

  • Found out that it was another Exception which was the root cause of the whole thing. Turned on a deeper Logging and found it was a Nullpointer.

    So the solution is: look at the root cause - and turn on a better logging with more details in the specific problem.