I used to add my maven project to tomcat server v7.0 by right click server -> add and remove -> select my project -> Finish.
But today i dont find my maven project in the list.
There is only one project in the Available section.
How can i have my project in the list.
I have seen this kind of junk in IRAD (the IBM version of Eclipse) many times. I think the software is just plain buggy. Make sure you back up your code somewhere else, like in your code repository, and delete all your projects including local files. Then check everything out again. Also, tomcat is great for picking up changes in its webapps folder. You might want to just forget about deploying through eclipse all together. You have some other options that will actually allow you to see changes immediately with out having to redeploy.
Hot deploy solutions
1) Use Jrebel - this is expense
2) Expand your war in the webapps folder and send symbolic links back to your target folders containing your class, and to you jsp, javascript directories
3) Expand your war in the webapps folder and use filesync plug in (its been hard to find on the web for a while) to copy your changes to the expanded area
Other ways just to send your war/ear over, not hot deploy
1) Change your maven code to copy the ear/war to the tomcat directory for you every time you run maven install
Fully integrated IDE to webserver seems to be fantasy that they never quite worked out as far as I can tell.
Related
I have a web app project that looks like this:
Project/
src/main/java/...
src/main/resources/...
target/MyProject-0.01-SNAPSHOT/
META_INF/...
WEB-INF/...
App.html
App.css
etc..
I want to start Tomcat from within Eclipse. In the past when I've done web-apps the stuff that Tomcat is interested in is available in a war/ directory in the root of my project. The WTP plugin seems to know to copy the contents of that into a hidden tomcat directory (wtpwebapps) in my workspace, then it starts Tomcat. Now, however, it doesn't seem to be copying anything, which I suspect is because it doesn't know that it's actually in target/MyProject-0.01-SNAPSHOT/.
How do I tell Eclipse/WTP where the root of my application is?
Eventually I found it - This is controlled by the Project->Properties->Deployment Assembly pages.
I'm working with some very old, monolithic software that is basically a heavily customized JBoss deployment. Unfortunately, this means that JBoss can't be started from the "Servers" view in Eclipse, it must be started as a Windows service or via the command line. There are multiple WARs/EARs, but the WAR classloaders are rarely used and most of the actual class files are located in jboss/shared/lib as .jars.
We need a way to run a Maven build in Eclipse (via m2e) and deploy the class files in the resulting .jar to C:/product/jboss/shared/lib so that when we start JBoss, we can use Eclipse to debug (as a remote java application). Ideally, the artifact that Maven pushes will not overwrite the existing .jar file that was originally installed. For example, if the Maven project builds an artifact named myjar-1.0.0.jar, we need a way to deploy the classes inside of myjar-1.0.0.jar to C:/product/jboss/shared/lib/classes so that they are picked up by the classloader prior to C:/product/jboss/shared/lib/myjar-1.0.0.jar, which was installed with the product.
Currently, our (very hacky) solution is this:
Under the project configuration's Java Build Path > Source tab, we use the "symlink" functionality under Advanced to map the Default Output Directory (e.g. project/target/classes) to a class folder (e.g. C:/product/jboss/shared/lib/classFolder). This modifies the .project file, which is checked into source control.
We build the project normally with a m2e launcher (e.g. clean install).
Assuming the Maven build is successful, we run an Eclipse project build. This pushes the class files to C:/product/jboss/shared/lib/classFolder:
We restart JBoss. Since classFolders take precedence over jars, JBoss will load the classes in C:/product/jboss/shared/lib/classFolder, which are identical to the classes in our Eclipse workspace.
We attach to JBoss and debug the project as a remote java application.
Pros:
We're able to push our new classes to JBoss and test them without backing up the original jars and copy/pasting the new ones by hand (jar hell).
Cons:
We're compiling twice -- once with the maven-compiler-plugin, and
once with an Eclipse project build (Java Builder).
The symlink functionality is hit or miss in my experience. Sometimes we need to
do the refresh project/close project/build project dance to get it to
work.
Is there a better way to do this? I cannot force them to restructure the project so heavily that all deployables are container-agnostic WARs, but our developers need to be able to make changes and quickly test them without manually copy/pasting .jars.
How old is old?
Have you looked at the Cargo plugin?
http://cargo.codehaus.org/Quick+start
It can deploy to JBoss 3.x.
It has a Java API so you should be able to write something to extend it to do what you want.
Why are you trying to deploying classes instead of jar files?
You can still remote debug via Eclipse with jar files.
Worst case scenario - use Ant.
Maven is not designed for this kind of stuff, trying to force it to work will just cause you pain.
Once you have got Maven generated the right artifacts, work out what you would do manually and then script it via Ant.
I would try looking at the maven-dependency-plugin which has the possibility of copying artifacts to different location.
Please check your Deployment Assembly (project -> properties -> Deployment Assembly) and verify if your maven libs are there.
The are two "kinds" of jars in my project. One - jars made from projects which ,my project is depend from (e.g. my-second-project.jar), another - jars which are third-party libraries (e.g. hibernate.jar). The second kind of jars DOES NOT appear in deployment tmp dir while the first DOES.
I'm using eclipse 3.6, my project is dynamic web project, my tomcat version is 6.0.28. I've tried to recteate it - it doesn't help. I've also got similar web-project which works well.
I've made temporary work-around - I've put my jars directly to classpath. But this is just work-arond, but not the problem reason.
My waring/errors perspective output is clean, no connected messages whith this problem. Also I've got another "interesting" problem which might be connected whith this one. It's described here
Any help would be appreciated cause I've tried everything I can and I realy don't know what to do.
Do you have two projects, one depending on the other? And you don't get the jars from the project that the other project depends on? If so, make sure the jar files are exported from the first project: right click on the project, Build Path -> Configure Build Path... and then go to the "Order and Export" tab and tick the jar files you want to export.
(Am a maven noob)
Have a maven built webapp which uses spring, etc.
When I run "mvn clean install", it generates a .war file in the target directory.
I copy the .WAR file to tomcat for deploying the app.
Debug the app
Edit the code
This process takes a lot of time. When I earlier used ant, I would point tomcat's server.xml to my webapps directory. Also, Eclipse would put all of its classfiles in my webapp\WEB-INF\classes folder. If I had to modify any JSPs, I would just edit and there was no need of additional copying. If I modified a .java file, Eclipse would build it and put the .class file in the WEB-INF\classes folder so that Tomcat would pick it up.
Now, each time I make changes to a .jsp, I need to manually copy the .jsp to tomcat's webapps directory. Isn't there a way that a maven built app can optimize this process ?
So, where do you point your tomcat at that makes development productive?
project (where pom.xml resides)
src
main
java
resources
webapp
WEB-INF
target
webapp
webapp.war
Basically, I would like to know how to configure eclipse(3.7.1) and tomcat/maven so that the edit/deploy/debug cycle is really fast.
UPDATE1
1) I was able to get m2e(http://download.eclipse.org/technology/m2e/releases/) installed in indigo(v. 3.7.1 of eclipse). it had 2 components
a) maven integration for eclipse
b) slf4j logging
It installed successfully asking me to restart eclipse. I restarted.
2) Next, I installed m2e-wtp (at http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/)
It had 3 components
a) maven integration for eclipse
b) maven integration for eclipse Extras
c) maven integration for WTP.
When I selected all 3, I got some error. So, I unselected the 1st two and only selected the 3rd one and then it installed successfully asking me to restart eclipse. I restarted.
#Raghuram
I ran the 4 steps that you suggested below. Only the 4th step resulted in an error and my webapp could not get deployed. It resulted in an error "File not found --- .svn/.wcprops/.
http://i.imgur.com/Pg1aq.png
What should I make of it ?
Thanks again,
I'd recommend you to use cargo to deploy automatically to a local container (that can be downloaded and started)
Maven+Cargo
Then having that started with jpa activated (so that you can remotly debug your code) you just have to attach a listener and debug from eclipse, intellij, whatever.
For JSP, talking Intellij, you must tell your IDE where to package files (right-click 'package file") which is done in the project setup (output classes dir in WEB-INF/classes)
Check Tomcat 7 - Maven Plugin? for an example cargo configuration for Tomcat 7. After the confiuration is valid you can deploy to your Container using mvn cargo:deploy and mvn cargo:redeploy
If you use Eclipse Indigo with m2e and m2e-wtp, you can pretty much develop and debug your web application without any manual step.
Add tomcat as a server in Eclipse
Import your maven project as a maven project in Eclipse.
Build the project (using Eclipse or using maven)
Choose "Run as server...".
Eclipse will pretty much take care of hot deploying jsps as well as classes on changes.
I used ant when building my web app from eclipse to deploy to Tomcat 6 and referred to servlet-api.jar and el-api.jar within the Tomcat 6 release tree rather than pulling them in to my deployed library folder.
I am trying to deploy to Glassfish v3. I've pulled the jars from the www.java2s.com website.
Was this the right place to get them?
Did I need to do it at all? I searched within Glassfish and the jars weren't there
If I didn't need to do it at all, is there another course of action to follow to ensure the same functionality is available?
Seeing this question and the other questions you posted I have the feeling that you're doing things completely wrong. Here's just an answer which should get it all straight.
You should never have separate copies of servletcontainer-specific libraries wandering around in the classpath.
You should never put copies of servletcontainer-specific libraries in webapplication's WEB-INF/lib.
In an IDE like Eclipse, you should never add servletcontainer-specific libraries separately in project's build path.
In a nut: just do not touch servletcontainer-specific libraries at all. Don't even think of downloading them separately. That's plain recipe for trouble. Having separate libraries of different servletcontainer makes will only result in collisions in classpath. The servletcontainer should be downloaded and treated as its whole own.
In Eclipse, when integrating a servletcontainer (Tomcat or Glassfish), just add it in the Servers view.
To associate a dynamic web project with a specific servletcontainer (server) so that you can compile servlets and so on, you need to select it in the Targeted Rumtimes section of the project properties. Then everything will go well automagically, thanks to Eclipse smartness. That's also the place to change the servletcontainer implementation whenever necessary. When you're creating a brand new dynamic web project, you can just choose the desired servletcontainer implementation from the servers dropdown in the wizard.
When you want to create a WAR, simply rightclick the dynamic web project, choose Export and then WAR file. No need for a separate ant task or so.