aspose file tools*
The moose likes JBoss/WildFly and the fly likes How to get the Codebase path? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to get the Codebase path?" Watch "How to get the Codebase path?" New topic
Author

How to get the Codebase path?

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
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?


Thanks,
Kumar
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

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

Joined: Mar 19, 2008
Posts: 261
hi Paul,

Thanks for replying..

I tried with your suggestion, but I get NullPointerException, that is InputStream is getting null.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Then you've given the wrong path for your resource relative to the classpath.
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
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
 
Consider Paul's rocket mass heater.
 
subject: How to get the Codebase path?