<< Previous | Home

Fixing EhCache / Tomcat memory leak warnings.

We were receiving messages such as this:

The web application [/services] appears to have started a thread named [net.sf.ehcache.CacheManager@37ce6a10] but has failed to stop it. This is very likely to create a memory leak.

The solution, in our groovy based spring web app that uses annotation based configuration, was to register the net.sf.ehcache.constructs.web.ShutdownListener class with the context in our class that extends WebApplicationInitializer via an overridden onStartup() method, something like this:

import net.sf.ehcache.constructs.web.ShutdownListener
import org.springframework.web.WebApplicationInitializer
...

public class CustomWebApplicationInitializer implements WebApplicationInitializer {
    ...

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        ...
        createContext(...)
        ...
    }

    private AnnotationConfigWebApplicationContext createContext(final Class... annotatedClasses) {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext()
        context.register(annotatedClasses)
        context.register(ShutdownListener)
        return context
    }
}

More information can be found here: http://ehcache.org/documentation/operations/shutdown

Adding a custom test phase to Grails 2.3

Here's a snippit showing how to add a custom test phase and to exclude other phases, this code is pretty raw but should help you in figuring things out. The way that test phases are created has changed alot since grails 1.3 and the grails documentation doesn't show how to do it. Also as of November 2013 Luke Daley's blog post on the subject from the grails 1.3.7 days has disappeared.

scripts/_Events.groovy

buildRawGrailsEnv = {
    return System.getProperties().get('grails.env').toString().toLowerCase()
}

eventTestPhasesStart = { phasesToRun ->

    // background: in our codebase we have an environment called 'remote' and the only valid phases for that environment is the new 'remote' phase.

    // if the environment is not 'remote' then do not add the new phase.
    String rawGrailsEnv = buildRawGrailsEnv()
    if (!rawGrailsEnv.equals('remote')) {
        return
    }

    // exclude all other phases except the new 'remote' phase.
    def phasesToExclude = phasesToRun.collect { return it }
    phasesToRun << "remote"
    phasesToExclude.each {
        phasesToRun.remove(it)
    }

    def remotePhaseConfigurer = new IntegrationTestPhaseConfigurer(projectTestRunner.projectTestCompiler, projectLoader)
    projectTestRunner.testFeatureDiscovery.configurers.remote = remotePhaseConfigurer

    def remoteTestTypeName = "remote"
    def remoteTestDirectory = "remote"
    def remoteTestMode = new GrailsTestMode(autowire: true, wrapInTransaction: true, wrapInRequestEnvironment: true)
    def remoteTestType = new GrailsSpecTestType(remoteTestTypeName, remoteTestDirectory, remoteTestMode)

    projectTestRunner.testFeatureDiscovery.testExecutionContext.remoteTests = [remoteTestType]
}

remoteTestPhasePreparation = {
    // called at the start of the phase
    println "*** Starting remote tests"
    integrationTestPhasePreparation()
}

remoteTestPhaseCleanUp = {
    // called at the end of the phase
    println "*** Finished remote tests"
    integrationTestPhaseCleanUp()
}

ASUS P5K-E Wifi with ATI 5870 Triple Screen hackintosh

Guide Version: 1 – 17/April/2011

Hardware

  • Mobo: ASUS P5K-E Wifi/AP (Network: Marvel 88E8056 Gigabit, Vendor: 0×11ab, Device: 0×4364, SS Vendor: 0×1043, SS: 0×81f8)
  • CPU: Intel E8200
  • OCZ 2×2GB RAM OCZ2P8002G (Slots A1/B1)
  • GFX: HIS 5870 (VendorID: ATI 0×1002, Device ID: 0×6898, Revision ID: 0×0000)
  • Optical Drive: Pioneer DVR-218L / 1.02 / SATA
  • HDD: Old Seagate 7200.11 SATA drive (for testing, will move to Seagate Momentus XT later)

HIS ATI 5870 Bios: HIS.HD5870.1024.091112.bin from Tech Power-Up, Flashed using ATIWinFlash in Windows (I did this before I used the card in my hackintosh box, unsure if older BIOS revisions work on hackintosh)

ASUS P5K-E Wifi Bios Version: 1305

Needed stuff

  • Multibeast 3.4 (latest as of 17/4/2011)
  • IBoot (latest as of 17/4/2011)
  • Kaybl bootloader – http://www.insanelymac.com/forum/index.php?showtopic=231768 (patch commit revision 700 (09.01.2011))
  • DSDTAutoPatcher

BIOS Settings

Load Setup Defaults

  • Configure SATA as: AHCI
  • ACPI v2: enabled
  • JMicron disabled (to be enabled later)
  • Suspend Mode: S3 Only
  • ACPI 2.0 support: Enabled

The procedure and notes

Boot IBoot cd

Problem #1:

IBoot comes up with ‘ebios read error’

Solution:

Removing SATA cable, then booting IBoot CD, then inserting SL DVD, then pressing F5 then quickly connecting HDD SATA Cable back to HDD allows system to boot.

Problem #2:

Install CD fails to boot to a GUI. The Apple logo appears, following by spinning circle but no GUI appears

Solution 1:

Use Rebel EFI to boot the DVD instead of IBoot (also means you don’t have to fiddle with SATA cables, however this, didn’t allow me to get native res and accelerated graphics when using it to boot from the HDD)

Solution 2:

Use iBoot-ATI-5xxx-3.iso to boot the DVD (although unavailable from tonymac site and you still have to fiddle with SATA cables)

Create 2 partitions using disk utility before continuing with the installer (one for boot, one for bootable backup) GPT style, not MBR.

Install OSX. Might say failed after copying the files, ignore and reboot using IBoot ATI boot cd.

Install OSX 10.6.7 combo update, wait till the restart prompt appears, don’t click it, then run MultiBeast, select EasyBeast and PCIRootUID fix

Could boot off HDD using IBoot ATI boot cd with boot arguments (just type in once you cursor over to the HDD in the IBoot chameleon boot menu):
PCIRootUID=1

Installed experimental ATI Chameleon bootloader (without ATI support attempting to boot from HDD resulted in the graphics cards fans being turned on full – power cycle required!)

This allowed booting from HD but not to GUI

Could get into single user mode from HDD with:
arch=i386 PCIRootUID=1 -s

Create a DSDT file using DSDTAutoPatcher (selecting Asus, P5K-E Wifi/AP), install as /Extra/dsdt.aml

Remove the following kexts from /Extras:
EvOreboot.kext
LegacyAppleRTC.kext
NullCPUPowerManagement.kext

Could then boot with arch=x86_64 (no other options)

Display port would not work

Installed Kaybl bootloader – http://www.insanelymac.com/forum/index.php?showtopic=231768

sudo su – gzip -d boot.gz
mv boot kaybl-boot
mv /boot/boot.multibeast
cp kaybl-boot /boot

FYI, the unarchived kaybl-boot file was 297152 bytes long, the one i had before that was 199712 bytes long

Made no difference, but there was some settings to try:

Set AtiConfig=Uakari in boot plist after looking at source here: http://forge.voodooprojects.org/p/chameleon/source/tree/HEAD/branches/Kabyl/i386/libsaio/ati.c

That enabled DisplayPort and a second monitor using the top DVI port, plugging in an HDMI cable resulted in all three monitors being detected but only the output on the displayport worked.

Moving the DVI cable to the bottom DVI port restored a display on a second monitor, still only 2 displays however.

Using AtiConfig=Zonalis only enabled bottom DVI port (this was probably the previous default)

Weirdly, after a reboot (using AtiConfig=Uakari, still in boot plist from before), with DVI cable in bottom port, DVI-VGA in top port and Display Port all three monitors worked! Need to cold boot to check it works twice.

Yay, still works after a cold boot, GFX done!

Wifi and JMicron IDE not working yet.

Went back into bios:
JMicron Controller: enabled
Controller Mode: AHCI

Rebooted, JMicron JMB363 AHCI listed in System Profiler ‘Serial-ATA’ section, had a Pioneer DVR-110D connected via IDE cable, popped in a DVD and it appeared on the Desktop.

Note: From Multibeast selected Lnx2Mac Realtek RTL81xx driver, which fired up another installed, installed ‘Release’ version of driver, rebooted – that failed, killed regular ethernet because it moved the IONetworkingFamily.kext driver to my desktop, removed /S/L/E/RealtekRTL81xx.kext, restored IONetworkingFamily.kext to /E/E)

Realtek 8187L driver on their site is for OSX 10.5 which some people report as working in 32bit mode, but we’re using x86_64 so just gonna leave it as not-working.

Aside form the Wifi, all the hardware seems to be working!