2

I have a Maven web project (Java) that I created in Eclipse. Due to in house IDE restriction I had to move the project to JDeveloper 12c and disable the Maven nature. I had to make several tweaks to project's properties in JDeveloper to make it work.

We found that the back-end code (Service Impl, DAO and Entity classes) can be used on several other projects so we are evaluating/considering to separate the single large web project into 2 projects. One for the front end, which is specific for each project and the other for backend, which is common for all projects.

Here are few ways I thought it can done.

1) From the single large web project, create 2 projects; web UI project and web back-end project.

2) Keep the code as it is and use maven modules or maven overlays feature and generate 2 wars from the same code.

I have not dealt with the projects depending on others or multi module projects a lot. Do you see any issues with this type of architecture, good or bad!

Please let me know if you have any other suggestions or ran into similar situations before. Thanks in advance.

Superman9999
  • 815
  • 3
  • 16
  • 30

1 Answers1

0

Splitting project into many subproject is a good idea. You could use maven multimodule project setup (docs). Every frontend project would have a separate maven project (module in parent pom) and you'll have one project (module) for the backend.

Depending on your requirements you could then create:

  • an EAR archive with backend in EJB jar and all frontends in WAR archives,
  • a WAR archive for every frontend project with EJB jar (or jar for non-plain-javaee setup) inside WEB-INF/lib.

Multimodule setup has few advantages and the main one is that you can build the whole application from scratch just by issuing single mvn command.

Arek
  • 3,106
  • 3
  • 23
  • 32
  • Thanks Ajan. Can the front-end code directly call the classes in the back-end project if they are deployed as 2 separate war files in a EAR? We use an in-house third party library/jar for authentication and spring security along with it for authorization. I am curious to know if I need to write any extra code for communication between front-end and back-end projects. – Superman9999 Sep 10 '14 at 14:16
  • By design you can not access directly services from another WAR archive. But you can put 3rd party libraries into /lib folder of EAR archive (see http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html). You can place your code in EJB jar and just put it in the root folder of EAR. By contract all EJBs from EAR are accessible by all other archives. If you are not using EJBs and you use Spring then you can just put your common logic in separate JAR archive (separate mvn project) and put it in every WAR archive (single WAR archive = single application). – Arek Sep 10 '14 at 17:05