aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes ejb and properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb and properties" Watch "ejb and properties" New topic
Author

ejb and properties

John Gregory
Ranch Hand

Joined: Oct 05, 2006
Posts: 115
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
giuseppe fanuzzi
Ranch Hand

Joined: Sep 18, 2006
Posts: 99
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


GiUsEpPe (SCJP, SCWCD, SCBCD, IBM OOAD, SCEA/OCMJEA 5)
John Gregory
Ranch Hand

Joined: Oct 05, 2006
Posts: 115
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
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Oct 05, 2006
Posts: 115
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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Oct 05, 2006
Posts: 115
James,

Ok, will do. Thanks.

John
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ejb and properties