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 Java 8 in Action this week in the Java 8 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: 260
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: 18150
    
    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: 260
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: 18150
    
    8

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

Joined: Mar 19, 2008
Posts: 260
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
 
 
subject: How to get the Codebase path?
 
Similar Threads
Can't find properties file path when running uner 4.0.3 Test environment
Loading properties file into Servlet
Unable to access config files from a servlet
cannot load property file from WAR
Unable to load a .properties file