Tutorials and What's HOT 

Configuring Tomcat 7 to Accept Maven's Structure

by budi kurniawan


Posted on Saturday Jan 09, 2016 at 02:52PM in Java


The most productive way of developing a servlet/JSP app is to structure your app to comply with the Servlet specification. This means creating a WEB-INF directory under your app directory, adding all JAR's to WEB-INF/lib and instructing Eclipse/NetBeans to compile Java sources to WEB-INF/classes. This way, as long as Tomcat's Context reloadable setting is set to true, your app will be reloaded automatically whenever a Java class is updated. No need to rebuild the project and restart Tomcat.

Unfortunately, you are not always free to structure your app. For instance, if your team is using Maven, chances are you will be working with a Maven directory structure. You'll probably have a structure like this:

web-app/
         src/
             main/
                  java/
                  resources/
                  webapp/
                         WEB-INF/
                                 classes/
         target/
                classes/

Not too worry. You can still be productive if you are using Tomcat 7. Simply use its VirtualDirContext implementation of Resource in your Tomcat Context declaration.

Here is an example (you need to declare this in your server.xml file in $TOMCAT_HOME/conf or a Context file)

<Context path="/myapp" docBase="/home/temp/shopping/web" reloadable="true">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <Resources className="org.apache.naming.resources.VirtualDirContext"
        extraResourcePaths="/WEB-INF/classes=/path1/classes,/WEBINF/classes=/path2,/css=/path3"/>
    <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
        virtualClasspath="/home/temp/target/lib/homegrown.jar" />
    <JarScanner scanAllDirectories="true" />
</Context>

You can find more info here.

This will not work with Tomcat 8, though, because Tomcat 8 removed VirtualDirContext. You can, however, use symlinks in Tomcat 8 to enjoy the same benefit.

More on servlet/JSP programming can be found in my book "Servlet & JSP: A Tutorial, 2nd Edition" (ISBN 9781771970273)



Comments:

I simply Appreciate your effort and submit here. Every weekend i used to go to see such type of web info, because i wish to collect something variety in my knowledge. I like this submit an sure will bookmark it for the reason that this this submit genuinely informative material too.

Posted by Reviews of essay writing service on October 03, 2017 at 09:54 AM UTC #


Along these lines, as long as Tomcat's Context reloadable setting is set to genuine, your application will be reloaded naturally at whatever point a Java class is refreshed. No compelling reason to revamp the task and restart Tomcat.

Posted by Essay Service UK on October 25, 2017 at 09:28 AM UTC #


This suggests making a WEB-INF list under your application inventory, adding all JAR's to WEB-INF/lib and preparing Eclipse/NetBeans to arrange Java sources to WEB-INF/classes. Thusly, as long as Tomcat's Context reloadable setting is set to authentic,

Posted by Essay Writing Service on October 25, 2017 at 09:33 AM UTC #


Shockingly, you are not generally allowed to structure your application. For example, if your group is utilizing Maven, odds are you will work with a Maven catalog structure. You'll most likely have a structure this way:

Posted by assignment writing service uk on October 25, 2017 at 09:41 AM UTC #


I really like this site and this shocking post. likewise, We outfit capable help with different unimaginable features that make our work unmistakable from others. Other than papers, we in like route serve on a fundamental level, piece, undertaking, book report or some other educational works. We have creators more than 50 fields put basic essentialness in their differing subjects. a dedication of appreciation is complete to share, keep it up.

Posted by Write my Essay for Me on November 01, 2017 at 05:28 AM UTC #


John arnold is an academic writer of the Dissertation-Guidance. Who writes quality academic papers for students to help them in accomplishing their goals.

Posted by Programming Matlab Help on November 23, 2017 at 06:02 AM UTC #


I loved the way you discuss the topic great work thanks for the share Your informative post.

Posted by Auditing Homework Help on December 02, 2017 at 10:45 AM UTC #


Consistently I used to go to see such sort of web information since I wish to gather something assortment in my insight. I like this present a beyond any doubt will bookmark it for the reason that this submits truly useful material as well.

Posted by Best Essays Writing Service on January 01, 2018 at 05:18 AM UTC #


Expect how tomcat8 works

Posted by alex on January 03, 2018 at 08:39 AM UTC #


This is really great work. Thank you for sharing such a good and useful information here in the blog for students.

Posted by Java Homework on January 13, 2018 at 04:44 AM UTC #


This is really great work. Thank you for sharing such a useful information here in the blog.

Posted by DissertationWriting ServiceUK on January 17, 2018 at 12:12 PM UTC #


Leave a Comment

HTML Syntax: NOT allowed