• Post Reply Bookmark Topic Watch Topic
  • New Topic

where to keep a property file in ear?  RSS feed

 
Reena Kher
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • 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
  • 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: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pass the locale to the getBundle method.
 
Reena Kher
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Pass the locale to the getBundle method.


no luck !
i am really stuck up!
 
Ken Robinson
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • 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: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • 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).
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!