1

I have deployed on war under WildFly-9.0.2 and in java code I want to get absolute path for one of the jar which is available under helloworld.war/WEB-INF/lib/ directory, I am trying with following java code

Thread.currentThread().getContextClassLoader().getResource("WEB-INF/lib/demo.jar/")

This was working in JBoss 4.0.5, but in WildFly 9 it gives null,

If I try with following code

Thread.currentThread().getContextClassLoader().getResources("")

Then I can see the file as follow, but for this I have to iterate through all the return collections,

vfs:/C:/Users/alpesh/Desktop/content/helloworld.war/WEB-INF/lib/demo.jar/

So, how can I directly locate the jar path as I was doing on earlier JBoss.

Sevan
  • 669
  • 1
  • 5
  • 18
Alpesh Jikadra
  • 1,692
  • 3
  • 18
  • 38
  • What do you want to do with the resource? – James R. Perkins Jan 13 '16 at 01:25
  • basically that jar having the code which create new database based on user selection and populate predefined data in that new database, there are more than 1 jar for creating different databases as per user selection – Alpesh Jikadra Jan 15 '16 at 04:41
  • Needing get a reference to the actual JAR seems a bit odd. I don't know for sure, but I'd guess that the `WEB-INF/lib` directory is not readable. Using an EJB or something similar you could invoke would avoid having to get the URL to the JAR. – James R. Perkins Jan 16 '16 at 16:05

0 Answers0