wood burning stoves 2.0*
The moose likes BEA/Weblogic and the fly likes Newbie question  - how to include dependent classes automatically in ejb jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Newbie question  - how to include dependent classes automatically in ejb jar " Watch "Newbie question  - how to include dependent classes automatically in ejb jar " New topic
Author

Newbie question - how to include dependent classes automatically in ejb jar

Kiran Srinivasa
Greenhorn

Joined: Jul 07, 2009
Posts: 12
Hi Experts,

I have a basic question.
I am using Jdeveloper 11g and have divided my application into 2 projects (Model(ejb's) and Viewcontroller(jsf+managed beans etc)).
The model project has a stateless session bean(named VisitingScholarBean) which uses a backing bean class(named VisitingScholarDetails) defined in the ViewController project.
The relevant Method in the stateless session bean is public void saveVSDetails(VisitingScholarDetails vsDetails).
Now the issue is that the VisitingScholarDetails class is part of only the ViewController project.
So when I try to run the application it gives an error saying that


I cannot replicate the same VisitingScholarDetails class in both projects.
Please let me know how to include the VisitingScholarDetails class in the ejb-jar without replicating it in the Model and View Controller projects.
Thanks for your time and help.

Regards
Kiran
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

There are two things you could do.

* I have not used JDeveloper but, adding the controller project as a dependency in the EJB project should remove the problem. You EAR should be exported with the relevant dependencies.

* Make a jar of the controller project and put it in the lib of the ejb project.

The gist of your question is 'How do you ensure shared classes are available to both apps' correct ? If the solution does not make sense or your problem is different, feel free to reply with additional information


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Kiran Srinivasa
Greenhorn

Joined: Jul 07, 2009
Posts: 12
Thanks a lot , Deepak. Setting the dependencies of the View Controller in the Model helped.
However I had one more question. When I build in the ejb -jar should I include the view controller classes also?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

When I build in the ejb -jar should I include the view controller classes also?


If the EJB classes have a dependency then yes.

The way I see it, your EJB project should have this class to begin with. This class is a Value Object, which might be used in several applications. The definition of the input and output objects of an EJB call should be within the project. It is not normal to have API classes defined in other projects. Think about that if you are yet to deploy this application in prod.
Kiran Srinivasa
Greenhorn

Joined: Jul 07, 2009
Posts: 12
Thanks Deepak.
However it comes back to my basic question. The Value Object is used in both the EJB as well as the EJB client(in this case a JSF managed bean).
It is not however possible to define it in both places. In my case I have the jsf managed bean(VisitingScholarDetails) itself as the VO for the EJB. Is it a good practice to define the VO in the web tier or should we define it in the EJB tier and reuse it in the web?

Regards
Kiran
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Is it a good practice to define the VO in the web tier or should we define it in the EJB tier and reuse it in the web?


Define the VO in the EJB project since you are going to reuse it in other projects. The VO is part of the EJB business API parameters / return value. It belongs in the EJB project.
Kiran Srinivasa
Greenhorn

Joined: Jul 07, 2009
Posts: 12
Thanks a lot for clarifying my doubts, Deepak. It was a pleasure interacting with you.
 
wood burning stoves
 
subject: Newbie question - how to include dependent classes automatically in ejb jar