USer22999299
USer22999299

Reputation: 5684

How can I avoid from deploying jars into the web content folder while using tomcat?

So I'm facing into a problem that is slowing down my development process.

I'm using eclipse with tomcat 8. My software has 3 different tomcat servers that runs on different project.

As well my software is divided into 8 components, each one of the tomcat servers using some of the other projects.

For now I'm using Jenkins in order to build my software and deploying the jars into the web content folder of the tomcat servers.

The main problem is that to build it it takes 1 min, then I need to refresh all the projects in eclipse then restart the tomcat servers from eclipse.

I'm looking for an easier and faster way to do it.

Is there any way to point the tomcat servers in eclipse to actually look into the src folders of the project instead of looking for the jars?

Upvotes: 0

Views: 106

Answers (2)

USer22999299
USer22999299

Reputation: 5684

Had hard time to make @wero solution to work.

Found another useful workaround for this:

Right click on project -> build path -> configure build path -> source

Than you just linking the source of the other project into servlet one.

Upvotes: 0

wero
wero

Reputation: 32990

There is a technique to let Tomcat create web contexts from your eclipse projects instead of building and deploying to Tomcats webapp folder. The main advantage is that no build of a war file or copying of classes (file like done by dynamic web projects) is needed.

Basically it involves the following:

  1. You have a eclipse project with a bin folder, dependencies on jar-files, possibly dependencies on other projects and a web folder containing the webapp resources including a WEB-INF folder.
  2. Instead of deploying to Tomcat you create a context in Tomcats server.xml pointing to the project resources needed by Tomcat to run the app. Tomcat is then fetching classes and resources from the project location.
  3. After you did some development and you want Tomcat to pick up the changes you use Tomcats manager to restart an application. The manager has a HTTP based interface so this can even be done from the commandline.

The above link describes how to do that for Tomcat 7. In Tomcat 8 the syntax for this technique has changed and would look like this (you get the idea):

<Context path="/mycontext" docBase="/myproj/web">
    <Resources>
        <PreResources webAppMount="/WEB-INF/classes" base="/myproj/bin" className="org.apache.catalina.webresources.DirResourceSet"/>
        <PreResources webAppMount="/WEB-INF/classes" base="/myproj2/web" className="org.apache.catalina.webresources.DirResourceSet"/>

        <PreResources webAppMount="/WEB-INF/lib"     base="/myproj/lib" className="org.apache.catalina.webresources.DirResourceSet"/>
        <PreResources webAppMount="/WEB-INF/lib"     base="/myproj2/lib" className="org.apache.catalina.webresources.DirResourceSet"/>
    </Resources>
</Context>          

Upvotes: 2

Related Questions