• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Using Tomcat in Eclipse Luna - Classpath Issues

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I have recently upgraded to Eclipse Luna. In my previous version of eclipse, I ran Tomcat via the Tomcat "plugin". Using the plugin, it was easy for me to add eclipse java projects to the Tomcat classpath. This saved me from having to create and export jar files to my WEB-INF/lib directories from the eclipse java projects. It also hot-loaded my changes of java and HTML files.

In the latest version of eclipse, Luna, I am trying to configure Tomcat to run in its "Servers" project. I have tried MANY configurations and various instructions to try and add my java projects to the Tomcat server classpath. I can get it to partially work. I can change java files in eclipse and see the changes, but ONLY after tomcat has loaded them from the jar first. Also, I used to be able to hot reload HTML files that are in the java project, now I cant seem to do that.

Here's what I am trying to get back to :
1) Use the java project instead of the jar file in WEB-INF/lib. In the old eclipse using the tomcat plugin I did not even need the jar file in WEB-INF/lib, it just knew to use my java project because it was configured on the tomcat classpath. Now, if the jar file does not exist, it never finds my class files in my eclipse project.
2) When I make a change to a java file, I should be able to immediately see the change take effect (when I refresh the browser for example).

Simply put, I want Tomcat to use my java project ALL the time, and never the jar file.

Has anyone had the same troubles, and if so any advice? Much appreciated.

Tyler
 
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Same here, I still have the old plugin installed in eclipse Mars since I keep my workspace from version to version of eclipse (my workspace must be 10 years old ;-). Anyway, I do not use the plugin anymore, I use the built-in tomcat interface now and it works pretty well!

To provide the hot reload functionality you have to start tomcat by clicking on "Debug". If you click on "Start", hot reload won't work. This is documented somewhere but it took me a while to find it...
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the jar file issue, I ain't sure what jar file you are talking about and what it would be doing WEB-INF/lib.
 
Saloon Keeper
Posts: 25466
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You appear to have an extreme case of IDE dependency. I.e. you have no idea what you are actually doing. Or (more importantly) why the things that worked actually "worked". More or less.

Eclipse is not some program for running Tomcat and it is certainly not some program running webapps. No sane IT shop in the world would be running production web services on Eclipse. Eclipse is a developer's tool and like most developer's tools it is not supposed to be part of the production environment.

I recommend that you shut down Eclipse and pick up a good book on J2EE. Learn what a WAR is and how it's structured. Once you understand that, you can go study the Eclipse documentation on how to use Eclipse to produce WARs. Tomcat works with WARs, just like all good J2EE servers do. There are some "magic tricks" that can be used with Tomcat/Eclipse to work with the intermediate products that WARs are built from but to properly understand how they work you first need to understand how WARs work without all the trickery. And, I should add, that the "Run on Server" plugin for Tomcat that comes with the J2EE edition of Eclipse does pretty horrible things to Tomcat anyway, which is why I don't use it and use the "mongrel" third-party Tomcat plugin instead.

Dumping classes willy-nilly into Tomcat's own classpath is not the way to do it. At best it will make Tomcat -and the webaapp - itself unreliable. At worst you could corrupt the whole system.
 
Tyler Wassell
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A.J. Thanks for the response, that helped.

 
He was expelled for perverse baking experiments. This tiny ad is a model student:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic