Setup Maven Project with 2 Modules - JSF, Spring, Hibernate - spring

I'm using Eclipse and want to setup a MAVEN project which contains two modules for frontend and backend with JSF, Spring and Hibernate.
What I know:
- Create a Maven Project (packaging POM) without archetype
- Create Modules and select the Parent Project (Frontend JAR, Backend WAR)
Which archetypes can I use to combine JSF, Spring, Hibernate?
Do I have to use the same archetype for both modules?
Thanks for any help!

maven archetype is only template those prepare projects folder structure, dependency etc. See
Maven archetype
So you can create both module like simple module without archetype and self create folder and depency...
If you can use some archetype you can use some of these
ex: for main project: appfuse-basic-jsf and Maven create project which use Spring, hibernate and JSF
or softeu-archetype-jsf for JFS nodule and spring-osgi-bundle-archetype for Spring

Related

Liferay plugin package dependencies and Maven

I'm starting to develop a Spring-MVC Portlet project. I did all the configuration needed in portlet.xml and web.xml but still a little bit confused about the Spring dependencies that have been declared in liferay-plugin-package.properties. In fact, should I add the required dependencies in this file and declare them as provided in the project pom.xml?
I use Maven as the build and dependency management tool and all examples I've found are based on the ANT project.
How does Liferay is processes the dependencies declared in liferay-plugin-package.properties ?
Besides, a maven compile fails since it does not find Spring MVC libraries required for the Spring MVC portlet project. What do you think is missing (or) incorrect in the configuration to create Spring MVC portlet ?
thanks in advance
The easiest way to go about this is to use the Maven Archetype that's been provided by liferay.
The Maven dependency is:
<dependency>
<groupId>com.liferay.maven.archetypes</groupId>
<artifactId>liferay-portlet-spring-mvc-archetype</artifactId>
<version>6.2.10.15</version>
Install this archetype in your local repository and then create a Maven project from this archetype.
This will have all the prerequisites needed for your project.
It is not necessarily to put any dependencies into liferay-plugin-package.properties file. All you need for your Spring MVC Portlet project should be presented in the project pom.xml file.
All dependencies are accessible from maven repo, e.g. http://mvnrepository.com/artifact/org.springframework/spring-webmvc-portlet

IntelliJ Spring Web and Maven

I am trying a create JEE spring web project (+spring security, mvc, web flow) and it will be a maven project with IntelliJ IDE.
I tried :
1) Create Project as "Spring",
2) Additional Libraries and frameworks : Spring, Spring MVC, Spring Security, Spring Web Flow. Web Application, Application Server, Hibernate.
And click on Finish button.
3) After project created, right clicked and "Add frameworks support" and selected maven.
I have three questions :
1) Is this a right approach to create a spring web maven project with IntelliJ?
2) Project has a lib folder that has spring, hibernate jars etc. They are not included in pom.xml file as dependency. How can i make them as they defined in pom.xml file so these jars will be in "External Libraries" folder?
3) When i didn't select "Application Server" while creating a new project, I cannot add later, when the project is created using "Add frameworks support". Why?
Thanks in advance.
Is this a right approach to create a spring web maven project with
IntelliJ?
No, create a Maven (or Gradle) project form starting point and then add dependencies through Maven (or Gradle) dependency management system. Generally, managing dependencies through lib folders or System Wide Dependencies are NOT good ideas. Read more on
Project has a lib folder that has spring, hibernate jars etc. They are
not included in pom.xml file as dependency. How can i make them as
they defined in pom.xml file so these jars will be in "External
Libraries" folder?
Delete all jar files and replace them with dependency section of pom.xml. You should find groupId, artifactId and version coordiantes of each one. For example, for spring-core module, you should add this to your <dependencies></dependencies> section:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency
When i didn't select "Application Server" while creating a new
project, I cannot add later, when the project is created using "Add
frameworks support". Why?
After creating project, you can add Application Servers or Servlet Containers through Run > Edit Configuration settings.

How to convert Maven War project to an EAR project in Openshift?

I have created an JEE application in Openshift using the JBOSS AS 7.1 cartridge a Maven project have been generated with the War deployment format.
I need to use EJBs into the application but the War format cannot hold EJB so I changed the from War to Ear, the problem is that when I deploy the Ear the application does not Work(404 Error when I access the home page).
Is there any simple solution in order to make this work?
Or Should I create two seperate projects(one EJB project and another JSF project) and a parent POM?
Actually it is possible to package EJBs inside a WAR archive : JEE6 Tutorial, so I decided to stick with that.
Alternatively it is also possible to convert a project from WAR to EAR by using Maven's project composition (useful link).

Web project dependency pojos, web deployment

I have 3 maven projects:
1 - common pojos project
2 - web project
3 - java client project
web and java project uses same pojos from common project, have dependency on 1 project
I added to web build path common pojos project,
but when I deploy web project to server, no pojo classes exceptions....
My question is how can I configure it to get my pojos classes deployed with all web project ?
(it will be fantastic, If you have some online examples for this)
Tnx.
If all your 3 project are maven projects and the dependencies are set right then maven will automatically package all the dependencies into the war.
commons pojos is a jar project
web project is a war project which depends on commons pojos project. Unless the dependency scope is not provided the jar will be packaged in the war.
You can verify the same by opening the war file as see if the commons pojos jar is present and the jar has the required classes.

Pulling out domain classes from a Spring Roo project

We need to be able to pull out domain classes (i.e. entities) from a Spring Roo project in order to reuse them for a Spring Batch project.
Is this possible?
Bearing in mind that we rely on Maven as our build and dependency management tool, and that our Roo project is already created, can we switch to a multi-module architecture?
If so how?
I don't think there is a roo command for converting a single module maven project to a multi module project.
One option would be to use roo to create a separate persistence module in your current project and manually migrate your entities and configuration over.

Resources