tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris.Christo" <>
Subject Trouble with POST & PUT with Rest
Date Tue, 04 Jun 2013 18:40:20 GMT

(The following is run with the latest OpenEJB standalone 4.6.0-SNAPSHOT on a Mac and calling
the openejb start command)

(I have attached the app, its an ejb-jar which you need to just drop in to apps/ of a fresh
OpenEJB standalone from the tomee/assembly/ folder in svn. The app has nothing other than
this one simple rest class below).

I'm having a problem with calling a POST or a PUT to the following class:

public class ExampleRest {

	@Path(value = "/get")
	public String get() {
		return "get";

	@Path(value = "/post")
	public String post(@QueryParam("param") String param) {
		System.out.println("post(" + param + ")");
		return "post(" + param + ")";

	@Path(value = "/put")
	public String put(@QueryParam("param") String param) {
		System.out.println("put(" + param + ")");
		return "put(" + param + ")";

The following GET request works;

curl -X GET -v -H "Accept: application/json" -H "Content-type: application/json"

The server prints out 'get' and also I get a response 'get'.

However with either PUT or POST nothing is printed on the server and nothing is returned,
with the following curl commands:

curl -X POST -v -H "Accept: application/json" -H "Content-type: application/json" -d '{"param":"value"}'

curl -X PUT -v -H "Accept: application/json" -H "Content-type: application/json" -d '{"param":"value"}'

When I do call either POST or PUT I get the following (generic) output:

* About to connect() to port 4204 (#0)
*   Trying
* connected
* Connected to ( port 4204 (#0)
> POST /testing-rest-0.0.1-SNAPSHOT/example/post HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host:
> Accept: application/json
> Content-type: application/json
> Content-Length: 17
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 200 OK
< Content-Length: 0
< Set-Cookie: EJBSESSIONID=cc51246f-9095-4a11-9f0e-ff8bc030fa7b; Path=/
< Content-Type: text/html
< Connection: close
< Server: OpenEJB/4.6.0-SNAPSHOT Mac OS X/10.8.3 (x86_64)
* Closing connection #0

So it looks like it connected with the server but its not routing the request to the associated
method. The end points I'm using in the curl put and post requests are the same as the get
(apart from the last word).

Is there anything obvious I'm doing wrong?

Chris Christo


View raw message