What should I do in order to be able to work with maven + eclipse + wicket + hibernate + spring in Mac OS? - eclipse

I want to create a web app that will use wicket, hibernate and spring frameworks. My IDE of choice is Eclipse, I am using maven for the .war generation and I am running Mac OS. What steps should I follow to correctly install and configure all the tools so as to have a project running that relies on these 3 frameworks. I was able to successfully set up wicket but I am having trouble for setting up hibernate and spring. I went through multiple tutorials but I still couldn't find the solution.
Thanks!
I will now try to explain a bit what is the problem I can't solve. I first began with a clean project:
mvn archetype:create -DgroupId=test.framework -DartifactId=microForum
Moved on to the project folder and mvn eclipse:eclipse
Imported the project from eclipse
Looked into the apache wicket homepage where there are multiple examples, so I read through the page and that was enough to learn what to add to the pom and had wicket and everything up and running nicely
My next step was trying to use hibernate and/or spring. I thought that "adding" hibernate and spring in the same way I added the wicket necessary configurations and dependencies to the pom (by hand) might not be that easy. So I tried using the maven archetype: appfuse-basic-spring. So:
mvn archetype:generate -> launchs the wizard that lets you choose among different archetypes
After choosing the archetype number 2 ( Hibernate + Spring + Spring MVC) it fails
After googling a bit I found out why it fails (something like I should add a -archetype after appfuse-basic-spring. So, instead of using the wizard, I put:
mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring*-archetype* -DarchetypeVersion=2.1.0-M1 -DgroupId=test.framework -DartifactId=microForum2
This created my project (after multiple warnings). I paste a screenshot (Image 1) because some of the information might have some important meaning :
http://img97.imageshack.us/img97/6687/screenshot20100323at112.png
- Image 1
I then did mvn eclipse:eclipse and it started downloading millions of things, which seemed very odd so I Control+C it.
Following schmimd04 answer I tried to use the eclipse maven plugin but I couldn't create a maven project:
Unable to create project from archetype [org.appfuse.archetypes:appfuse-basic-spring:RELEASE]
The defined artifact is not an archetype
Thanks!
p.d: My Mac OS already had maven installed (version 2.2.0), I tried downloading the last one and repeating the same steps but I still had the same trouble.

Bert's recommendation LegUp, jweekend.com/dev/LegUp, have worked just fine for me. I used the wicket + Spring + JPA archetype. I will still look for the reason why maven's Hibernate+Spring+Spring MVC archetype didn't work for me. I'll edit this once I have the answer. For the time being, legup did the job!
Thanks

Install the Maven plugin for Eclipse from the update site: http://m2eclipse.sonatype.org/update.
This will allow you to create Maven projects (I would start with the quickstart archetype) and easily add dependencies, such as Hibernate, Spring, and Wicket.

As Pascal is saying, your question is to broad to answer. A few pointers that might help you:
use 'mvn eclipse:eclipse' to generate an Eclipse project out of your pom.xml. There might even be a working eclipse project that allows to open a pom.xml as eclipse project. I can't say, i left eclipse behind for good.
spring is 'just' a library that need to be in your classpath. the above command will ensure it is there (if it is defind as dependency in the pom.xml) You need to define a applicationContext.xml for Spring that resides in your classpath. See the Spring documentation for that.
hiberate is similar, it is just a library that needs to be in the classpath and that needs to find a config file. in there, the connection to the database is described. See the hibarnate docu (or one of the many blogs out there) for more info.
If you are stuck with a particular problem, please describe it so people can help here.
Bert

I don't know if it sounds odd. But it is because you have archtype data in your .metadata for respective workspace. If you delete the workspace. You can create new archtype. I know deleting worksapce is not a good idea. But still it works.

Related

Dynamic web application in eclipse using MAVEN 3.04

From past 90 hours I am trying to know how to use Maven in my web project, generate a war file and deploy it into my JBoss 4.2 Server.
I am not getting.
I am reading all kinds of blogs, googling almost all time, trying out all kinds of way to build a dynamic web project with maven, but trying out different methods make a simple thing more complex.
Few examples tell me how to run, few tell me to change the folder structure, few tell me transfer the contents of web content but nothing is matching my requirements. In some of the examples war file is getting generated, but of some big name, and it does not contain the jars inside. Uff.
I know maven is easy and makes our lives better but learning it for the first time makes it complex.
My requirement is simple.
1) Build a Dynamic web project in eclipse indigo. (Preferably in JAVA perspective )
2) Enable Maven dependencies, in eclipse.
3) Update pom.xml to add dependencies.
4) Finish the web application i want to do by writing classes, html pages, deployment descriptors.
5) Build the war file using maven "IN ECLIPSE ONLY". (the WAR file must have user specific name and not some name like "V1- Snapshot dash dash dash")
6) Deploy my war file in jboss 4.2 server deployment location. (Preferably from eclipse )
7) Run my localhost server and my application from the browser.
And Done.
By spending time on it I am understanding how beautiful is maven, but I am not able to achieve what I want.
Please help me by giving me a detailed procedure on how to use maven to meet my requirements above.
Fist I would suggest to use the newest Eclipse (Juno) with Maven support (m2e and wtp-m2e).
The first step is to define your pom with the appropriate dependencies and the correct packaging type which is in your case war.
If you really need a different naming you should leave Maven, cause maven makes assumptions about the naming of your artifacts which usually isn't a problem. The default version patterns as 1.0.0-SNAPSHOT etc.
If you wan't to deploy the war into JBoss there exist a number of possibilites to do such things and if you like to run your application locally it sounds you wan't to do some kind of testing (integration testing) which is supported by Maven (see maven-failsafe-plugin).
Furthermore you must learn if you like to use Maven to understand that not Eclipse is anymore the leader of the project configuration. This job has been moved to Maven or in other words into the pom file. If you like to use the project in Eclipse you need to import this project into Eclipse.
Apart from the above i would suggest to go to a Maven training to lear all that stuff which is more effective than learning it yourself.

Errors when importing Mahout's maven resource to eclipse

I'm trying to import Mahout's maven resource to eclipse, but i meet these errors:
I have tried google but it doesn't help.
Eclipse : Helios Service Release 1
Maven : External Maven 3.
Edit: If I try to play with latest stable release ( Mahout 0.7 ) and not the latest snapshot that the official site recommends for downloading, I experience the same error.
Follow step-by-step this link: https://cwiki.apache.org/MAHOUT/buildingmahout.html
After doing this and re-importing mahout, these errors you noticed go away.
Notice: Before compiling the code in the right way (as stated at the link above), I have followed the instructions from here:
http://domengrabec.wordpress.com/2010/12/14/installing-maven-on-eclipse/
Q: If anyone could help me with this related issue:
Include classes of Mahout math libraries of both core & math folders - Eclipse - Hadoop , I would be grateful.
I think what you need is to build mahout in a different way,
first install m2e plugin for eclipse, then you can create maven project. You can make the run configuration (package) after that to make sure everything is fine.
The important part is that you have the pom.xml in the project so you have to add the dependencies of mahout that you want.
You can get the dependencies from searching on google " name of the dependency in mahout api".
i solved it by manually applying the patch in https://issues.apache.org/jira/browse/MAHOUT-1043 to 0.7 sources (changes pom.xml files and src/conf/driver.classes.conf )
just one note, do not remove the groupid in distribution/pom.xml
launch an external mvn eclipse:clean and update the projects. All errors are gone when workspace is rebuilt

Hibernate Setup in eclipse helios

How I can setup Hibernate for a Dynamic Web application by using Eclipse Helios? I am a newbe so please let me know if there is any example.
I tried for Java application and included all JARS and it worked fine. But don't understand how I can do it for Web application and test it.
I will use Struts2 so I will appreciate if I can get appropriate example or guidance.
Drop the jars in WEB-INF/lib. Those jars are automatically added by Eclipse to the project build path, and constitute (with the WEB-INF/classes directory and the container classpath) the classpath of the webapp.
http://hardik4u.wordpress.com/2008/09/02/struts-2-hibernate-3-integrationcomplete-using-eclipse/
https://stackoverflow.com/questions/4364923/struts2-and-hibernate-framework-create-in-eclipse
First, download Struts2, and import example WAR file into Eclipse. You can find it from the source folder: struts-2.3.1-all\struts-2.3.1\apps\struts2-blank.war
Second, you should install Eclipse Hibernate Plugin. Goto Window > Preferences > Install/Update > Available Software Sites and add following link and name it JBossTools or something.
http://download.jboss.org/jbosstools/updates/helios/
Depending on your needs you can install Hibernate Plugins for many project types. In this case, select web application plugin.
And after, you should include Hibernate Core libraries into your classpath. I would recomment Hibernate 3.6 and greater. Because it does not depend on asm (asm-3.3.jar, asm-commons-3.3.jar ...) anymore. If you use earlier versions you might encounter some problems, since Struts2 also depend on asm libraries.
Then create your database, and use following link to configure and generate model bean classes.
http://casteyo.wordpress.com/2007/06/06/conf_hibernate/
Now you don't need to write mapping files by yourselves. And with DAO factory pattern you have your way to finish your project.
Hope this helps, and Goodluck

gwt-maven-plugin with Eclipse Indigo

I would just like to setup a new GWT project in Eclipse and use Maven for dealing with all the jar jungle. I used gwt-maven-plugin with this instructions, but I can't get the project to work in Eclipse.
What I've actually done:
Created a maven project using the archetype gwt in command line.
Imported the projet in eclipse using import > existing maven project
While doing that I had errors saying:
gwt-maven-plugin:2.3.0-1:generateAsync - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:i18n - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:exploded - "No marketplace entries found to handle"
These errors don't go away even if I ignore them on the import.
How can I make these projects working? Is the problem that I skipped the "process-resources" setting? (There is no such setting in the latest version of m2e.)
Should I even use gwt-maven-plugin? Is there any other way of making a GWT project to use Maven? Or – is there any other way to fight with the jar jungle? What does GWT guys use?
I use Eclipse Indigo with m2e plugin 1.0.0 and Google suite plugin version 2.3.3.
Eventually I gave up Maven. As one other developer said "good ideas and bad code build communities faster" , I also remember my experience with Maven on all the projects: very promising on the beginning, but eventually you get to some problems and end up working more with configuring Maven than actually dealing with your own code.
I decided to manually copy needed .jar-s into /lib folder. I spent some time due to transitive dependencies, but LESS than dealing with Maven and now I have things under control. If sometime in the future working with libraries will become an overhead, I will consider using Ivy.
If someone wishes to stick with Maven, I lately found a very useful link by Google team:
http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven
They recommend using their sample projects and not gwt-maven-plugin archetypes (due to issues). I agree. They also provide needed pom lifecycle changes for Eclipse Indigo.
According to a recent post on the gwt-maven-plugin mailing list the Maven integration is not complete for Eclipse Indigo, since the M2Eclipse 1.0 release has brought about a large number of changes. The suggested workarounds from David Chandler, Google engineer, are:
You can run "mvn package" on the command line or right-click on the project > Maven > Run as > Maven build.
The plugin execution failures you're seeing can be resolved by adding lifecycle mapping metadata as in the sample POMs. They are only needed for Indigo. You should not get these errors in Helios or when running mvn package from the command line.
Disclaimer: The following guidelines are for Windows users. These steps are on the basis that, they have worked when tried by the replier and doesn't guarantee fulfledge working unless experimented by self and tried with proper prerequisites.
::Creating a simple gwt project using archetype::
Following are few commands that can be used to create a simple gwt project "Web Starter Application":
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 org.apache.maven.plugins:maven-archetype-plugin:generate
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 -Dmodule={module name} org.apache.maven.plugins:maven-archetype-plugin:generate
(The value of archetypeVersion can be 2.3.0 or any higher stable version.)
Few coordinates are required by maven to create the gwt project. They are as follows:
groupId
artifactId
version
module
The first command doesn't take any of the above coordinates hence, we need to supply them at the time it executes. Notice that the archetype goal is mentioned right at the beginning of the command. It is mandatory to give the archetype goal.
The meanings of these coordinates can be found here.
One of the best ways to start with understanding maven is this.
The second command doesn't consider the module name hence, you will be prompted to give it at the time the command executes.
The third command is equivalent to running it in batch mode where you just have to confirm the inputs for groupId, artifactId, version, module as mentioned in command itself.
Once any of these commands gives a BUILD SUCCESS result, then navigate to the just-now-created project folder from command line and execute the following command:
mvn gwt:run
It should start the project in Development Mode so that you can Launch the Default Browser to run the project or Copy the URL to clipboard and navigate to it through any browser.
Good luck with the execution.

Efficient dev cycle with Maven, Tomcat/Glassfish, Archetype?

So far i've been using tomcat and glassfish to develop a testing webapp, without maven. And the usual development-till-deploy cycle is simple :
develop in eclipse ide, with a WebContent folder, which is the root webapp folder that has the WEB-INF, web.xml, WEB-INF/lib, n all. The compiled classes location in eclipse is set to WEB-INF/classes.
after coding, i could just click on the reload button in glassfish admin console for that specific webapp. In tomcat, i believe it's reload also in the tomcat manager.
i could access the web application in the browser
Now if i would like to create a new webapp, that'll make use of latest stuffs of jsf, spring, jpa, hibernate, postgresql :
what recommendation of archetype should i use in the creation of the project ?
can i still use my previous steps of development? because i think it's very easy without having to repackage everything into a war file, or copying it into the tomcat's webapp folder everytime i want to test. Saving the files in eclipse, hit on the reload in the admin console / tomcat manager, and i could instantly test the updated webapp.
Or what do you usually do in the webapp development cycle ? Please share your experiences, =)
Thank you !
Development Cycle with Maven and Friends
Use Maven to drive your code-build-test-deploy-release cycle.
Start with Maven Archetype that suits closest to your web-app. This will create the whole folder structure for you and will add Jar depencies.
Use an embeded light-weight server like Jetty, this will be very fast on dev machine without sucking resources and is highly configurable. Plus, you can set it to auto-reload changes.
Most of Maven project are supposed to be test-driven. Of which Maven takes care of using it's surefire plug-in. So, every build will have a test phase.
You can define multiple profile for various environments (test, dev, prod, Win, Unix..). These profile will alter the behaviour of the project to be compatible with the environment.
Use Cargo, again a Maven plugin to deploy your builds on test or production server, which can be Glassfish, Tomcat, Jetty or any oter webserver.
Use Liquibase with or without Maven :) to manage your database changes the same way you manage your code change.
I came from almost similar project as yours in my previous company. Development with Maven makes things so smooth and the change is appreciable.
A little Google search shows that someone has worked on archetypes for JSF and JPA with Spring
Edit#1 -- added more details
Feasibility and Ease of Use
Maven is born out of neccessity to simplify the dev process for large and distributed code.
Maven is very well integrated with Eclipse -- so it's painless.
Jetty keeps monitoring source folders, so your changes gets deployed almost immediately.
You can customize the build to skip tests, to not build dependecies. When you just edit a UI component, Jetty will silently copy it to "target" folder.
If you're worried about copying and redeploying. You must read THIS to see how efficiently things are done, keeping in mind that you don't have to compile-test-deploy everytime you change a JSP or HTML.
That said, I would like to mention that Maven might be a challanging learning. This is an object oriented way of development cycle, to say. Most of us, who are used to build script, can find a bit tedious/verbose initially.
Resources
I would suggest to go through the following resources
Maven Book - Maven basics
Automated Deployment with Maven - going the whole nine yards If you can, literally follow this pattern.
Maven 2 Effective Implementation -- this book really helped us a lot.
for the q2 :
You can still run/debug app with tomcat from within the IDE (eclipse) even if you change the directory structure. (like the maven dir structure instead of eclipse's dynamic web dir structure)
Project properties - >
project facets - >
Dynamic Web Module ->
Click the appearing "further configuration available"
and set your content dir and context root.
You dont have to package everytime you want to run/debug it.
Another option is using Jetty
And I am sure there are more options others will tell as well.