scala - Can't get path to resource -


I'm trying to use Scala macro annotation with the library.

I have a schema file to src / main / resources / avsc / FriendRequestAcceptedGson.avsc

I thus refer to it in your code I am trying to do:

  @AvroTypeProvider ( "/avsc/FriendRequestAcceptedGson.avsc") @AvroRecord case class FriendRequestAcceptedGson ()  

this is the error I get:

[error] / home / Lee /Code/bigdata-friends/java/etl/src/main/scala/com/mxit/bd/friends/etl/Runner.scala : 64: Exception during macro expansion: [error] java.io.FileNotFoundException: / avsc / FriendRequestAcceptedGson.avsc (Such a file or instruction [Error] java.io.phileInputStream.open (Native Method) on [error] on java.io.FileInputStream & Lt; Init & gt; (FileInputStream.java:146) on [error] Org.codehaus.jackson.JsonFactory.createJsonParser (JsonFactory.java:504) [error] at org.apache.avro.Schema $ Parser.parse (Skimakjawa: 9, 22) [error] [eRROR] com.julianpeeters.avro.annotations.AvroTypeProviderMacro at $ .impl (TypeProviderMacro.scala: 23) [error] @AvroTypeProvider: com.julianpeeters.avro.annotations.util.SchemaParser $ .getSchema (20 SchemaParser. Scala) on ( "/avsc/FriendRequestAcceptedGson.avsc")

resource his JAR file Are compiled in You should meet them with Classloader, not in the file system. The Java.io.FIle class only knows how to check the file system. Now, if you are trying to open the source file (which may not exist if the jar is deployed), it will depend on what is in relation to your current working directory file. It's likely to be on the root, so the path you need to use is absolute relative: src / main / resources / avsc / FriendRequest are accepted.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -