Eclipse-Kepler, Maven and Setup Tomcat 7 debug (hot deploy) - eclipse

I have maven based project with following structure:
main_project
module_webproject
module_java_proj_1
module_java_proj_2
module_java_proj_3
... ...
Everything compiles and packages fine with command line maven goals execution. I need to setup this project into eclipse environment for developers with tomcat deployment. Anyone know setup instructions?
Also, i am looking into tomcat hot deploy for debugging capabilities.
I have tried mvn eclipse:eclipse, this does only creation of .project and .classpath files. But projects directories are not treated as java or web projects.

Answer from following forum some what helps...
[Running Maven project on Tomcat from Eclipse
There can be a few reasons why you don't see the project in the Add/Remove projects dialog for Tomcat. Verify the following:
You have m2e installed (http://eclipse.org/m2e/download/)
You have m2e-wtp installed (http://www.eclipse.org/m2e-wtp/download/)
Your Maven project imported as a Dynamic Web Application. Look for a Deployment Descriptor entry when you expand the project, it should be somewhere in the first few entries. It is the second one down for me on Eclipse Juno. Not there? It's probably not a web app. Go back and verify 1 & 2, then remove and re-import your project.
Make sure that your web application is not too new for the version of Tomcat that you are using. Right-click the project and go to Properties > Project Facets. Look for Dynamic Web Module and check the version. If this version is too new for your Tomcat version, Eclipse won't let you add it. For instance, your Dynamic Web Module version is 3.0 and you're using Tomcat 6.

Related

Eclipse glassfish plugin not publishing maven dependency jars to ear lib folder

I'm using the Eclipse "Internal Glassfish 3.1.2.2" server with the Eclipse Glassfish plugin (http://download.java.net/glassfish/eclipse/juno). I'm also using Maven with the m2e Eclipse plugin. The Glassfish plugin correctly deploys my EAR modules to the Internal Glassfish, but it does not deploy my dependency jars, which I believe should end up in a folder called "lib".
I found a partial solution here, which is to add my maven target lib folder to the EAR Deployment Assembly (double-click in the Deploy Path box to edit). This works, but m2e (or m2e-wtp) undoes the config change when I do Maven > Update Project.
There ought to be a cleaner solution. The Eclipse Ear Module Assembly dialog has a field to name the "EAR library directory", so it's aware of the lib folder. Where does Eclipse EAR assembly (without Maven) look for jars to put in the lib folder? I assume the Glassfish plugin is looking in the same place.
You can use the following steps to find the source of the problem:
Take Eclipse out of the equation and build EAR on command line using Maven, does it turn out ok? If not, look for a solution in your pom.xml.
If ok so far, open Eclipse and perform Maven -> Update Project. Then export EAR using Eclipse (look for EAR export wizard under File -> Export). Did the exported EAR turn out ok? If not, file a bug report for m2e-wtp plugin. It is still pretty raw, so it wouldn't be surprising if it doesn't setup Eclipse metadata correctly in some cases.
If ok so far, then it is time to look for a problem in Glassfish plugin. I doubt that you will get this far, but if you do I will help you to follow up.

Importing Java Web EE Netbeans Project to Eclipse

Looking for a clean way to export a NetBeans Java Web Project (Java EE) to Eclipse.
Already tried importing the war file, but it outputs many errors. I think because EJB object is not contained there.
Netbeans project has a connection with PostgreSQL, and Glassfish server, everything installed on my Windows PC. It's using the EJB module, and it features a REST implementation, with JPA persistance.
Using Netbeans 7.2 and Eclipse IDE 1.5 (latest)
Here is a view of the Netbeans project:
Below is the project resulted from the import of the war file (generated by Netbeans) in Eclipse.
Which would be a clean way to do this?
I can also hear ideas about importing it to IntelliJ Idea.
Solution took long, but here are the basic steps:
Create empty EAR Project In Eclipse, add 2 modules, EJB and Web Module. Then added JPA facets to the EJB project. Imported src folders. Then exported the EAR Project to to JBoss (changed Glassfish, no particular reason).
Basically 1 project in Netbeans is equivalent to 3 projects in Eclipse in this case.
Prepare to get your hands dirty.
Netbeans uses Ant build scripts by default. These scripts cannot be directly converted to work with Eclipse.
The way I did it was to create a Maven project in Netbeans and copy all source files from the Ant project to the Maven project. Eclipse provides a Maven plugin which enables you to work with Maven projects. Maven projects (if set up correctly) tend to be IDE independent.
You could try to create new project in Eclipse, and choose "Create project from existing source". Then point src folder from NetBeans project. You probably will need to organize your REST services etc by yourself, but I think that is the way.

deploying a war file in WTP(Eclipse) tomcat server

I have a maven build Java project.
My war file name is: test-1.0-SNAPSHOT.war
I am using M2E plugin in Eclipse.
I have run target mvn package.
Added server as tomcat version 7 in eclipse indigo 3.7. Server started. But my war file didn't deployed in the server.
I have tried by right clicking tomcat server and Add remove..., it says "there is no resources that can be added or removed from the server".
How can i deploy my war file in the eclipse WTP tomcat server?. Do i need to run any maven target?
Make sure that you have "Maven Integration for WTP" installed in your Eclipse instance.
First check if it's available through
Window->Preferences->Maven->Discovery->Open Catalog
If for whatever reason this does not work, you can get WTP integration from this update site (that's the version I am currently using):
https://repository.sonatype.org/content/repositories/forge-sites/m2eclipse-wtp/0.13.0/S/0.13.0.20110623-0455
This integration does a lifecycle mapping of maven-war-plugin into m2e architecture.
Once you've installed the WTP integration, you must restart eclipse and once it's restarted, right click on your web app project and choose: Maven->Update Project Configuration...
Also, I would advise to run a clean build at this time.
Last, but not least, delete and recreate your Tomcat server configuration (I don't know why, but I had to do it quite a few times when I switched to m2e).
I think eclipse is not recognizing your project as a web app, To confirm this
Open to do open J2ee perspective on your eclipse, If you open the project folder of your app, You should see (Deployment Descriptor)
If you don't see it, your app is not web app as far as eclipse is concerned
I have see this in case if you imported/created a maven command line project
To fix this
Select Project ==> Properties ==> Project Facets ==> make sure Dynamic Web Module check box is checked
If you do that the local tomcat server will add your app when do add remove projects
I think eclipse is not recognizing your project as web app,convert your project into web app by command mvn eclipse:eclipse -Dwtpversion=2.0 and try to deploy in Eclipse configured tomcat,it will work.
If you have Eclipse 3.5 or above you should ensure that you have both the m2eclipse (m2e for 3.7) plugin installed and its WTP add-on. With these you shouldn't need to change your configuration by hand.
Did you try to build your project from the command line and deploy it in Tomcat by hand?
By the way, have you read this wiki post? It's a bit old, but it may still be relevant.
Adding 2 cents to Prasanna wonderful solution.
I realized that building maven war files "mvn package" was just creating .war file but eclipse was not picking up that war but was deploying its some internal version of it's app war.
I found that server > Browse Deployment Location.. in Eclipse server view .. it was taking to some abstract location like "C:\Programs\workspaceSTS.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps"
Where I could see my exploded app deployed but it was not having any /classes folder just limited files.
Using Prasanna's method I realized that eclipse now was deploying full exploded .war now.
So this was happening coz changing the facets to Dynamic Web Module has actually populated "R-click project > Properties > Deployment Assembly "
This Web Deployment Assembly window only tells eclipse what to deploy and what not. So even if your project is NOT setup as Dynamic Web Module , and still if you configure "Web Deployment Assembly" values properly , eclipse will deploy the app fine to Tomcat/ Server.

Eclipse WTP: Glassfish does not include WEB-INF/lib in classpath

I started a new dynamic web project in eclipse helios. I integrated glassfish into eclipse and it works fine so far. Except one thing:
I place my libraries (jdbc, log4j etc.) in WEB-INF/lib. Eclipse deploys that files correctly to glassfish, but glassfish does not include that directory in its classpath, so my app won't run (because it can't find the jars).
When I edit the server's "launch configuration" in eclipse, I can manually add the libs under "Classpath", but that don't change a thing.
Only when I manully copy the jars to glassfish's lib/ext folder, the libs are included.
When I used tomcat as a server it works, the libs are in tomcat's classpath. But I want to use glassfish without copying the libs manually.
Any idea?
Not sure how do you add the libs in your project.
Try to show the project properties tab, select the Deployment Assembly node section, and click the add button. Select archives from file system or project (if your lib i also an Eclipse j2se project).
This should work.
Hoping you use the latest Eclipse 3.6 SR1 and the latest glassfish plugin from the update Center: http://download.java.net/glassfish/eclipse/helios
My servlet did not find the jdbc driver, so I thought it was a lib missing. Calling “ClassForName“ solved the problem. This seems strange to me, as this is not needed when used in the SE context.
So eclipse is correctly deploying the libs, just a little extra code is needed.

Integrate War-Plugin for m2eclipse into Eclipse Project

I set up a small web project with JSF and Maven. Now I want to deploy on a Tomcat server. Is there a possibility to automate that like a button in Eclipse that automatically deploys the project to Tomcat?
I read about a the Maven War Plugin but I couldn't find a tutorial how to integrate that into my process (eclipse/m2eclipse).
Can you link me to help or try to explain it. Thanks.
I set up a small web project with JSF and maven. Now I want to deploy on a Tomcat Server.
During development I recommend to use Eclipse Web Tools Platform (WTP). M2Eclipse provides support for it (assuming you have Maven Integration for WTP installed) and your project should be recognized as a Dynamic Web Project runnable on a Server.
So, declare Tomcat as a Server (show the Servers view and right-click in it to add a Server via New > Server). And deploy your project to it (right-click on your project then Run > Run on Server).
There are other options like using the Tomcat Maven Plugin or the generic Cargo Maven Plugin but I wouldn't use them for development and, since you are a Maven beginner, I don't recommend them at all. Use your IDE.
I read about a the Maven War Plugin but I couldn't find a tutorial how to integrate that into my process.
Actually, the Maven War Plugin is only responsible of the packaging of your webapp project (it is bound automatically on the package phase when using a <packaging>war<packaging> for your project). It isn't used for deployment. But as I said, use your IDE to deploy your application during development.
The war plugin is for generating war files, not for deploying them. What you are asking for may be provided by the Cargo Plugin. Another interesting candidate for you could be the jetty-maven-plugin.