• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the Codebase path?

 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Earlier I used to work with IBM WAS server, in my project, I had to load properties files from resource folder located in classes folder.
Inorder to load these properties file I used the following parth


When I used this, I got to load the file during the application run time.

Now I got to work the same thing in another project with JBOSS AS, but I'm failing to load the file and when I see in the logs I get the following
codebase.getPath() =



it supposed be ended at ../WEB-INF/classes,

is there any change to get the path?

is there any alternate way to get the path to load properties file?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a rather roundabout way of getting a resource from the classpath. If you have a resource in the WEB-INF/classes directory -- in your case it appears to be in the resources directory below that -- then you just get it like this:

This works in WAS as well.
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Paul,

Thanks for replying..

I tried with your suggestion, but I get NullPointerException, that is InputStream is getting null.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you've given the wrong path for your resource relative to the classpath.
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right paul,

actually I put all my prop files in resources folder and make this folder in Source folders on build path.
But after build the application, these prop files are storing directly in classes folder, here I didn't find resource folder.

Now I changed the path to



Then working ....


Thank you so much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic