0

I am new to NanoHTTPD server and Maven. I'm starting a maven project using NanoHTTPD server and im trying to test the HelloServer (set to port 8081 in HelloServer class' super call). I run the app and a NetBeans like window opens, i guess it is the server running, i haven't given it any brandings yet.

But how do i test that it is serving properly? In tomcat or apache i could just go to the url on that port http://localhost:8080/ and the server will serve me an error or welcome page.

I try going to http://localhost:8081 in a browser but all i get is the browser couldnt connect error, no confirmation of anything served.. I feel like im really dumb right now. Im not 100% confident i have set the project up properly, i imported the class files as i wasn't sure how to import it as a module, and i put parent tags in the pom file for the NanoHTTPD pointing to my parent app but i guess its not actually using that, anyhow it builds and compiles and runs, but how do i confirm it is serving..?

i notice these errors in output log: specifically i notice context errors before/after it turns on modules: java[7741] <Error>: CGContextGetCTM: invalid context 0x0
java[7741] <Error>: CGContextSetBaseCTM: invalid context 0x0
java[7741] <Error>: CGContextGetCTM: invalid context 0x0
java[7741] <Error>: CGContextSetBaseCTM: invalid context 0x0
java[7741] <Error>: CGContextGetCTM: invalid context 0x0
java[7741] <Error>: CGContextSetBaseCTM: invalid context 0x0
`

update: context errors are fixed by updating to Mountain Lion. Apparently they are caused by Mac's version of Java prior to Mt.Lion.

jsky
  • 2,225
  • 5
  • 38
  • 54
  • Could you please confirm that the `port 8081` is listen? e.g. using the command `netstat -an`. The result may look like `0.0.0.0:8081 LISTENING`. – Charlee Chitsuk Jul 05 '13 at 04:18
  • netstat -an returned a list of connections then sockets, and i couldnt find any reference to port 8081 or NanoHTTPD. I will also add the full run log, as i noticed some context errors. – jsky Jul 05 '13 at 04:38
  • What are your environment? OS, JDK ? – Charlee Chitsuk Jul 05 '13 at 05:01
  • Mac OS X version 10.7.5 running on x86_64, O.S = Lion, JDK = 1.7, Netbeans - 7.3 – jsky Jul 05 '13 at 05:11
  • I've found the another SO question [CGContextSetBaseCTM invalid context 0x0](http://stackoverflow.com/questions/12758762/cgcontextsetbasectm-invalid-context-0x0). There are 2 comments with may be useful link. – Charlee Chitsuk Jul 05 '13 at 05:30
  • if you develop on OSX maybe it's worth to have a look here [setting-the-default-application-icon-image-in-java-swing-on-os-x](http://stackoverflow.com/questions/11253772/setting-the-default-application-icon-image-in-java-swing-on-os-x) – SubOptimal Jul 05 '13 at 11:10
  • i tried reinstalling Netbeans altho i imported old settings maybe i shouldnt have. but the reinstall didnt help. The only fix for these context errors i could find was a user saying upgrading to Mountain Lion fixes it: https://github.com/processing/processing/issues/1129 so looks like i might do that tomorrow. Whether these context errors are preventing me from accessing any pages from the server is another question, it seems that i should be able to. – jsky Jul 05 '13 at 13:26
  • context errors are gone after update to Mt.Lion, however, i still dont get any confirmation that the server is working when i go to `http://localhost:8081` in a browser.. – jsky Jul 06 '13 at 04:53
  • Ive also decided to now use an embeddable Tomcat for this project. – jsky Jul 07 '13 at 04:55

0 Answers0