How to prevent HTTP 404 during deployment of ear in Wildfly/Jboss - java

We're using WildFly 10 as our application server and deploy via Docker (deployment in WF is ordinary hotdeployment). We're not using WildFly's clustering mechanisms but simply have load-balancers (HAProxys) in front.
The problem is that WF opens its HTTP port while the EAR deployment is still in progress. This (of course?) leads to HTTP 404 errors which we don't want to handle specifically in the LBs. This could lead to false negatives...
Is there a way to allow HTTP connections only after the EAR has started successfully?
Alternatively is it possible to replace the "404 because nothing is deployed here"-error with a "503 service unavailable"? This would much better express the problem and would be easy to handle externally...

You can set default-response-code for host you are running this on.
something along the lines:
<host name="default-host" alias="localhost" default-response-code="503">
or in cli:
/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-response-code, value=503)
and similarly for any other host you might have.

Related

How to configure Wildfly 9 to failover HTTP sessions

I'm really struggling to configure Wildfly 9 to cluster/failover its sessions...
I keep reading that wildfly in standalone-ha mode will automatically discover peers and automatically share sessions, but it's clearly not working for me.
I have setup 3 AWS EC2 servers which all have the same configuration. They all run the same versions of everything and have the same webapp .war file deployed to each of them. This webapp works fine, I can log in to the app which maintains a simple session variable to verify that I am logged in. I've launched each server with standalone-ha.xml configuration files but logging into one doesn't allow be to access the session in any of the others.
I've tried all the things I can think of, but don't know how to diagnose the issue as I don't know how the servers identify each other.
I've manually deployed the war file on each server but placing the file into .../standalone/deployments/
Each has a fully open firewall...
Oh - I set the muticast address on the command line to 230.0.0.4 (That number came from a guide, and I have literally no understanding of it) and each is bound (-b) to the internal IP of the server...
Any help appreciated...
First you must consider that in AWS EC2 multicast traffic is not allowed and thus MPING will not work.
See http://developer.jboss.org/wiki/JGroupsS3PING
An example how to implement S3Ping http://aws.typepad.com/awsaktuell/2013/10/elastic-jboss-as-7-clustering-in-aws-using-ec2-s3-elb-and-chef.html

Tomcat Request.getPort() stripping port number

Problem:
I am using Java HttpServeltResponse to call sendRedirect but on a particular deployment the URL port number is not included in the HTTP 302 response message.
Details:
I have an application, which uses spring security to authenticate and redirect on success. The redirection URL provided by me is a relative path.
On redirection the spring framework calls sendRedirect on HttpServletResponse passing in the context path along with the relative URL. For example:
HttpServletResponse.sendRedirect("/MyApp/index.html");
This all works fine when we deploy to tomcat instances on various platforms (Windows/Ubuntu etc). However one of our clients is finding that in their deployment, the redirection port is stripped, for example, if the entry point is:
http://server:8082/MyApp/authenticate
The redirection they get is:
http://server/MyApp/index.html - this page does not exist, as it is missing port 8082
Stepping through the code, I can see that the port is determined by asking the Java Request Object, which seems to be supplied by the Web Application Container (i.e Jetty/Tomcat?). In my dev environment it is org.eclipse.jetty.server.Request.
So is this a tomcat configuration issue? We could replicate the same behaviour using Apache2 ProxyPassReverse, but they assure me they are not running Apache2, and their connection is a direct connection to tomcat.
As I can not replicate this issue anywhere, I am really stuck for an answer. Any help would be very much appreciated.

Deploying Java SE6 stand alone web service on a server

Follwing the steps as outlined here: Standalone web service
I created a test web service that works great on my local machine. Since this is 'stand alone' I copied the same root folder on to a 'server' that I use and published the service on the server (as if it is my local machine). When I access the wsdl using localhost as the domain name, it works fine on the server. However, when I try the url from a different macihne on the network giving the server's domain name instead of localhost, I get a 'can not be displayed' error in IE.
My question is, should this even be possible? Or is there anything specific that needs to be done. Since this is a 'stand alone' solution, we should not require 'another' container like tomcat correct?
To be honest, until your post, I had no idea there was a builtin, lightweight, HTTP Server in the JDK. I've always used glassfish for my web service needs.
I can't say for sure, but if you look closely at the example code you'll see:
Endpoint endpoint = Endpoint.publish("http://localhost:8080/calculator", calculator);
I suspect that this limits you to "localhost" as opposed to the host machine. Try changing it so that it represents the name of the server and try again from another machine (naturally making sure it can get through the firewall as well). Something like:
Endpoint endpoint = Endpoint.publish("http://myserver:8080/calculator", calculator);
Rebuild it and try again. Other than that, you'd need to create a proper war file and deploy to glassfish, tomcat, etc.

Continous Deployment for Java/JVM Web Application

My team and I would like to implement "Continuous Deployment" for our website. Continuous Deployment basically means deploying to production very frequently (multiple times a day). Supposedly Etsy does this all the time.
Our environment is Tomcat + Nginx. We already do Continuous deployment of any code change to our snapshot server (ie traditional continuous integration) using Hudson and a Hudson+Cargo plugin that hot deploys.
Surprisingly that works well (albeit over time we have to restart tomcat sometimes).
For production this is not going to work because we can't have the website down.
I have some ideas like having two web apps and redirecting while one is down.
Anybody have any ideas or has done this before in a real production environment?
From http://radar.oreilly.com/2009/03/continuous-deployment-5-eas.html:
Real-time alerting. No matter how good your deployment process, bugs can still get through. The most annoying variety are bugs that don’t manifest until hours or days after the code that caused them is deployed. To catch those nasty bugs, you need a monitoring platform that can let you know when things have gone awry, and get a human being involved in debugging them.
To effectively implement continuous deployment to production, you need good monitoring, otherwise you will not understand what is happening with your application.
I don't know WHY you think this is a good idea, but thats up to you.
I would use a balancer application with two hot systems, which can be found in tomcat itself, and then just stop the server before deployment, deploy, and restart the server. Leave a two minute window for each hot server, and you should be good.
EDIT: I wouldn't deploy EVERYTIME. We also are a small company with noch much QA (tm), but it is still one click in the build system to go live.
We use apache httpd 2.2 and mod_proxy for this
We then have 2 tomcats running, one on port 8080, and one on port 88.
The firewall prevents outside access to those ports, so only port 80 is open
Apache HTTPd is configured to listen on port 80
It is very simple to configure too.
This is a basic configuration (httpd.conf) that will work out of the box:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<Proxy balancer://mycluster>
BalancerMember http://localhost:8080
BalancerMember http://localhost:88 status=+H
</Proxy>
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
The "+H" means that it is only used as a backup server, so when 8080 is unreachable, it will run on 88 until 8080 comes back online

Weird Tomcat and Axis Webservice behaviour

I have a simple web service deployed on tomcat using Apache Axis.
If i access the webservice as http://localhost:8080/webservices/TransactionService i see the usual message
TransactionService
Hi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
showing that the web service is available and ready for use.
However if i access it as http://10.0.0.1:8080/webservices/TransactionService (10.0.0.1 is the actual IP of the machine. I'm accessing it on the same machine as above, machine hosting tomcat) i get:
HTTP Status 404 - /webservices/TransactionService
--------------------------------------------------------------------------------
type: Status report
message: /webservices/TransactionService
description: The requested resource (/webservices/TransactionService) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5
There is nothing in the tomcat logs
If i try deploying on Jetty it all works fine.
Is there any explanation for this? Any pointers most welcome.
Tomcat can listen on different hostnames/IPs in a different way. Specifically, every host/IP can have its own work directory:
<Host name="localhost" workDir="/workdir">
...
</Host>
Application deployed to one workdir won't be available to a host with another workdir.
Check your configuration.
UPDATE: if name is specified as name, not IP, check that that name is resolved to 10.* address too.
Also, one of the hosts is default. It responds to all requests now matter what host they are targeted too, if there is no specific Host. For your setup you may want to leave only that one active.
I don't think a change to Tomcat configuration is the answer. I don't have to do such a thing to use my local IP address or localhost.
Could it be as simple as an addition to your hosts file? I've got mine in c:/windows/system32/drivers/etc/hosts, and there's an entry for "127.0.0.1 localhost" in it.

Categories