WebModuleUtilTest failure

Hi

(Running Ubuntu 17.10; java 1.8.0_25; Maven 3.1.1)

I have checked out the latest openmrs-core (based on https://github.com/openmrs/openmrs-core.git) and have run mvn install.

I get this error when running tests:

startModule_shouldCreateDwrModulesXmlIfNotExists(org.openmrs.module.web.WebModuleUtilTest)  Time elapsed: 0.319 sec  <<< ERROR!
java.lang.BootstrapMethodError: call site initialization exception
	at java.lang.Class.cast(Class.java:3361)
	at java.lang.invoke.MethodHandles.constant(MethodHandles.java:2137)
	at java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:216)
	at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:304)
	at java.lang.invoke.CallSite.makeSite(CallSite.java:289)
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:296)
	at org.openmrs.module.web.WebModuleUtil.getDWRModuleXML(WebModuleUtil.java:660)
	at org.openmrs.module.web.WebModuleUtil.startModule(WebModuleUtil.java:251)
	at org.openmrs.module.web.WebModuleUtilTest.startModule_shouldCreateDwrModulesXmlIfNotExists(WebModuleUtilTest.java:119)

startModule_dwrModuleXmlshouldContainModuleInfo(org.openmrs.module.web.WebModuleUtilTest)  Time elapsed: 0 sec  <<< ERROR!
java.lang.BootstrapMethodError: call site initialization exception
	at java.lang.Class.cast(Class.java:3361)
	at java.lang.invoke.MethodHandles.constant(MethodHandles.java:2137)
	at java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:216)
	at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:304)
	at java.lang.invoke.CallSite.makeSite(CallSite.java:289)
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:296)
	at org.openmrs.module.web.WebModuleUtil.getDWRModuleXML(WebModuleUtil.java:660)
	at org.openmrs.module.web.WebModuleUtil.startModule(WebModuleUtil.java:251)
	at org.openmrs.module.web.WebModuleUtilTest.startModule_dwrModuleXmlshouldContainModuleInfo(WebModuleUtilTest.java:144)

On examination this relates to changes made in WebModuleUtil.java - at line 660 there is the following:

		db.setEntityResolver((publicId, systemId) -> {
			// When asked to resolve external entities (such as a DTD) we return an InputSource
			// with no data at the end, causing the parser to ignore the DTD.
			return new InputSource(new StringReader(""));
		});

Before the changes the code was:

		db.setEntityResolver(new EntityResolver() {
			
			@Override
			public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
				// When asked to resolve external entities (such as a DTD) we return an InputSource
				// with no data at the end, causing the parser to ignore the DTD.
				return new InputSource(new StringReader(""));
			}
		});

(This also requires the re-introduction of two imports for org.xml.sax.EntityResolver and org.xml.sax.SAXException).

When I revert this change WebModuleUtilTest runs happily, and the whole test suite completes. I’ve no idea why these changes don’t work for me, but presumably do work for everyone else.

Jerry

What does this return? mvn -v

jerry@oap:~$ mvn -v
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 16:22:22+0100)
Maven home: /sdb/home/jerry/apache-maven-3.1.1
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /sdb/home/jerry/jdk1.8.0_25/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-32-generic", arch: "amd64", family: "unix"

This looks like a JDK bug. Can you upgrade to the latest Java 1.8.x release?

1 Like

Excellent. Upgrading to jdk1.8.0_162 does indeed fix it.