Moving webapp from localhost to server - page cannot be found - java

I have developed a Play! 1.2.7 web application which calls an existing online payment service, eclipsified to work in Java.
I send data in POST to a servlet and get a response in GET to my application. This is possible because one of the data sent to the service is the URL of my controller handling the response.
I had this working perfectly in local environment but when I move the webapp to a Tomcat container on our local server with public ip I'm stuck because service response cannot find my webapp as it used to do with localhost.
Locally the URL was something like
http://localhost:port/myAction
When I put it on tomcat I changed the URL to
http://my.public.ip.address:tomcat_port/app_name/myAction
I get the "page is not available" message from browser.
My guess is that I miss some basics from network communication and I'd like to know how to have this working when the application is deployed on our server.
Ps. sorry for bad tagging, I'm not sure what's this question's target
EDIT: no logs from catalina.out. If I run the application nothing gets logged

I came across the solution by knowing that loopback is not enable by default on every router.
So I will never be able to have a response client side when I send the request from the lan where the server is located, unless loopback is enabled on the router.
To test my application I had to use the server local address, visible from inside.

Related

InternetAccess with Jetty and a Webserver. Client-Server Communication 2 machines, computer, java

I need some advice in the following matter:
I have two machines that are connected via ethernet.
One machine (lets call it ServerSide) is also connected to the Internet via LAN. The second machine (ClientSide) is offline, in the beginning.
So ServerSide is creating a webserver with Jetty on port XY. ClientSide opens a webbrowser and requests some page (e.g. stackoverflow.com). The request will be forwarded to port XY and the webserver. ServerSide would have to send the request to the internet and then back over ServerSide to ClientSide, so the webbrowser should display the requested webpage.
Is it even possible to do that this way?
Thanks in advance
Yes. What you need on server side is an HTTP Proxy and there are plenty of existing solutions in the market.
Check out the Wikipedia article about proxies. Bear in mind that the client might require some configuration (Proxy settings) so that it forwards the requests to the proxy rather than attempting to reach the final host.

Deploying a webapp to a websphere application server that checks the health of the host server

If i have a webapp deployed to a specific server or host, and this webapp checks the health of the local server its deployed on when you call a get request on its URI.
The problem I am having is that if the server goes down, you can't even make a get request to the health webapp (webapp simply uses a URL object with the localhost and port path and gets the connection code).
Would creating a seperate JVM for the webapp solve this problem? or does the webapp need to be hosted entirely on another server?
i'm a beginner so have mercy.
The short answer is not feasible. you will need a third party vendor app to check your server from outside the host itself. i can give you many suggestion. but just try these first, datadog apm and nagios.
I think it's totally reasonable to use a small JSP for a health check of the server itself.
If you can't reach the JSP, it's a pretty extreme case of the server being in trouble.
If you can reach the JSP, you can query some mbeans to summarize a more detailed/nuance health.

How to make a web service url work on a remote machine?

I have developed a REST based web service that works perfectly on my machine. The URL is
http://localhost:8080/MyRESTProject/resources/welcome/
Obviously, the URL would work only on my machine. What I want is the URL to work on any remote machine. Also, I want the service to run constantly. Is this possible even after I terminate the web service process?
PS: I am using eclipse dynamic web project to build this web service and the OS is windows 7.
Your web service will be available as long as it is being hosted. A web server receives HTTP requests and replies with HTTP responses. How can you expect your web service to continue working if you terminate the server process?
As for your web service being accessible from outside, you will need to know the public IP address of your network. You can search "What is my public IP" on Google search to get your answer.
But you are not done yet, you will need to configure your router/firewall to open up a port on your router and map it to port 8080 on your host.

Not able to access webservice from same network java

My webservice is running on jboss and client is on the tomcat
both client and webservice is running perfect on my local machine.
but if i setup client on another machine, the client program giving an error message 404 not found
I have shared my jboss over network and i am able to access webservice wsdl from another machine using http:192.168.1.26:8080/FalconServer/SearchService?wsdl
I set the same url in Client code.
but it won't work, any help
I wanted to put this as a comment, but i dont seem to find a comment button.
Did you start your jboss binding to your ip address. One way to do that:
run -b

Get server Port in web application at server start

I need to retrieve server information like Server IP and Port at server startup.
I am using Spring and hibernet in my project and Glassfish (and tomcat) is the application server.
I know that I can get the IP and Port information from request, but there is no request at server startup.
I found on net after some search that IP address can be retrieved as follows:
InetAddress.getLocalHost().getHostName();
but I did not find any method to retrive the current Port of the server. I am hoping to find API from app server which will provide this information. I am using Spring in my application and thus any indications from Spring API will also be helpful.
Well you should configure port in your web.xml as param and read it out in your code using ServletContext or you can use this poor hack
A server may be listening to multiple ports on multiple names, so you cannot be certain that the one chosen automatically is the one you really want.
Question is what you need it for.
If it is for giving URL backs in requests then use the information in requests.
If it is for logging or announcement with ZeroConf, then consider writing application server specific code asking it about its configuration.
If all else fails, explicitly pass in the information through e.g. system properties or JNDI.

Categories

Resources