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.
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.
Related
I am working on migrating a java multi project build based on net beans into a gradle build.
The motivation is not to be dependant on the IDE and having gradle manage all the dependencies.
we currently have one folder that contains all the projects and they have their inter dependencies.
These projects are deployed in two separate applications. One (lets call it App1) in a play framework application (v1.4) that depends on some other projects, and the other (App2) is a regular java application deployed on a separate machine.
Some projects are common to both applications.
I currently managed to build App2 using gradle, so I have a build.gradle & settings.gradle files in the top folder
now I want to add the build files for App1 (the play application).
Questions:
1. I couldn't find any explanations on combining play 1.x with gradle. Does anyone know how to do it?
2. How should I arrange my top level gradle files for building 2 separate applications
3. I want to be able to use the IDE for refactoring code that is common to both apps. how do I do that
Thanks
Answer to your questions
Suppose your projects structure looks like in below image
Please include all sub projects in top level project's settings.gradle like below image
Use the dependencies in sub projects like below image
I'm creating a web app, for which I have created a dynamic web project in Eclipse. I have also created two java projects, which serve different business purposes. I want my dynamic web project to use these projects as well.
Below are the projects i've created
myapp-core (Java project that has all my core components)
myapp-db (All classes related to DB calls go here)
myappWeb (Dynamic web project which will have only presentation logic)
The point is, I've created all these projects and the classes within them. I have also added myapp-core and myapp-db projects to my myaddWeb's classpath, and am now free of any compilation errors.
However, when I deploy this on Tomcat, I get java.lang.ClassNotFoundException for org.slf4j.LoggerFactory
Now, all three projects have logging, for which I have added slf4j and logback related jars to the build paths of each project (separately).
All my projects are referencing common libraries, like guava, apache poi, etc., which I have associated with each project separately.
Am I missing anything here? Can anyone guide me what is the exact setup that needs to be done for such a framework?
Thanks
Sriram
Please follow below mentioned steps for all 3 projects :
1. Right Click on your Project
2. Go to "Java EE Module Dependencies" option.
3. Select all jars and Apply changes.
If "Java EE Module Dependencies" is not there, try "Web Deployment Assembly" which does the same thing.
I want create skeleton for big ecommerce project. It will be huge project. It should be a core module and set of additional modules.
Now I am thinking about maven modules into Spring MVC project. But I am newbie in maven and Spring
How make each module independent from other modules? Any best practice?
Any examples or code snippets?
I have a multi-module Maven project which was created couple of months back.
I can give you some pointers.
It can be structured as a parent project and multiple child modules under it.
In my case the output generated with Maven is a .war file and which contains jar files from each child module.
From maven you can build each modules separately if you want.
This is a useful link for multi-module creation
http://skillshared.blogspot.in/2012/11/how-to-create-multi-module-project-with.html
These are the layers on a high level:
Bean > Service > DAO [JPA]
Another useful link on directory structure is
Maven Multi Module Project Structuring Issues
I try to find the way to organize a GAE with several projects within Eclipse using the Google plugin for GAE:
The Web App project (a WebApp project) containing the GAE web application.
A Java project with data access
A Java project with utility classes
My problem here is how to link things together. I want to add the two Java projects in both build and execution paths. Since a Web App project follows the JavaEE structure, only what is specified in the WEB-INF/lib directory is taken into account.
I would like to find out how to simulate a Jar file in this directory based on a Java project present in the Eclipse workspace based on what the Google Eclipse plugin for GAE provides.
I saw something that seems to be related in the WebApp project properties Google > Web Application, section "Suppress warnings about these build path entries being outside of WEB-INF/lib".
For the GAE web application to run then you'll need the classes or a jar from the projects you want to include in the WEB-INF/classes or WEB-INF/lib folders respectively.
One way would be to build your data and utility projects and put the resulting jars in the WEB-INF/lib folder. You can then then reference those jars as libraries from your web app and all should be fine. Of course that's a bit tiresome to do manually, so you should probably check out some dependency management tools. From personal experience Ivy and IvyDE were easy to get into and should cover your needs although Maven and others have their strengths.
Another way that is a easier (but less structured) is to used linked source folders in your build path (to the source folders for your data and utility projects). In such way Eclipse will build those sub projects to WEB-INF/classes and build and execution should work similarly.
Environment
IDE: Netbeans 6.9
App Server: Glassfish 3
Frameworks: Spring, Hibernate, Struts 2
Problem
I have 2 web applications. I want to share resources between them both - i.e. authentication form jsp and other assets (js - yui,jquery/images/css). I will be adding more web applications that will also require access to these common components.
As a last resort I will create another web project with just the common assets - including them via http://common.mydomain.
How has anyone else achieved this? Can I create a web resource jar/war and include this in both applications?
I am experimenting so will update question with any progress.
Many thanks.
Place these 'common' components in a separate module (or in several separate modules) and make a dependency to this module from other parts of your app. (I'm not sure how is it called in NetBeans, in IntelliJ IDEA it's called module, in Eclipse - it's a separate project in the same workspace).
In eclipse you must create an utility project and an ear project containing the utility project and your current web applications. You can then move common code to the utility project, and deploy the ear to glassfish.
Common resources must be located through the classpath. This is rather easy with JSF 2
Netbeans has a feature to do this. Create a new project just for your shared components. List the project as a dependency of the projects that need it and make sure both projects are open in the IDE during the build process.
The IDE agnostic way(which I'm using in my own projects.)
would be to:
use maven to manage your projects
build your shared components into their own .jar
setup a local repository server(nexus, artifactory) server to host the shared .jar
(if you're the only dev, you might be able to get around this with mvn install)
list your new jar as a dependency on the projects(wars) that need it.