• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejb and properties

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a MDB that I need to load some properties which I need to pass
to some helper classes. If this were a stand alone, I could just load
the properties using a Reader.

However, I've seen some apps that use a ResourceBundle. In my MDB,
I initialize by trying to load the properties. However, I keep getting
null.

The name of my properties file is default.conf. It contains the string
name for things like ldap things....etc.

So, my question is what would be the best approach to accomplishing
what I need to do?

Thanks,

John
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this properties file tight coupled with the mdb? if yes i think that you could specify those properties in the environment entries of the mdb
 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The mdb uses some of the properties, but mostly,
the properties get passed into the constructors of
helper classes. We often change servers, so I thought
I'd not want to hardcode anything.

John
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Business logic is best placed in Session EJB. Any helper classes associated with business logic should be instantiated in the Session EJB.

Message-driven EJB should handle processing messages and fowarding whatever data there is to a Session EJB for executing business logic.
 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,

Ok, but still, how can I load a properties file? The helper
classes need access to the properties.

Or, is there a better way to do this? I only have limited
experience with j2ee and ejbs....

John
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,

The first thing you should do is write a simple, standalone Java program that loads file-based properties with the java.util.ResourceBundle class.

Once you have this working correctly, then you should incorprate this code in your business object(s) (Session EJB).

Then you must make sure that you are placing the properties file in a location where it (a) can be read by the Session EJB and (b) is loaded into the EJB module (JAR) or EAR file.

If you deploy the application or module without the properties file, it will not be read.

If you deploy the application or module and have the properties file not in the correct location, it will not be read.

So, you first have to ensure that you have written the code correctly. Then once you are sure, then you can work on finding the right location to place the properties file and then deploy the application or module.
[ December 08, 2008: Message edited by: James Clark ]
 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,

Ok, will do. Thanks.

John
 
reply
    Bookmark Topic Watch Topic
  • New Topic