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 on 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 »

, , , ,

Leave a Comment

Fixed: iPod Crashing iTunes & Restore Error – iPod Classic 160GB

Symptoms:

  • An iPOD classic 160GB was causing iTunes to freeze each time it was connected (on more than one windows 7 64bit machine).
  • When trying to restore iTunes gave the following error: iPod could not be restored. An unknown error occurred 1439.
  • To Solve iTunes Crashing Problem:

    When the device was first given to me I formatted it using FAT32 filesystem (iTunes would crash and I would not be able to use the restore button). I reformatted it using gparted in ubuntu because Windows 7 would only let me use exFAT – this is no good.

    After formatting the device it would no longer crash iTunes so I could then try to restore it using the correct iTunes restore button. Unfortunately, the restore would fail and the following error would be given: iPod could not be restored. An unknown error occurred 1439.

    To Solve iPod restore error (iPod could not be restored – An unknown error occurred 1439.)

    The next step which took me ages to figure out was to use a windows XP virtual machine to install an old version of iTunes. After iTunes was installed on the XP box I was able to restore the iPod as normal.

    My main computer was running windows 7 64bit and iTunes 10. – This configuration would not restore the iPod and would always have the 1439 error.

    The windows XP computer was running 32bit windows and iTunes 9.2.1.5 – this worked correctly and the iPod appears to be fixed.

    Leave a Comment

    Dual Booting: Installing Windows XP after Windows 7 – Nightmare Solved

    After spending 3 hours trying to get my PC which was preinstalled with Windows 7 to dual boot with XP, I finally found the solution that worked for me.

    I tried all of the suggestions that were given in the support forums including meddling with my BIOS and none of them worked for me. I even tried using different partitioning software because I was worried the partition wasn’t setup properly. – It didn’t make a difference.

    My Solution:

    1. I used Windows 7 partition manager to create a new primary partition to house my new Windows XP installation. I set it to FAT32 file system just for simplicity and because I had started to stress out with NTFS at this point.
    2. Then I put my windows XP disc in and began the installation process, however the problem came when the computer finished the command line based installation and was ready to move into the Graphical Interface section of the install process. When the system rebooted it would halt with a message “Error Loading Operating System”. Which was very unhelpful.
      Restoring Windows 7 to Working Order
    3. In order to get back to a reusable Windows 7 Installation you have to replace your Windows XP CD with your windows 7 DVD and reboot from the DVD.
    4. After selecting your language, click on the little link in the left hand side of the screen and select the command line from the list of options (after you select the Windows 7 installation you want to repair).
    5. In the command line if you run the following commands in order;
      bootrec /FixBoot
      bootrec /FixMbr
      This should allow you to boot back into your original Windows 7 installation.
      Completing Windows XP Installation
    6. Now once you are in windows 7 we have to find a way of getting the bootloader to give us the option to boot into the incomplete installation of Windows XP Service Pack 2.
    7. Fortunately a handy freeware application exists which makes this relatively easy. EasyBCD.
      Screenshot of EasyBCD

      Screenshot of EasyBCD

    8. Install this application and then click the Add/Remove button, then add a new Windows XP menu item. After you have added it you may need to go to configure the XP menu item to use the correct drive letter. I did.
      Final Steps to Success
    9. Now this is where the secret comes in, if you were to try and just reboot now and select the windows XP partition from the boot loader it would say there is no windows XP boot loader yet and the whole thing just wont work.
    10. What I did was nip over to my laptop and copy across the essential files from my laptops windows XP installation to enable the other installation to boot and complete. Copy and paste these into the root of your incomplete windows installation (and then magic! you can use the boot loader to go and complete your windows XP installation) So far it all works correctly after that! Woo hoo!

    To be helpful I have attached a copy of the files I copied and pasted from my laptops windows XP installation that were required to complete installation of windows XP on my new partition. I suggest you paste them in from windows 7 when you have completed the first stage of the installation and rebuilt the MBR.

    Boot Files Zip File: windowsBootFiles

    Contains:
    Subdirectory windows (which represents the root of the windows partition file system – these files should be copied and pasted directly on to the root drive of your new windows XP partition NOT the windows directory which will have already been created by the XP install CD)

    – AUTOEXEC.BAT
    – boot.ini
    – CONFIG.SYS
    – IO.SYS
    – MSDOS.SYS
    – NTDECT.COM
    – ntldr (the most important file)

    The zip file here contains the boot files without the pagefile.sys and hibernation files as I didnt think these would be necessary and were quite big.

    Hope this helps!

    26 Comments

    Eclipse Plugin Development: Wrapping Text In a Label

    Today I was having trouble wrapping text in a label on an SWT shell in an eclipse plugin.

    I found a useful guide that explains what was going wrong. It can be found here.

    Wrapping Text Guide

    The problem was I hadn’t defined a widthHint for the grid data object. This is apparently used by the label component to work out whether it needs to wrap or not.

    Leave a Comment

    SSH Port Forwarding Guide

    This is a good Guide. for setting up port forwarding with putty and squid.

    Leave a Comment

    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

    Hello world – My first post

    I am currently a PhD Candidate studying Technology Enhanced Learning at Durham University. Have a little look at my website for more info.

    More specifically I am looking at folksonomies and programming to see if there are any applications that could be used to improve undergraduate programming courses.

    I have started this blog to help other coders who are programming on similiar things to me. Primarily, for things that I had problems with or got frustrated with, when I couldnt find help online or on irc.

    Leave a Comment