Creating a WAR file from multimodule project - java

I have a simple project with following structure:
myApp - parent pom
|-app - REST API module
|-db - JDBI module
I want these two to stay as they are and add a third module from which I will be able to create a war. Also, my app module is a REST API created using Dropwizard. I read that I should create in new module a WEBINF catalog with web.xml, but I don't know what do I put in there.
Are there any example projects, tutorials, links or references how to do it? I'm new to maven and Java EE.

I found what I was looking for. It's wizard-in-a-box project that do all the necessary things to build a WAR file.

Related

Differences between Intellij project and module

I followed dropwizard tutorial and build a simple API project( or maybe I should call it a module). Can I make it a module? Since there is a main method in it, is it allowed to have main method, pom.xml and yml file in a module? If so, when import several modules to a project, how to use the service it provides?
What is the folder structure difference between a project and a module? I notice in the Project Settings of Intellij, I can either add my application to the module, or artifacts.
Should I package my restful API project as a jar to use it?
1.
A project can contain one or more related modules.Each module is a separate library, application and can be a jar, ear or war.Also modules aren't just Java either. You can have modules for ruby, scala, or something else as well.A project is a convenient way to develop related, interdependent applications, libraries in concert.2. Module folders are subfolders of the project folder. An artifact is an assembly of your project assets that you put together to test, deploy or distribute your software solution or its part.see https://www.jetbrains.com/help/idea/working-with-artifacts.html
3. Your REST API most likely will be a web app. So it should be a war/ear.for a sample see https://www.jetbrains.com/help/idea/creating-and-running-your-first-restful-web-service.html

appengine create two modules using same war

I have a 2 modules in a java appengine project (one for front-end and one for back-end).
I want to duplicate the back-end module without duplicating the code.
How can I create a new module that uses the same war of the backend module ?
Thanks for your help.
You can symlink the file(s) (or directories) to be shared inside the respective modules. The deployment utilities know how to replace the symlinks with the actual content of the files/directories they point to.

AppEngine Dynamic WebProject - Ear libraries not copied to War Project Web-INF/lib folder

I have a Ear Project which includes two Appengine Dynamic Web Project and one shared java project (which has common classes).
I have added shared java project to EarContent Folder through Deployment assembly settings in EAR Project and i can see the java project jar file in published folder under EarContent folder.
Now i wanted to use the Ear library in Dynamic Web Project, so i have added this library in MANIFEST.MF setting for both the project and at compile time i can access the class from shared project too.
The problem is when i publish it, i couldn't able to find the java project jar in Both Web Project, i have tried almost every settings but nothing was helpful.
Am using Eclipse Mars, AppEngine SDK version 1.9.10,
Does any one tried this, is there any possible solution for my problem. any thoughts or suggestion is highly appreciated.
Thanks!
It looks like the Google Plugin for Eclipse doesn't recognize anything in EarContent/lib (or whatever your EAR library path is) regardless of settings when packaging the WAR files for each Dynamic Web Project. The JARs need to be physically present in WEB-INF/lib for each Dynamic Web Project in order for the modules to deploy properly.
I would recommend opening a feature request in the official issue tracker here:
https://code.google.com/p/googleappengine/wiki/FilingIssues

Java classpath for dynamic web project

Hi all i have very rare problem which needs to be solved.
Problem/issue:
I have a dynamic web project which is already built and i have war file of that project.
I need to apply some customizations on top of the war file given to me.
Using maven or ant am able to compile the custom code written by me and able to add produced class files to the war file.
But the this is happening for final war file build.
when i want to test my code in eclipse. the war file build and deployed in jboss plugin contains only the class files produced out of java files written by me..........
Please help me how can i modify the .classpath file of my project so that a jboss publish can build a war file using the dependent war file which can run on eclipse-jboss to test my custom code....
Advance Thanks.....
Not a rare problem.
What you need to combine two web applications (wars) together. You have your customization war on which you need to overlay the existing web application.
It looks like you have already solved it from build perspective and looking for Eclipse support. To my knowledge, Eclipse lacks support for this. You probably need to manually do the necessary configuration to make this happen.
It looks strange to me to have two WAR files.
Perhaps you have to consider to package your customizations in a JAR and inserting that jar in the original WAR file.
Otherwise, another solution, and what I do often with open-source project to customize is to have three projects in your workspace.
PRJ-src (with your original sources/JAR/WAR)
PRJ-custom (which depends of the previous one); This project contains only the new classes or custom spring xml files (with injection of my own classes)
PRJ (the merge of the two previous projects)
I create an Ant task in the 3rd project which takes the 1st project (PRJ-src) and merge with the 2nd project (PRJ-custom). This is possible to do so with Maven as well.
Then this is the only project I deploy in my app server (tomcat / jboss).

How do I package multiple WAR files in one Maven project?

I am writing an application that integrates Geoserver with a custom component, intended to be hosted on a single servlet engine. Both are Maven based projects, and I would like to stay in Maven land to package it all into a nice distributable. The general idea I have is to add another module to my application that packages the application itself, Geoserver and all dependencies into one nice archive.
I am aware of the maven-assembly-plugin and its capability of storing all dependencies in a target folder, but I am not sure what would be the best way to create a package that it easy to deploy. Googling for any examples has not been successful.
Extra bonus points if the module can be started via mvn jetty:run.
Have you considered packaging them into an EAR project. It will bundle a set of WARs (and jars), and allows you to specify or generate a deployment descriptor.

Categories

Resources