users@jersey.java.net

HTTP Status Error 405 when using POST

From: <timothy-a.mcknight_at_ubs.com>
Date: Tue, 7 Apr 2009 11:43:03 -0500

Hi,

I am trying to use @POST to perform an update. My method is the
following:

        @POST
        @Path("updateacesslevel")
        public void updateUserAccessLevel(@QueryParam("appname") String
anApplication, @QueryParam("user") String aUser, @QueryParam("level")
int appLevel) {

                /***if (anApplication == null) {
                        //do something
                }
                if (aUser == null) {
                        //do something
                }*/
                if (aUser != null && anApplication != null){
                        int returnValue;
                        try {
                                returnValue =
AppPerms.updateAppAccessLevel(anApplication, aUser, appLevel);
                        } catch (Exception e) {
                                log.error("Error updating access,", e);
                        }
                }
        }

When I hit my url:
http://mymachine:8080/myapp/applicationperms/updateacesslevel?user=johnd
oe&appname=TEST&level=0

I get an HTTP Status 405 - The specified HTTP method is not allowed for
the requested resource ().

I am using tomcat 6 and my web.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
  <display-name>ORION</display-name>

        <servlet>
                <servlet-name>My app</servlet-name>
                        <servlet-class>
        
com.sun.jersey.spi.container.servlet.ServletContainer
                        </servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>My app</servlet-name>
                <url-pattern>/*</url-pattern>
        </servlet-mapping>
    <security-constraint>
            <web-resource-collection>
                    <web-resource-name>Permitted Actions</web-resource-name>
                    <url-pattern>/*</url-pattern>
                    <http-method>GET</http-method>
                    <http-method>POST</http-method>
                    <http-method>PUT</http-method>
                    <http-method>DELETE</http-method>
            </web-resource-collection>
    </security-constraint>
</web-app

Does anyone have an idea on what I may be doing wrong?

Thanks,
Tim




Visit our website at http://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
        
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.

 
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.