Error loading Groovy config file from JAR

rhinds

I have an application that is running on compiled Groovy code in a jar.

The groovy code is all being loaded/executed correctly, however, I have a step that attempts to load a groovy-config file from the root of the JAR, but it is failing.

The code below is from a groovy class that is being run from the JAR, and here it attempts to load the groovy config file config.props from the root of the jar:

URL url = this.getClass().getClassLoader().getResource("config.props")
logger.info( url.toString() )
if(!url)throw new IllegalArgumentException("'$resource' not found ")
GroovyScriptEngine gse = new GroovyScriptEngine( url )
...
gse.run(url.file, binding)

When I run the above I get the following error:

Message: Cannot open URL: jar:file:/usr/local/libs/test-all.jar!/config.props

Does anyone have any idea how to load a file from a root of a jar? I have temporarily set the permissions to 777 and have checked that the file exists/spelling correct.

rhinds

Ok - I think I have resolved this.

It looks like the error was in

gse.run(url.file, binding)

the url.file passed the full absolute path including file: protocol to the gse - I changed this to just "config.props" and it seemed to have got past this (there is another error now, but seems to be further on).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error when creating JavaFX jar file from codes written in Groovy

From Dev

Host not loading from config file

From Dev

Assigning values dynamically from a groovy config file

From Dev

Assigning values dynamically from a groovy config file

From Dev

Loading Java spark config from yaml file

From Dev

uwp loading config from a file at startup

From Dev

Java Image Loading from .jar File

From Dev

'URI is not hierarchical' when loading a file from a .jar

From Dev

Loading resource from JAR or file system with getResourceAsStream

From Dev

Dynamic Class Loading From Jar File

From Dev

Keystore not loading JKS file from within jar

From Dev

Loading files from java jar file

From Dev

'URI is not hierarchical' when loading a file from a .jar

From Dev

Dynamic Class Loading From Jar File

From Dev

Executing a Java jar file from within a SoapUI groovy script not working

From Dev

Jenkins groovy pipeline - Need stdout of command from executing jar file

From Dev

scala- error loading a properties file packed inside jar

From Dev

Error loading solr config from solrconfig.xml

From Dev

Scalatra loading static content from executable jar file

From Dev

Loading docx file from resources folder in runnable jar

From Dev

Loading Fonts from Jar while writing PDF-A (archive) file

From Dev

Scalatra loading static content from executable jar file

From Dev

JAX-RS - Loading @Provider classes from a jar file

From Dev

Elasticsearch groovy script loading error

From Dev

DNS Error: Loading from master file failed:

From Dev

Getting error in loading json from static file?

From Dev

Docker non-root access: Error loading config file:stat /home/wu/.docker/config.json

From Dev

error in importing the file from jar in java

From Dev

Error while downloading JAR file from repo

Related Related

  1. 1

    Error when creating JavaFX jar file from codes written in Groovy

  2. 2

    Host not loading from config file

  3. 3

    Assigning values dynamically from a groovy config file

  4. 4

    Assigning values dynamically from a groovy config file

  5. 5

    Loading Java spark config from yaml file

  6. 6

    uwp loading config from a file at startup

  7. 7

    Java Image Loading from .jar File

  8. 8

    'URI is not hierarchical' when loading a file from a .jar

  9. 9

    Loading resource from JAR or file system with getResourceAsStream

  10. 10

    Dynamic Class Loading From Jar File

  11. 11

    Keystore not loading JKS file from within jar

  12. 12

    Loading files from java jar file

  13. 13

    'URI is not hierarchical' when loading a file from a .jar

  14. 14

    Dynamic Class Loading From Jar File

  15. 15

    Executing a Java jar file from within a SoapUI groovy script not working

  16. 16

    Jenkins groovy pipeline - Need stdout of command from executing jar file

  17. 17

    scala- error loading a properties file packed inside jar

  18. 18

    Error loading solr config from solrconfig.xml

  19. 19

    Scalatra loading static content from executable jar file

  20. 20

    Loading docx file from resources folder in runnable jar

  21. 21

    Loading Fonts from Jar while writing PDF-A (archive) file

  22. 22

    Scalatra loading static content from executable jar file

  23. 23

    JAX-RS - Loading @Provider classes from a jar file

  24. 24

    Elasticsearch groovy script loading error

  25. 25

    DNS Error: Loading from master file failed:

  26. 26

    Getting error in loading json from static file?

  27. 27

    Docker non-root access: Error loading config file:stat /home/wu/.docker/config.json

  28. 28

    error in importing the file from jar in java

  29. 29

    Error while downloading JAR file from repo

HotTag

Archive