• Bug
  • Status: In Progress
  • 2 Major
  • Resolution:
  • ehcache-core
  • reinra
  • Reporter: reinra
  • May 16, 2011
  • 0
  • Watchers: 3
  • March 28, 2013


Environment: ColorCache sample application Java 1.6.0_24 Mac OS X 10.6.7

Error stacktrace:

java.lang.ArrayIndexOutOfBoundsException: 0 at java.net.InetAddress.getLocalHost(InetAddress.java:1356) at com.tc.config.schema.dynamic.ParameterSubstituter.getIpAddress(ParameterSubstituter.java:173) at com.tc.config.schema.dynamic.ParameterSubstituter.substitute(ParameterSubstituter.java:52) at com.tc.object.config.schema.L2DSOConfigObject.initializeNameAndHost(L2DSOConfigObject.java:216) at com.tc.object.config.schema.L2DSOConfigObject.initializeServers(L2DSOConfigObject.java:135) at com.tc.config.schema.setup.StandardXMLFileConfigurationCreator.getConfigFromSourceStream(StandardXMLFileConfigurationCreator.java:495) at com.tc.config.schema.setup.StandardXMLFileConfigurationCreator.loadConfigurationData(StandardXMLFileConfigurationCreator.java:405) at com.tc.config.schema.setup.StandardXMLFileConfigurationCreator.loadConfigDataFromSources(StandardXMLFileConfigurationCreator.java:218) at com.tc.config.schema.setup.StandardXMLFileConfigurationCreator.loadConfigAndSetIntoRepositories(StandardXMLFileConfigurationCreator.java:116) at com.tc.config.schema.setup.StandardXMLFileConfigurationCreator.createConfigurationIntoRepositories(StandardXMLFileConfigurationCreator.java:98) at com.tc.config.schema.setup.BaseConfigurationSetupManager.runConfigurationCreator(BaseConfigurationSetupManager.java:122) at com.tc.config.schema.setup.L2ConfigurationSetupManagerImpl.(L2ConfigurationSetupManagerImpl.java:112) at com.tc.config.schema.setup.StandardConfigurationSetupManagerFactory.createL2TVSConfigurationSetupManager(StandardConfigurationSetupManagerFactory.java:208) at com.tc.server.TCServerMain.main(TCServerMain.java:29)

Steps to reproduce:

  1. Add an alias to your localhost interface: sudo ifconfig lo0 alias
  2. Turn AirPort Off: sudo ifconfig en1 down
  3. Start the Sample Server: ehcache-2.4.2/samples/colorcache/bin/start-sample-server.sh


Tim Eck 2011-05-16

I don’t quite understand why this would be considered a ehcache/terracotta bug.

I suppose we could fail with a more meaningful exception, but the problem lies in the core JDK library code and/or your local configuration. You don’t need anything related to ehcache to reproduce the exception.

Fiona OShea 2011-05-17

Please review Tim’s comments

Rein Raudjarv 2011-05-18

Thanks for a quick response and sorry for my delay!

I understand that the particular error comes from the JDK library code. However I am interested in using EHCache when I’m offline (e.g. in a plane) and using a localhost interface alias. Is there an option I could for example skip this failing JDK invocation?

The actual problem I have is related to Play framework which uses EHCache: http://play.lighthouseapp.com/projects/57987/tickets/813-unexpected-error-with-localhost-interface-aliases If there’s a good way to configure EHCache to be used offline it could solve the issue.

Tim Eck 2011-05-18

Okee doke. Well it seem there are maybe 3 unique issues at hand.

The first is the problem inherit in the JDK code. Not sure if that is bug for apple or oracle or both, but obviously not for terracotta.

The ticket on the play site is actually a different code path than the one reported here. This one has to do with the terracotta server whereas the other one is the ehcache-core library.

You should be able to workaround the terracotta server issue by providing a tc-config.xml where the has a defined "name" attribute. That will at least prevent us from trying use the default of "%i" which hits this problem in InetAddress.getLocalHost()

The code in ehcache-core [net.sf.ehcache.Cache.(Cache.java:155)] looks like it tries to be tolerant of some errors. It could maybe be expanded to be tolerant of \*any\* exception.

In general I’m not too wild about adding too many workarounds and would rather concentrate on getting the core problem fixed in the JDK or finding a way to avoid it.

Eugene Shelestovich 2013-03-28

Looks like a known bug on Mac OS X Lion (http://stackoverflow.com/questions/7892609/inetaddress-getlocalhost-resolution-on-osx-lion-when-offline). A temporary workaround is to run:

sudo ifconfig en0 alias

on a client machine.

It is fixed in rev 22522 by substituting a localhost IP address in case of ArrayIndexOutOfBoundsException.

Eugene Shelestovich 2013-03-28

For some reason I cannot put the ticket in a resolved state.