Thursday, February 16, 2017

Use correct header with CURL

Upon submitting a request to my service like

CURL -X POST http://localhost:8600/a/b/c -d '{"assignmentId[]":[12345]}'

I got this error:

"A servlet request, to the URI http://localhost:8600/a/b/c, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected."

Resolved with this answer from (thanks Arnold B.).

When I changed my request to

CURL -X POST http://localhost:8600/a/b/c -H "Content-Type: application/json" -d '{"assignmentId[]":[12345]}'

(adding the header) the service was able to parse the request and handle it normally.


Tuesday, April 5, 2016

Replacement for Windows Task Manager

Windows Sysinternals - a suite of sys admin tools (some require admin rights).


Process explorer - a much better replacement for Windows Task Manager - doesn't require admin rights and can help deetermine if a process has a lock on a DLL.

TCPView - shows all your port connections.

et al.

Monday, January 12, 2015

Selected differences in sed on mac and other *nix

A coworker sent me this sed command that works in other versions of unix command line:

sed -i "s/filename_prd/filename_dev/g" filename_dev.sql

But on Mac OS this what I had to do:

sed 's/filename_prd/filename_dev/g' ./filename_prd.sql > ./filename_dev.sql

Evidently the "-i" is not required in Mac, the command being sent to sed must be in single quotes and not double, and the output of sed goes to std_out so it needs to be saved to another file. (You can save it to the file itself but I prefer to be conservative about this.)

Thursday, October 30, 2014

Thursday, October 2, 2014

grep in a bunch of files

I always have to look this up so I'm posting a note to myself here. To grep through all the files in a directory, recursively, and only get back a list of the files containing the string, do:

tomcat@merchant101 $ grep -lr "import" .

Found this in this blog.

Friday, September 5, 2014

Avoid error messages with `find` in *nix

Very useful comment on StackOverflow about how to get rid of error messages that come up when you use `find`.
You do not need sudo to run find for generally-accessible commands. If you don't want to see the error messages about inaccessible directories, get rid of the messages rather than using root privs unnecessarily. Using sudo all the time is a bad habit. Redirect stderr to /dev/null, like this:
find / -name java 2> /dev/null

Walter Underwood on SO