• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

where to keep a property file in ear?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I want to keep a property file in an ear at a common location so that the ejb jar and war both can use it. I tried putting it in meta-inf directory (along with application.xml). then i specified the path in the classpath of manifest. it didn't work

where do i keep the common peoperties file?
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put the properties file in the top level directory i.e. a level above the META-INF.
 
Reena Kher
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
didn't work

i put the property file at top level one level up meta-inf. Secified it in the class path of the manifest. But when i use following statement from a java code -

InputStream in = this.getClass().getResourceAsStream ("general.properties");
properties.load(in);

I get NullPointerException!
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldnt you use the class java.util.ResourceBundle to access the property file instead of using InputStream?

Nick
[ July 20, 2004: Message edited by: Nicholas Cheung ]
 
Reena Kher
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, i tried using that also -

java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("general");

I got following exception -
java.util.MissingResourceException: Can't find bundle for base name general, locale en_US
[ July 20, 2004: Message edited by: Reena Kher ]
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pass the locale to the getBundle method.
 
Reena Kher
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
Pass the locale to the getBundle method.



no luck !
i am really stuck up!
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a jar file that contains the properties file and any other common stuff. Put that jar file in the ear and the jar file name in the manifest classpath of the ear's modules (web app, ejb) that you want to hit it and you should be set.

I've never seen a situation where individual files that the modules will use are placed in the ear outside of a module.
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Create a jar file that contains the properties file and any other common stuff. Put that jar file in the ear and the jar file name in the manifest classpath of the ear's modules (web app, ejb) that you want to hit it and you should be set.


I agree with Ken. This will work fine.
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using Ken Robinson's formula :-) I've never seen such a long discussion about a simple properties file. An automatic build process/system should always been able to put the properties file in all the jars where it is needed (as we are not talking about a writable proeprties file).
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just deploy it twice is the easier option.

Otherwise if you use websphere, you can use url resources and then use jndi to pick up the url resource which links to a location on the local drive.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic