File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Where to put the spring config for my ejb jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Where to put the spring config for my ejb jar?" Watch "Where to put the spring config for my ejb jar?" New topic

Where to put the spring config for my ejb jar?

Sonny hodac

Joined: Jan 31, 2008
Posts: 8
I build a back end services consist of multiple EJBs, service interfaces, DAO. All classes will be built to classes folder:


I plan to load the spring context xml from my service contructor:

public class MyCustomInterfaceService {

* DAO properties
private InsuranceGroupDAO insGrpDAO;
private PayorTypeDAO payorTypeDAO;
private ProductCategoryDAO prodCatDAO;
private QueueDAO queueDAO;
private ApplicationContext context;

public MyCustomInterfaceService (){
context = new ClassPathXmlApplicationContext("beans-context.xml");
BeanFactory factory = (BeanFactory) context;
insGrpDAO = (InsuranceGroupDAO)factory.getBean("insuranceGroupDao");
payorTypeDAO = (PayorTypeDAO)factory.getBean("insuranceGroupDao");
prodCatDAO = (ProductCategoryDAO)factory.getBean("insuranceGroupDao");
queueDAO = (QueueDAO)factory.getBean("insuranceGroupDao");

// some interface business methods here

Where should I place my beans-context.xml? In build/classes, and jar them together with the ejb.jar? Anyone has experience with this please help. Also, this ejb will be deployed to websphere, any comment/input for this specific app server with what I'm doing will be greatly appreciated.

I also have another war for web end that has it separate spring config under WEB-INF/ folder.

Is it correct to have two separate bean config one in the web tier and one for the ejb tier like what I do? OR can we just put all beans config to web tier (WEB-INF/application-context.xml so they got pick up by the framework without explicitly load in my service constructor class?

I agree. Here's the link:
subject: Where to put the spring config for my ejb jar?
jQuery in Action, 3rd edition