Archive for category Programming

ElasticSearch issues upgrading from Ubuntu 15.04 -> 15.10

For some bizarre reason when we did an upgrade from ubuntu 15.04 to 15.10 and elasticsearch was updated from v1.4.5 to v1.6.2 elasticsearch would not start (although systemctl thought it had each time).

Immediately after the upgrade, we received error messages from our application saying it could not connect to elasticsearch.

Sure enough trying to connect to the elasticsearch service failed when we attempted to use curl -XGET 'localhost:9200'

Another strange thing is that systemctl says that elasticsearch is running perfectly, even though the process is not running when we execute ps -aux | grep elastic …

It turns out the elasticsearch.pid file had been deleted in the upgrade and the elasticsearch user could not create a new one.

touch /var/run/elasticsearch.pid
chown elasticsearch /var/run/elasticsearch.pid

However, that is not all, I started receiving a new and exciting error message (see stack trace below). Read the rest of this entry »

3 Comments

Nasty Class loader issue: “java.lang.LinkageError: loader constraint violation: loader previously initiated loading for a different type…”

Background

First a bit of background, I am working as part of a team responsible for building a bespoke content management system for educational uses and the back end uses the following technologies:

  • Java Tomcat 7.0 server
  • Rest Easy 3.0.6.Final
  • ElasticSearch 1.0.1
  • Google Guice 3.0 for dependency injection
  • Eclipse Kepler Build 20130919-0819
  • Counterclockwise (Clojure plugin For Eclipse) 0.20.0 & 0.24.1.STABLE001 – This becomes important later even though I am not using it really.

The problem

Now to describe the problem. For some reason after integrating ElasticSearch with our project a nasty error as seen below started happening (and breaking the whole site at runtime when running within eclipse):

SEVERE: Servlet.service() for servlet [jsp] in context with path [/rutherford-server] threw exception [Filter execution threw an exception] with root cause
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catalina/loader/WebappClassLoader) previously initiated loading for a different type with name "javax/servlet/http/HttpSession"

This problem seemed to refer at a random place in our code in the stack trace. This random place had previously worked (and is totally unrelated to the Elastic Search stuff I was working on) in my case it occurred in a User Manager class that deals with sessions (hence the reference to HttpSession). The elastic search stuff didn’t have anything to do with the user manager or even use the HttpSession class as far as I was aware but seemed to trigger the error when the code for the elasticsearch java api was inserted.
Read the rest of this entry »

, , , ,

7 Comments

Eclipse Plugin: Listening to Marker Deletions

Today I was desperately trying to figure out how to get eclipse to tell me when a Bookmark had been deleted, so that I could update my plugins internal data representation.

I found lots of api’s which was all well and good but finding a code example was a lot harder. Also the guys on the irc channel were too busy to help, so I kept searching.

It turns out that you need to fiddle with the IResourceChangeListener and IResourceDeltaVisitor to traverse a delta (basically a tree representation of all the changes that have just occurred) and look for your bookmarks.

Below is example code for creating a listener, visitor and how to attach it to the workspace as a change listener.

	// this listener deals with handling changes to markers.
	private static IResourceChangeListener markerListener =  new IResourceChangeListener() {
				private MarkerChangeVisitor fVisitor = new MarkerChangeVisitor();

				public void resourceChanged(IResourceChangeEvent event) {
		           IResourceDelta delta= event.getDelta();
		           if (delta != null)
		           {
		                try {
		                    delta.accept(fVisitor);
		                } catch (CoreException ce) {

		                }
				   }
				   }
		   };

Read the rest of this entry »

, , , , ,

2 Comments

Eclipse Plugin Tag Cloud

I got fed up looking for a nice version of an eclipse tag cloud so instead I made my own.

Its simple but effective.

Eclipse Plugin Tag Cloud

Eclipse Plugin Tag Cloud

You can download the archive here. Or look at the code below.

eclipseTagCloud.zip

All you should need to do to display it is make a viewpart and then write something like.

// pass the tag cloud generate a data structure like the following
// example code
ArrayList al = new ArrayList();
al.add(new Pair("tag 1", 3);
al.add(new Pair("tag 2", 6);
// create the tag cloud generator
EclipseTagCloudGenerator tclg = new EclipseTagCloudGenerator(al);
tclg.setMaxTags(35); //set max tags to display (by default will display most frequent)
tclg.setScale(2); //set scale to increase font by
tclg.generateTagCloudDisplay(comp, tclg.getTagCloud()); //generate the tag cloud and attach it to the parent comp object

, , , , ,

3 Comments