Home » Devtech review » LangsNTechs » Java » Eclipse » Eclipse WTP Tomcat/JBoss Adapter issue – permanent starting

Eclipse WTP Tomcat/JBoss Adapter issue – permanent starting

Eclipse WTP Tomcat and JBoss adapters have a certain bug that I’ve encountered recently, and due to conditions it occurred in it took almost a detective work to figure out.

I added a video below with all the details and a little demo – just for fun.

Long story short, the bug occurs on starting the server (be it Tomcat or JBoss) from Eclipse. When starting it Eclipse WTP Server Adapter starts a thread called PingThread that tries to connect to the server. If connection is OK, server is considered to be “Started”. Otherwise it’s shown as “Starting”, and if there’s a startup timeout configured, after the time of timeout passes server gets killed.

The problem is that PingThread connects to server using java.net.HttpURLConnection – so an HTTP protocol client – and this HTTP protocol client by default follows HTTP redirects. So if server is started (say on localhost at port 8080) but request to it’s root index (i.e. “http://localhost:8080/”) returns a redirect, java.net.HttpURLConnection will follow that redirect. If the redirect is issued to some URL that’s accessible – you notice nothing. But if it redirects to some place that’s not accessible, “connection refused” error is returned, and Eclipse keeps thinking your server hasn’t started yet.

Which results in 2 things: continuous requests to index page on your server (which might be a problem and certainly doesn’t improve performance) and continuous “Starting” state of your server in Eclipse (so if there’s startup timeout configured – server will be killed after timeout time passes, plus you can’t use publish/restart/debug buttons while server isn’t considered “Running”).

In my case the redirects were sent from my WebApp conditionally, depending on UserAgent. The JVM’s user agent was considered to be of a “mobile device”, so requests from JVM – i.e. from Eclipse here – were redirected to non-existent mobile version of my WebApp. The desktop browsers, however, worked just fine, so I had no idea at first than an actual redirect is happening there for Eclipse.

All in all it took a while for me to figure out why exactly is my WebApp under constant load, why Eclipse doesn’t switch my server to “Running” mode, and how can I fix it. I wasn’t aware of the way Eclipse was testing Tomcat for being started, so I had to dig until I found out about PingThread, checked the code, reproduced it, etc.
Eventually I corrected the UserAgent rules to let PingThread pass in without redirects and everything became fine.

I’ve also posted a bug with all the info to Eclipse WTP BugZilla, so hopefully this will soon be fixed properly.
‘Cause actually I’ve encountered this problem while working with really old Eclipse (ver 3.3), but then reproduced it with most recent one (Juno), so this bug is old and should be fixed for long time now.

The video with demo and details:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s