maven and eclipse builds differently the same project - eclipse

I have a java ear maven project.
When I publish the ear to jboss7 via eclipse it generates an ear and deploys it to jboss.
But when I manually run a maven build of the same project I get a different ear in size and also the name is different.
When eclise builds the project when executing "publish to server", doesnt it use the same build as maven?
I use eclipse juno and maven3. I'm new to maven.

Eclipse uses the .classpath to package the ear that gets deployed to jboss. When you do a manual maven build it is using the pom.xml file to package the ear. If those aren't in sync you could get differences in your ears.

Related

How to make M2E (Maven for eclipse) include required eclipse projects in WAR

I'm starting to use Maven (M2E) on Eclipse.
I have two projects
->Tools
->Main
The Main project requires the Tools project. I add "Tools" under the "Main"->"Deployment assembly" option, and when exporting to WAR, the WAR will automatically contain also Tools.jar. This is correct.
Now I installed M2E on the Main Project, to manage some spring dependencies. When I edit the pom.xml, Maven starts, and correctly downloads the Spring jars, but it removes the Tools project from the "Deployment assembly" option (it disappear from the org.eclipse.wst.common.component eclipse configuration file)
As a result, when I export the WAR from Eclipse->Export, the war will not contain Tools.jar, so the webapp will not work.
How do I configure pom.xml to do what Eclipse does with the "deployment assembly"?
That is, package all classes and resources and jar dependencies of the Tools project?
I think that I'm missing some understanding of Maven, but I've not been able to google about it?
thank you

Deploying an EJB .jar to jBoss/WildFly from Eclipse

I am new to Java EE. I use Eclipse, jBoss/WildFly and Maven. I have a multi module Maven project:
parent Maven project (pom)
web application (war)
EJB project (jar)
Currently, the EJB jar project is packaged inside the web application and the entire solution is deployed as one war file.
I want to change it: I need to deploy the war and the jar projects to the application server independently (as two independent applications). Then the web project could access the EJBs via their remote interfaces.
The problem:
I can deploy the war project in Eclipse with the Run As > Run On Server context menu, however when I attempt to deploy the jar project in the same way, I get an error message saying that the project cannot be deployed.
How can I deploy my projects independently from Eclipse?
Should I wrap the jar project into an ear project? If so, can I convert my jar project into an ear project, or do I have to keep my jar project and create one more project to wrap it into an ear? (I would no like to introduce one more project).
Look at your packaging for your EJB project. You should have
<packaging>ejb</packaging>
This will allow you to run the EJB project on the server.

Automatically publishing maven project from eclipse doens't publish maven dependencies

These are the steps I followed:
Created a maven project in eclipse.
Converted the project into faceted form.
Added the project to the server.
Now whenever I make any changes to my project resources, it gets reflected in server. But my WEB-INF/lib directory doesn't contain any maven dependency jar files.
How to fix this?
If you use Eclipse WTP, Maven dependencies are provided by WTP to the application server using some kind of special classpath container (as you see it in your project in Eclipse). So they are not copied to WEB-INF/lib directory but rather somehow "injected" by the WTP extension. But if you build Maven artifact (mvn package) everything should be OK.
I installed m2e integration for WTP and now it is copying the maven dependecies jars into WEB-INF/lib of the server installed apps directory.

Eclipse mvn project deploy to jboss

I changed my project to use maven2 (from just plain eclipse dynamic web project) and now I can't do Debug As > Debug on Server (JBoss).
Previously I can just do Debug As > Debug on Server (JBoss) and Eclipse will happily copy the war file into jboss deploy directory and I can debug etc.
Now it seems like eclipse just don't recognize the maven2 project and therefore cannot package the war file?
I have to deploy it manually using the command line mvn war:war and copy the war file to deploy directory.
What can I do to make Eclipse understand mvn project so I can just do Debug As > Debug on Server?
Eclipse 3.5
Use m2eclipse (and the extra Maven Integration for WTP). Once installed, Import... your webapp project as Existing Maven Projects and it will get imported as a dynamic web project.

M2Eclipse and EAR projects on Weblogic

How can I import a maven EAR project into Eclipse 3.4, and be able to use the IDE (WTP) to deploy the ear successfully to Weblogic (9.2)?
The main issue is that the dependent jars are not being included in the ear (under APP-INF/lib) when it gets deployed through the IDE. When I build from command line, the ear is exactly how I want it.
I am using the APP-INF/lib configuration for the ear plugin, and have included the jarModule sections for all the required jars.
When editing the eclipse EAR project's Java EE components, all the jars are listed, but not in the APP-INF/lib. Only when I open a dependent jar project do those specific jars get set under that subfolder. All the 3rd party jars are showing they will end up in the wrong place.
If you need more info, just let me know. Thanks!
You might want to use maven to create the eclipse WTP projects for you. This might be helpful.
The Using maven-eclipse-plugin in multi-module projects with WTP of the maven website describes how to develop Multi-module projects with Maven and Eclipse efficiently using the best of both Maven 2 and Eclipse's WTP. This covers projects that have EJB and EAR modules.
An fully working example of a multi-module projects, containing some JAR-, a WAR- and an EAR-project is even available for download if necessary.