<< Back to previous view

[DXML-32] data.xml fails when used with Java 9 Created: 27/May/16  Updated: 22/Nov/16

Status: Open
Project: data.xml
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Toby Crawley Assignee: Ryan Senior
Resolution: Unresolved Votes: 0
Labels: None


Java 9's module system (Jigsaw) appears to prevent loading of some of the XML classes. Java 9 isn't due to be released until March 2017, so there isn't a huge rush to fix this, but I wanted to make you aware. Unfortunately, I don't have enough knowledge of the module system to suggest the proper fix/workaround.

tcrawley@katahdin ~/w/c/data.xml> mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building data.xml 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ data.xml ---
[INFO] --- build-helper-maven-plugin:1.5:add-source (add-clojure-source-dirs) @ data.xml ---
[INFO] Source directory: /home/tcrawley/work/clojure/data.xml/src/main/clojure added.
[INFO] --- build-helper-maven-plugin:1.5:add-resource (add-clojure-source-dirs) @ data.xml ---
[INFO] --- build-helper-maven-plugin:1.5:add-test-source (add-clojure-test-source-dirs) @ data.xml ---
[INFO] Test Source directory: /home/tcrawley/work/clojure/data.xml/src/test/clojure added.
[INFO] --- build-helper-maven-plugin:1.5:add-test-resource (add-clojure-test-source-dirs) @ data.xml ---
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ data.xml ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/tcrawley/work/clojure/data.xml/src/main/resources
[INFO] Copying 13 resources
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ data.xml ---
[INFO] Nothing to compile - all classes are up to date
[INFO] --- clojure-maven-plugin:1.3.13:compile (clojure-compile) @ data.xml ---
Compiling clojure.data.xml.name to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.node to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.name to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.emit to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.prxml to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.impl to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.tree to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.pprint to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.process to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.protocols to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.jvm.parse to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml to /tmp/classes8428993250598039353.dir
Compiling clojure.data.xml.event to /tmp/classes8428993250598039353.dir
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ data.xml ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 9 resources
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ data.xml ---
[INFO] Nothing to compile - all classes are up to date
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ data.xml ---
[INFO] --- clojure-maven-plugin:1.3.13:test (clojure-test) @ data.xml ---
Exception in thread "main" java.lang.IllegalAccessException: class clojure.lang.Reflector cannot access class com.sun.xml.internal.stream.XMLInputFactoryImpl (in module java.xml) because module java.xml does not export com.sun.xml.internal.stream to unnamed module @1704f67f, compiling:(test_emit.clj:18)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3387)
	at clojure.lang.Compiler$DefExpr.eval(Compiler.java:398)
	at clojure.lang.Compiler.eval(Compiler.java:6516)
	at clojure.lang.Compiler.load(Compiler.java:6952)
	at clojure.lang.RT.loadResourceScript(RT.java:359)
	at clojure.lang.RT.loadResourceScript(RT.java:350)
	at clojure.lang.RT.load(RT.java:429)
	at clojure.lang.RT.load(RT.java:400)
	at clojure.core$load$fn__4890.invoke(core.clj:5415)
	at clojure.core$load.doInvoke(core.clj:5414)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invoke(core.clj:5227)
	at clojure.core$load_lib.doInvoke(core.clj:5264)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invoke(core.clj:603)
	at clojure.core$load_libs.doInvoke(core.clj:5298)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invoke(core.clj:603)
	at clojure.core$require.doInvoke(core.clj:5381)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval1038.invoke(run-test9074553612640357429.clj:5)
	at clojure.lang.Compiler.eval(Compiler.java:6511)
	at clojure.lang.Compiler.load(Compiler.java:6952)
	at clojure.lang.Compiler.loadFile(Compiler.java:6912)
	at clojure.main$load_script.invoke(main.clj:283)
	at clojure.main$script_opt.invoke(main.clj:343)
	at clojure.main$main.doInvoke(main.clj:427)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.lang.Var.invoke(Var.java:415)
	at clojure.lang.AFn.applyToHelper(AFn.java:161)
	at clojure.lang.Var.applyTo(Var.java:532)
	at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalAccessException: class clojure.lang.Reflector cannot access class com.sun.xml.internal.stream.XMLInputFactoryImpl (in module java.xml) because module java.xml does not export com.sun.xml.internal.stream to unnamed module @1704f67f
	at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base@9-ea/Reflection.java:405)
	at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base@9-ea/Reflection.java:396)
	at jdk.internal.reflect.Reflection.ensureMemberAccess(java.base@9-ea/Reflection.java:98)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(java.base@9-ea/AccessibleObject.java:355)
	at java.lang.reflect.AccessibleObject.checkAccess(java.base@9-ea/AccessibleObject.java:347)
	at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:525)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
	at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
	at clojure.data.xml.jvm.parse$make_stream_reader.invoke(parse.clj:116)
	at clojure.data.xml$event_seq.invoke(xml.clj:57)
	at clojure.data.xml$parse.doInvoke(xml.clj:67)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at clojure.core$comp$fn__4034.invoke(core.clj:2279)
	at clojure.lang.AFn.applyToHelper(AFn.java:161)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3382)
	... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.133 s
[INFO] Finished at: 2016-05-27T17:48:41-04:00
[INFO] Final Memory: 13M/300M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.theoryinpractise:clojure-maven-plugin:1.3.13:test (clojure-test) on project data.xml: Clojure failed. -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
tcrawley@katahdin ~/w/c/data.xml> java -version
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+119)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+119, mixed mode)

Comment by Toby Crawley [ 22/Nov/16 10:02 AM ]

This is caused by http://dev.clojure.org/jira/browse/CLJ-2066

Comment by Herwig Hochleitner [ 22/Nov/16 9:38 PM ]

Unless the reflector is fixed on time for a java 9 release, we'll have to work around this in data.xml by adding appropriate annotations to avoid reflection.

[DXML-27] Provide serialization for XML Schema built-in data types Created: 15/Jun/15  Updated: 24/Nov/16

Status: Open
Project: data.xml
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Adam Neilson Assignee: Herwig Hochleitner
Resolution: Unresolved Votes: 0
Labels: None

Clojure version 1.7
data.xml 0.8
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


data.xml doesn't currently serialize all the data types specified in https://www.w3.org/TR/xmlschema-2/#built-in-datatypes

data.xml should provide automatic serialization for all well-known clojure/jvm types, that have an xmlschema built-in mapping.

Current support


ints and floats probably work as expected, ratios need to serialize to decimals.


Not currently covered. XML Schema defines duration, dateTime, time and date based on ISO 8601. Thus, clojure's formatting of dates should be reusable. Additionally, the new java.time package should be considered.

URIs/binary data

uris need to be supported, binary data could be serialized as base64Binary or hexBinary


QNames don't currently support being serialized standalone. It makes a lot of sense, though, to support serializing qnames with the prefix they have in their xml environment.


Element java.util.Date throws IllegalArgumentException

This seems very similar to DXML-14 but given the lib has been in the wild a while I would have expected this to have been reported already. Can't find a bug report though so submitted here for the record.

I ran this the first time and it seemed fine but all subsequent executions result in this error:

(emit-str (element :something {} #inst "2015-06-15T16:53:18.470-00:00"))
IllegalArgumentException No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: java.util.Date  clojure.core/-cache-protocol-fn (core_deftype.clj:544)

Comment by Adam Neilson [ 15/Jun/15 12:18 PM ]

Actually clojure version is 1.6.0

Comment by Herwig Hochleitner [ 24/Nov/16 11:28 PM ]

I was about to decline this ticket due to scope creep, then I had a look at xml schema and I think the built-in datatypes there establish a well-defined boundary of what to expect data.xml to serialize by default.

Generated at Tue Jan 17 15:31:41 CST 2017 using JIRA 4.4#649-r158309.