I am using Eclipse Luna, Maven 3 and Websphere Liberty 8.5.5. I have added websphere liberty server in eclipse. The EAR/WAR project deployed in liberty does not include maven dependencies in WEB-INF/lib of WAR. If I export EAR or WAR the exported file has all the dependencies included. What could be going wrong?
While working with Maven projects in Eclipse, make sure your Maven dependencies are correctly configured in Project properties > Deployment Assembly to be deployed to WEB-INF/lib folder.
Gas has the right answer. Just here a screenshot:
If the Maven dependencies are missingf click then "Java Build Path Entiries" and the select "Maven Dependencies"
In my workspace this setting will be lost when I do Maven/Update Project.
Related
I have installed Eclipse, WildFly and Jboss Tools. I created an EAR/Maven project and an EJB/Maven project.
I added all the dependencies to the EAR pom.xml. Jboss Tools deploys the WildFly EAR lib with no issues and the application runs fine.
The problem is the build classpath in the EJB project in Eclipse. As all the dependencies are configured in the EAR pom.xml and not in the EJB pom.xml, I cannot figure out how to tell the EJB project in Eclipse to take from the EAR project the jars that were defined as dependencies.
How to set this up?
Add the dependencies in EJB pom.xml and not in EAR pom.xml.
You want to "take from the EAR project the jars that were defined as dependencies", but this is not how Maven works.
Jars are drawn from a Maven repository (like MavenCentral or your local repository), according to the dependencies that are defined in the pom. As #N.Shrivastava already said, you define the dependencies in the pom of the project that actually uses the dependencies. So when you have an ear that includes an ejb jar that has some dependencies, put the dependencies into the pom of the ejb jar and delete them from the pom of the ear. They will be transitively drawn into the ear as well.
If you need the same set of dependencies in different ejb jars, this can be realised by creating a separate project of packaging pom. Then the different ejb jars can depend on that pom project, and draw transitively all the dependencies from the pom project.
I have a ear project with maven and i want to hot deploy in a jboss with eclipse (m2e/jboss tools).
The ear has a two war and one ejb modules. The problem is when i deploy the ear (Server > add remove and clean/publish) the lib folder of the ear is empty when i expect find the ejb dependencies inside.
If i run "mvn clean install" the generated ouptput are correct and the eclipse "ear deplyment assembly" of the project are updated and show the dependencies. If, in the deployment assembly, delete one of the dependencies and add it manualy (exact same configuration relative .m2 folder) then it deployed.
Workstation:
Windows 7
Jboss 5.2 EAP
Eclipse Oxygen/ Proton and Red Had Developer Studio 12
Java 1.8.0_181 (eclipse) Java 1.7.0_75 (jboss)
Maven embedded 3.5.3 and exgternal 3.5.4
Any idea?
Thanks
I think I found the problem and the solution.
The problem is eclipse sets by default the oldest version of the EAR (1.3). If I add <version> X </ version> in the configuration of maven-ear-plugin, the problem will be solved.
To force eclipse to update the configuration, delete the project, run mvn eclipse: clean clean (verify that all eclipse settings have been removed) and re-import the project (mvn install && maven -> update project). If I check the facets of the project configuration, I will now show the new version.
I have a multi module Maven project with a common module which is a dependency of 2 others modules. One of this module generate a war which is integrated in the other one by overlay.
The final war is generated by Maven clean install command without problem. All the structure in target is OK.
But if I install a Tomcat 8 server in servers view (with 'takes Tomcat control installation' mode) and deploy the project, it's a nightmare...
I have tests resources in WEB-INF/classes, the common module (jar) is not deployed in WEB-INF/lib, the war which should be integrated during the build by overlay appears in WEB-INF/lib.
Is there a way to have a clean deployment without adding a Tomcat plugin in Maven configuration ?
For information, it is Neon version.
Deployment assembly are configured with src/main/* only (plus Maven dependencies).
We don't understand why Eclipse doesn't deploy the final application generated in target/xxx directory.
Ok, I found the problem.
Eclipse doesn't care about Deployment Assembly.
It mix Deployment Assembly AND Java Build Path.
When you import a maven project, the configuration of your project can be bad for an unknown reason.
Check the sources folders declared in Java Build Path and check specialy the output directory of each source folder.
For src/test/resources, it set a default output (not target/test-classes). So all tests resources were copied into target/classes.
And I don't know why he deployed to Tomcat this directory.
In Deployment Assembly, it just set these directories :
- src/main/java -> WEB-INF/classes
- src/main/webapp -> /
- /target/m2e-wtp/web-resources -> /
- Maven dependencies -> WEB-INF/lib
- link to others modules
Now all work perfectly.
I have read every page that shows up on the first Google result page with that search. But nothing seems to help.
Of course I can run "mvn clean install" in or out of Eclipse and get the .war generated in the target folder. I can copy the .war in the deployments folder of JBoss installation myself. And then I can start the server through the server adapter in Eclipse.
But I want that "manual copy of war" to be automatic as well.
How can I do this? What do I need to do to add a new item to "Run As" menu, say, "Maven JBoss Deploy" where underneath, it does a clean, install, deploy (copy to deployments)?
I have Maven 3.1.1 installed separately (outside of Eclipse) and I have told Eclipse where my Maven is. I have JBoss Tools (latest version) installed with JBoss Maven Integration part of it.
I just don't see any way to integrate JBoss and Maven within Eclipse :(
You can do with fileName tag
<fileName>${basedir}/target/webapp.war</fileName> in pom.xml
or
You can go with Profiles in pom.xml
More 1
More 2
By trial and error, I was able to get Eclipse to deploy a maven project WAR on JBoss.
I just needed to have "Dynamic Web Module" facet attached to the project. I did that using the Project properties in eclipse.
Now I am able to right click the project and Run As Server and that deploys to JBoss. And the project is still a Maven project. Yay!
I have setup a Dynamic Web Project in Eclipse using Maven. The Web Project has a lot of dependencies to other JARs. The JARs are properly added to the WEB-INF/lib folder in Maven/Eclipse. Many of the JARs though are results of other plain Java projects. I want to have the JARs represented by their resepective Java projects in Eclipse from time to time (but not for all of them).
So how do I quickly replace a normal Maven Dependency JAR by its Eclipse project?
Currently I:
Remove the Maven Dependency (Right click on the JAR, Maven -> Exlude Maven Artifact)
Edit the Build path and add the corresponding Eclipse project
Mark the project also in the "Export and Order" section of the Build path
Edit the Deployment Assembly properties and add the Eclipse project there as well (so it goes into WEB-INF/lib at runtime).
If your web projects is a maven project (little "m" in the upper left corner) and you have installed the M2E-WTP plugin (included in the Keplar JavaEE package), this will happen automatically, i.e. when the dependent project is open in the workspace, it will be a project link, if it is closed, your web project will use the jar file as dependency.
If you are using M2Eclipse, I gess you should enable Workspace resolution.
Both projects should be maven projects.
If you're using mvn eclipse plugin, make sure, they both have a pom.xml and call :
mvn eclipse:clean eclipse:eclipse