Interacting with a REST webservice

Hi there,

I’m working on a project where you have a regular multiplayer game but where the server should receive some data from time to time from a android app. In the past I have allready worked with an application created in NetBeans that interacted with an android app by using REST webservices, so I wanted to do this again. I managed to create the complete multiplayer game and the android app from scratch, but now I have troubles with setting up the webservice to connect the both of them. I added the Jesey Library to my JMonkeyProject and created a resource class, however I am not able to access this resource. For those who are not really familiar with REST, take a look at this link. I have a similar resource class as shown in the link, but I can’t access it. I am suspecting I have to add some properties to let my application know that this resource is there. Is there anybody that has done something like this in the past and is willing to help me?

Thanks anyway

a) there are probably better places to get help with REST-based issues since this isn’t really JME specific.

b) you probably want to better explain what “not able to access this resource” means and what you’ve done to start said resource. (though now I’m already guessing what you meant). If you mean that you can’t access that web page… then did you even run a web server or grizzly or whatever? We’ve got nothing to go on.

Thanks for your answer, I now realize I have stated my problem poorly. The rest-part isn’t really the issue, because I have done that before, otherwise I should have indeed asked the question somewhere else. The problem is in running the web server part. At the moment I just have a server and client created by using SpiderMonkey. So basicly my server is just a headless simple application. As you correctly suggested I need to run somekind of webserver to shown an html page or access the rest-resource. However I m not entirly sure how to set everything up with Jmonkey, while keeping the game itself a desktop application (jar)

You probably just need to embed the grizzly instance into your app. Jersey comes with grizzly for testing/development but you should be able to run it in your case. It is still not really JME-related. You are running a Java application and want to have it serve REST resources. It’s a little bit of a strange requirement but I guess not unheard of… you’ll have to portmap things through your firewall and stuff to get external devices to see it and so on.

For a normal application (android devices contacting some server), it seems like it might be a bit upside down, though.

Thanks for your help, I will try to make it work.
I agree the requirement might sound a bit strange, it’s a part of a major project for my university. Multiple android devices just need to send from time to time some measurements to the server, and the game responds to those readings.

I realized that since JMonkey is build on top of netbeans, so I removed the jersey lib that I installed myself and just installed a bunch of plugins (like the RESTful Web Services and Java EE Base). I managed to add an GlassFish server with a domain for my application. However I m not yet able to show a webpage or access a rest resource. In Netbeans, when you go to the properties of your project you can select the ‘Web Pages Folder’ and ‘WEB-INF Folder’. I am wondering how to do this in JMonkey, how can I let my server instance know where to find a webpage for example… Any thoughts on that?

When you instantiate the server… point it to the directory.

If you are not instantiating a server… well, there’s your problem.

(answers shortened to match original content provided)

Well in the ideal case, I just want to start the web server when i run the server of my application (the headless simpleapp).

I added the server as you can see here.
My project directory structure looks like this.

At the moment I am able to start up the server (just right click on it in the service tab and press start) without errors. I understand that it should point towards the stuff I want to put up there, but I 'm not sure where I should specify that info. Somewhere in any of the files in nbproject? of somewhere else?

I hope I gave you more info to work with this time…

If you want your server application to instantiate a web server then your server application will instantiate a web server.

You will probably get more help on a web server/glassfish related forum. I’m the only one answering here and I don’t feel like I have anything left to offer.

Aight, thanks anyway