aspose file tools*
The moose likes Websphere and the fly likes loading property files across modules(WSAD) 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 » Websphere
Bookmark "loading property files across modules(WSAD)" Watch "loading property files across modules(WSAD)" New topic
Author

loading property files across modules(WSAD)

vibeeshan kambli
Ranch Hand

Joined: Jan 22, 2003
Posts: 41
Hi,
I am new to WSAD
I have enterprise application project
which has modules like ejbModule,webModule,clientModule.
Say my enterprise application project directory name is MainProj.
I kept all my property files in MainProj\properties directory
I am trying load property file in ejb module
like getClass().getResourceAsStream("/properties/myprop.properties")
when execute above statement it is looking property file in
ejbModule/properties directory(that means it is looking property file from the module context not from the application context,since my application project directory is MainProj I expect to look from MainProj/properties folder)
do you have any idea how to solve the problem?
how to load property file accross the modules
(I tried resourcebundle approach too..)
Thank in Advance
vishnu
jeff mutonho
Ranch Hand

Joined: Apr 30, 2003
Posts: 271
I use a folder that I call Config and place all my property files in there .I then include that Config folder in my server CLASSPATH.
Hope that works for you.
Cheers
jeff mutonho
Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
What version of the AEs are you using with your WSAD? If you are in version 4, then you could potentially solve the issue by upgrading to 4.0.3.
If you let me know more about the versions, I could give a specific reply. I have struggled a bit with this as well and the answers are so specific to each situation.... therefore the request for more details.


Best Regards,<br />Nagendra Prasad.
vibeeshan kambli
Ranch Hand

Joined: Jan 22, 2003
Posts: 41
jeff && Nagendra
Thanks for your reply
I am using WSAD 5(using Websphere Test Environmnet 5.0 Server inside WSAD 5.0)
Jeff said it works if i modify my server classpath
but if you are working in WSAD 5.0 you have only test environment not server itself( Websphere Application server is not installed on my machine
All the work i am doing in WSAD 5.0 using Websphere Test Enviromnet.)
then how to solve this problem?
if at all i need modify server class path inside WSAD 5.0 how to do that
Any ideas?
Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
hello again...
i am not too sure with wsad 5.0 (i am working on wsad 4.03).. but here goes an attempt anyway..
in the test environment you must be having the test server
instance and its properties must be visible to you..
you must be having an equivalent of the 'paths' tab.In this 'Add Folder'
to your MainProj.
This should let your test env see the files.. let me know how it goes.
[ October 23, 2003: Message edited by: Nagendra Prasad ]
vibeeshan kambli
Ranch Hand

Joined: Jan 22, 2003
Posts: 41
Thanks for the reply Nagendra
I opened Test server instance and I got paths tab
In the paths tab I have entry called classpath
I clicked add folder button and I added my MainProj folder to class path.
still the same problem.
Any ideas greatly appreciated.
jeff mutonho
Ranch Hand

Joined: Apr 30, 2003
Posts: 271
Is your application using that test server?You can create another server and use that to load you ear?
Did you create the Config folder from within the same workspace where your project is?If not , do that and then when you configure you server classpath , click on add folder and the rest is a piece of cake...
Theoretically that should work
Maybe you can turn the versbose on , on your server and copy and pstate the out to us , then we can see if it sees the folder with the properties file.

jeff mutonho
Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
I second jeff's suggestion... seems to way to go.. esp. when we are not having more details..
however.. try the following change to ur code as well...
getClass.getClassLoader().getResourceAsStream"/properties/myprop.properties")
instead of
getClass().getResourceAsStream("/properties/myprop.properties")
this will force the use of the same classloader... and could provide some info as to whether this is a class loader selection problem.
all the best!
vibeeshan kambli
Ranch Hand

Joined: Jan 22, 2003
Posts: 41
Hi Jeff && Nagendra
Thank you very much!!
I deleted my old test server and created new test server
and deployed my EAR file over it
(it should work with my old test server ,but some how it does not)
It worked
I am able to load my property files
thank you very much
but one more thing ...
when ever i am creating a new file its getting created in
"C:\ProgramFiles\IBM\WebsphereStudio"
I am using File f = new File("a.txt");
How to change path?I need file to be created in my application context
Thanks

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: loading property files across modules(WSAD)