Fork me on GitHub
#graalvm
<
2021-03-10
>
ouvasam12:03:48

Hi, i wonder how i can include a file (xsd) the native-image ? I did try -H:IncludeResources='.*/Resource.*txt$ and then try to use (io/resource "Resource.txt") but it doesn't work

ouvasam12:03:44

Wow many thanks ! and you can then use it with io/resource ?

ouvasam12:03:08

Ok many thanks can't make it work and i have almost the samle structure. I'll see with you compilation parameters if i miss something

borkdude12:03:48

Is that dir even on your classpath? Are you able to get it in on the JVM?

ouvasam12:03:03

It is ok now i found my error ... Many thanks to you both, for the quick help and for the faboulous tools you bring to clojure !!!!

borkdude12:03:20

Note that the resource pattern must be relative to your classpath, not your working dir

ouvasam13:03:13

Also i have this code that work with lein run but not once compiled as native-image (InputSource. (http://clojure.java.io/input-stream (.getBytes data)))

ouvasam13:03:28

** ERROR: **
Exception: #error {
 :cause No matching field found: getBytes for class java.lang.String
 :via
 [{:type java.lang.IllegalArgumentException
   :message No matching field found: getBytes for class java.lang.String
   :at [clojure.lang.Reflector getInstanceField Reflector.java 397]}]
 :trace
 [[clojure.lang.Reflector getInstanceField Reflector.java 397]
  [clojure.lang.Reflector invokeNoArgInstanceMember Reflector.java 440]
  [sm_validator_cli.core$create_xml_doc invokeStatic core.clj 43]

borkdude13:03:04

@U0F7M1KA7 You need to avoid reflection warnings with (set! *warn-on-reflection* true)

ouvasam13:03:39

Thanks but this does not work too

ouvasam13:03:53

Typehint seems to work for this part (InputSource. (http://clojure.java.io/input-stream (.getBytes ^java.lang.String data)))

ouvasam13:03:15

now i have

(InputSource. ( (.getBytes data))) ** ERROR: **
Exception: #error {
 :cause org.apache.xerces.parsers.ObjectFactory
 :via
 [{:type java.lang.NoClassDefFoundError
   :message nil
   :at [org.apache.xerces.parsers.ObjectFactory class$ nil -1]}
  {:type java.lang.ClassNotFoundException
   :message org.apache.xerces.parsers.ObjectFactory
   :at [com.oracle.svm.core.hub.ClassForNameSupport forName ClassForNameSupport.java 60]}]
 :trace
 [[com.oracle.svm.core.hub.ClassForNameSupport forName ClassForNameSupport.java 60]