clarification about EAR project structure and maven

it's been a while now and still there are several things that are not clear to me.

Lets start with the basics: what I need to do. I'm building a web application that manipulate some data, do some computation and give the user an output. There will be also a standalone version, with some simplifications.

So I thought this is the right time to use EAR packaging structure and EJB. I've created with netbeans a basic j2ee ear project with maven support:

All of them have their own pom.xml. For what i understand, the first one is just a wrapper, the second one is the "real" project that doesn't contain source code, but encapsulate the other two. In the web project I put all of the web stuff plus jsf backing beans. In the ejb one I was planning to put my data model with all the required annotations, and that comprehend also JPA and JAXB. There should be also some additional classes: a facade class, or session bean, that allow me basic data manipulation with the database, and some classes that contain my business logic strictly related to my data.

Question: is it correct to put all this things into an EJB project? Why not a simple project that the web module depends on?

Moving forward: the web project. First things is, netbeans doesn't put the EJB project dependency into its pom. So I can't see my beans from here. Is that correct or I have to manually add the SRA-ejb into the pom as a dependency?

Secondly, using some netbeans macro, like the ones that generate session beans from entity, or CRUD jsf pages from entities, it looks like he try to generate and put session beans here, in the web project. I think they fits better in the ejb one. What do you think?

One last question: in my stand alone application I was planning to use just the ejb module. But I think I have to carry with me an EJB container, am I right?

Answers


it's been a while now and still there are several things that are not clear to me.

I know that feeling for sure :D

All of them have their own pom.xml. For what i understand, the first one is just a wrapper, the second one is the "real" project that doesn't contain source code, but encapsulate the other two.

Correct, it doesn't contain any sourcecode but can contain XML files for declarations and a common lib folder which contains shared libraries of the web and EJB projects.

In the web project I put all of the web stuff plus jsf backing beans. In the ejb one I was planning to put my data model with all the required annotations, and that comprehend also JPA and JAXB. There should be also some additional classes: a facade class, or session bean, that allow me basic data manipulation with the database, and some classes that contain my business logic strictly related to my data.

Question: is it correct to put all this things into an EJB project? Why not a simple project that the web module depends on?

I don't know what you mean with a "simple project", if you mean just a plain JAR file with classes: an EJB module is nearly the same plus a deployment descriptor which invokes scanning of the annotations.

Moving forward: the web project. First things is, netbeans doesn't put the EJB project dependency into its pom. So I can't see my beans from here. Is that correct or I have to manually add the SRA-ejb into the pom as a dependency?

Yes, in your case you need this dependency. You web project depends on your "service".

Secondly, using some netbeans macro, like the ones that generate session beans from entity, or CRUD jsf pages from entities, it looks like he try to generate and put session beans here, in the web project. I think they fits better in the ejb one. What do you think?

I think it makes more sense to put them in the EJB project because they come from the javax.ejb.* package and belong to the EJB layer. You can put them in the we project, but then you don't really need an EAR and you can use a normal web project like you did before.

One last question: in my stand alone application I was planning to use just the ejb module. But I think I have to carry with me an EJB container, am I right?

No, you don't need an EJB container. You can lookup your EJBs via JNDI but you'll need an EJB with a remote interface and a copy of this interface in your standalone client.

You can find some tutorials about that here:

See also:


Need Your Help

PHP subject line generated from Option tag in html file, won't show in email

php html show subject

I'm creating an application form which gets certain fields, such as there person's first name, last name, email, department, etc. and submits that information into email form. And everything works

OO design patterns to use for validation

design-patterns oop

I am in the process of writing some validation code based on these assumptions: