• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-core
  • hhuynh
  • Reporter: jpollak
  • September 15, 2010
  • 0
  • Watchers: 1
  • July 27, 2012
  • September 24, 2010

Description

We have what is probably a fairly rare situation, but I think the actual problem might be common, and it should be an easy fix.

We are launching an app via JNLP (WebStart) which has ehcache embedded, and the ehcache.xml file is embedded in our jar file. The application and config file works perfectly when launched normally, but when launched via JNLP, we get the following error. Unfortunately, you will see at the bottom of the stack trace that the BeanHandler prints the following out:

{quote} Caused by: org.xml.sax.SAXException: null:69: Could not create nested element . at net.sf.ehcache.config.BeanHandler.createChild(BeanHandler.java:173) \{quote\}

When I look at this line of code I see:

172  } catch (final Exception e) {
173            throw new SAXException(getLocation() + ": Could not create nested element <" + name + ">.");
174  }

In other words, the BeanHandler swallows the root-cause exception, and substitutes its own error message. This is making it nearly impossible for me to figure out what is going wrong and come up with a solution. (I know it is not the configuration, because the configuration works file locally).

The full stack trace is below for more context (I’ve obfuscated references to my code, but otherwise its the exact trace):

{quote} Caused by: net.sf.ehcache.CacheException: Error configuring from jar:http://localhost:8080/libs/myproduct.jar!/com/mypackage/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was null:69: Could not create nested element . at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:103) at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:496) at net.sf.ehcache.CacheManager.init(CacheManager.java:286) at net.sf.ehcache.CacheManager.(CacheManager.java:249) at com.myproduct.dao.PersistenceManagerImpl.(PersistenceManagerImpl.java:68) at com.myproduct.dao.PersistenceManagerImpl.getInstance(PersistenceManagerImpl.java:50) ... 41 more Caused by: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:69: Could not create nested element . at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:157) at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:101) ... 47 more Caused by: org.xml.sax.SAXException: null:69: Could not create nested element . at net.sf.ehcache.config.BeanHandler.createChild(BeanHandler.java:173) at net.sf.ehcache.config.BeanHandler.startElement(BeanHandler.java:104) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:198) at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:155) ... 48 more \{quote\}

Comments

Joshua Chaitin-Pollak 2010-09-15

I modified the code snippet above as follows:

        } catch (final Exception e) {
            throw new SAXException(getLocation() + ": Could not create nested element <" + name + ">.", e);
        }

And now I see the root cause:

{quote} Caused by: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:69: Could not create nested element . at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:157) at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:101) ... 47 more Caused by: java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks) at net.sf.ehcache.config.BeanHandler.createChild(BeanHandler.java:173) at net.sf.ehcache.config.BeanHandler.startElement(BeanHandler.java:104) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:198) at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:155) ... 48 more Caused by: java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:107) at net.sf.ehcache.config.BeanHandler.createInstance(BeanHandler.java:209) at net.sf.ehcache.config.BeanHandler.createChild(BeanHandler.java:170) ... 62 more \{quote\}

Again, this bug is NOT about fixing the root cause, its about just reporting the root cause.

Thanks.

Gary Keim 2011-06-03

And what WAS the root cause? A missing security policy entry? A bug in Ehcache not invoking setAccessible(true) on the Method? I’m getting another report that matches this one.

Tim Eck 2011-06-03

The way I read this JIRA is that the setAccessible() call(s) in BeanHandler can (and will) fail if (a) there is security manager in place (like with JNLP) and (b) no permissions are granted.

I think the only “fix” that was made here was to not swallow the underlying exception.

Joshua Chaitin-Pollak 2011-11-09

{quote} And what WAS the root cause? A missing security policy entry? A bug in Ehcache not invoking setAccessible(true) on the Method? I’m getting another report that matches this one. {quote}

For future reference for people like myself (who re-ran into this bug and rediscovered my own bug report), the following must be set BEFORE Spring is initialized:

 System.setSecurityManager(null);

I believe this will only work if your JNLP application is running completely trusted by the host.