Create complete EAR Project with Maven and Eclipse Helios - eclipse

I read some articles about how to set up eclipse and maven to create a new empty ear project but all solutions weren't complete or are to old.
I believe that I need to create three pom.xml files / or three projects:
client project with the WEB-APP structure (like a regular dynamic web project).
This should result in a WAR file.
server project with the ejbs. This should be a JAR file.
ear project which joins both projects together.
I tried that with help of the integrated maven plugin in eclipse. Since (I believe Helios) maven is already integrated in eclipse. So I go to
file -> new -> maven -> maven project
and leave the "create a simple project" checkbox unchecked. On the next side I got the archetype catalog. To create the client project I looked for maven-archetype-webapp Version 1.0.
But all the folders like WebContent\META-INF etc. are missing.
So how can I create all three projects are build them together?
Thanks a lot,
Hauke
PS.: I read in question 5668710 about creating the project without maven and activate the dependency management. But is that the right way? I don't think so.

Creating the projects via console and importing them via m2eclipse would be the best way, as you can read it in the comments of your question.
Start off with this line in your console
mvn archetype:generate
Then use the archetype maven-archetype-j2ee-simple
This will generate you a project structure for ejb, ear and web projects. Otherwise you can create 3 simple projects maven-archetype-quickstart on your own and add the concering plugins
maven-ear-plugin
maven-ejb-plugin
maven-war-plugin
Here is another post, handling your problem: Maven2: Best practice for Enterprise Project (EAR file)
Another nice example you can find here

The best and the most clean way for creating an Enterprise Application (all the three projects ear, jar, war.... i.e. jar and war are linked into ear).... is to create through maven Enterprise Application in NETBEANS and import the whole project into Eclipse.
Thanks
Imran

Related

Setup a Eclipse Workspace With One Dynamic Web Project and Multiple Java Projects

Can someone guide me to setup a web app project in Eclipse. I want to have a Dynamic Web Project and multiple Pure Java Projects. My Web project will contain JSPs and Java projects will contain Struts Action classes, Spring Bean, Hibernate Entities etc. I want to use those Java Projects as dependency to the WAR. I have done work in such environments, but haven't setup a workspace from the scratch. Can you please guide me or share a link?
Note: I want to use Apache Tomcat or Glassfish as server
In every project you can set the JavaBuild Path properties.
So suppose you have project1 that is dependent on project 2 and some other libraries provided as jars. Go to that option for project1, choose tab Projects and add project2 (that of course is already a eclipse project), than go to tab Libraries and clic on Add external jars.. You are done. This is not dependant by the nature of the project.
Specifically, since you have a Dynamic Web Project, you'll need to go also to Deployment Assembly and add project2 and your jars to the list of files needed by the server.

How to convert properly Eclipse project to Maven project?

I have created in Eclipse Dynamic Web Project. Then I have selected option 'Convert to Maven Project' from 'Configure' from right-click menu. And now I can see red errors on Java Resources folder in my project. But none subfolder is with red error. In which way can I resolve that problem? I am using Eclipse Juno and m2e plugin.
I have recognized that m2n plugin haven't created src/main/java, src/main/resources and src/main/webapp directories in Java Resources. But the error is still the same.
The process in manually. You need to create a pom.xml and change your folder structure to follow Mavens conventions. I would recommend to create a web project via maven archetypes and move your project step-by-step into the new structure.

Local Project Dependencies and Maven

I'm converting an ant backed Netbeans project into an Maven project. I've got most of the third party libraries set up in the POM, however now I've run into problems with setting up the local dependencies.
With the previous Netbeans way of doing things, it just added a project reference [with links to the source and jar location, rebuilt the dependency if the depedency's source had been changed and hadn't been compiled]. However I'm not sure how to setup up Maven to emulate this behavior. Is it possible?
Example:
Projects/SharedLibrariesResource [Ant based project]
Projects/WebSite [this is a maven based project]
Projects/Client
In this example the website and client projects don't connect to each other, but they do share the SharedLibrariesResource. Website should compile to produce a War with links to the SharedLibrariesResource
The way I understand the question, the Website maven project depends on the ant SharedLibrariesResource project. When Website is built, it should include the SharedLibrariesResource artifacts. The assumption is SharedLibrariesResources produces a jar artifact.
One way to achieve this is to
install SharedLibrariesResource to your local maven repository each time ant builds it
specify this as a dependency in Website pom.
We can use maven ant tasks to achieve the first.

Change NB project to maven project

I have created java desktop application project using NB and now I want to convert it into maven project so everybody will be able to compile it and maintain in eclipse/netBeans. Is there any easy way to do this?
Or maybe there is some way to convert project created using wizard in NB to eclipse?
I'm currently doing this for an Enterprise Application, which consists of 3 modules (EJB,EAR and WAR).
Its as simple as creating the new Maven project and copying your .java files into the new project and dependencies into the pom file.

How to get peer project source in eclipse and maven

creating a parent project with only a pom.xml, and lots of sub projects such as:
my-web
my-core
my-backoffice
etc. is easy, and the sonotype eclipse plugin does most of the work.
However, getting one project to know about the source in the other project seems to be hard. E.g. when you are debugging the my-web project, and step into my-core, eclipse doesnt know where to get the source.
Looking in the Java Build Path in eclipse, the maven plugin has added my-core as a folder under "Web App Libraries". I.e. its not using the my-core-0.0.1.SNAPSHOT.jar or similar, its using the raw java files. Great!
But how to tell maven to tell eclipse to look for the source in the same place?
Im not really sure where to start. Im guessing its possible to get maven to put the source in a special jar using the maven-soure-plugin, but this will usually be out of sync with the actual java files which the web project seems to be using directly.
A quick and dirty solution is to manually Edit the Java Build Path for each project, and add my-core and other dependant projects in the "Projects" tab. Is this best practice? Any other suggestions?
A quick and dirty solution is to
manually Edit the Java Build Path for
each project, and add my-core and
other dependant projects in the
"Projects" tab.
If this doesn't happen automatically you have a configuration problem.
My Guess would be that you have a version mismatch between the pom dependencies and the actual project versions. Or your projects have an unusual name template (m2eclipse resolves projects by their artifactId AFAIK)
Either way, what always helps is in your Debug configuration (Run > Debug Configurations ...) select the Source tab and just Add... the selected projects.