Why doesn't IDEA use reloadable Contexts for Tomcat integration?

I tried the Tomcat server support by creating a Local Tomcat Server in the App Servers configuration dialog (I use Tomcat 4.1.30).

I noticed that while changes to my JSPs were immediately reflected in the running Tomcat instance, the same was not happening with any of the Java classes I modified (I rebuilt the project in both cases).

I went to the local base directory that IDEA uses for creating the modified server.xml etc. (on my machine it's c:\Documents and Settings\Ivan\.IntelliJIdea\system\tomcat_Tomcat_40cd5fc9)
and looking at server.xml I found this Context definition corresponding to my project:

]]>

As you can see, IDEA doesn't add the parameter reloadable=true to the Context tag, which is strange because this parameter's sole purpose is to aid in rapid development, by not having to restart Tomcat each time you make a change in some class.

Is there an option I have missed somewhere, or any undocumented way of enabling this? I would settle even for a global Tomcat config option that would make all Contexts reloadable by default.

P.S.
I know there is a way to reload running Tomcat applications via the /manager webapp, but it's just as annoying as restarting it. If the 'reloadable' attribute is not suitable for some reason, couldn't IDEA atleast automatically inform Tomcat to reload the webapp after recompiling it (via some /manager/blah/blah URL, or something)?

7 comments

In my IDEA (4.5.1) it asks if you want to redeploy the module when I compile the module. The pushes out the new classes.

0

That's not my point. IDEA does redeploy them, but Tomcat does not pick up the changes without restarting it completely, which is annoying, and also destroys any session state maintained by the webapp. If your webapp requires you to e.g. login or maintains some other session state, you need to repeat all those steps to recreate what you were doing.

0

Ivan Todoroski wrote:

That's not my point. IDEA does redeploy them, but Tomcat does not pick up the changes without restarting it completely, which is annoying, and also destroys any session state maintained by the webapp. If your webapp requires you to e.g. login or maintains some other session state, you need to repeat all those steps to recreate what you were doing.

Some users use debug plus hot swap for this instead of run. Let JVM do
all the stuff.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Hot swapping is severly limited. It works only for minor changes to code in method bodies, but fails miserably when you add/remove/rename methods in your classes.

Furthermore, hot swapping requires you to have Tomcat already running under a debugger, which slows things down quite a bit, depending on your webapp.

Many times you don't need the overhead of debugging, you just want to make some changes and immediately see the final results in the webapp. The debugger only comes into play when you encounter some nasty bug and you need to singlestep through your code to find it.

Automatic context reloading, as supported by Tomcat, works in all cases, you can change your classes how ever you want and it will pick them up, as it fully reloads the whole webapp. It also doesn't require a debugger to be attached.

The Tomcat developers didn't spend their effort to create this feature for nothing, it is there for a reason - it really saves developers time and nerves.

It's a real shame that IDEA doesn't support this simplest of features, when you obviously went to great trouble to implement much more complex features in order to increase developer comfort.

It would be trivial to provide a user-definable template for the tag instead of the current hard-coded one, and then just override the 'docBase', 'path' and 'work' attributes to point to the temporary directories that IDEA creates. This is the tag I use for my web application development outside of IDEA:                    ]]>


The 'reloadable' flag above combined with the persistent session manager allows for trully transparent modification of both JSPs and classes/jars without ever having to restart Tomcat.

If there was any way to specify this flag outside of the ]]> tag, I wouldn't even bother you, but so far I haven't found a way.

0

Hi,
IDEA DOES use your config files so if you have one (say Root.xml in
%TomcatInstall%\conf\catalina) in your base directory, setup
reloadable=true in this file, specify / as application context for some
module (other context name like /SomeName provides mapping to
SomeName.xml). IDEA will pickup the file you provided and modify docBase
and path.

Ivan Todoroski wrote:

Hot swapping is severly limited. It works only for minor changes to code in method bodies, but fails miserably when you add/remove/rename methods in your classes.

Furthermore, hot swapping requires you to have Tomcat already running under a debugger, which slows things down quite a bit, depending on your webapp.

Many times you don't need the overhead of debugging, you just want to make some changes and immediately see the final results in the webapp. The debugger only comes into play when you encounter some nasty bug and you need to singlestep through your code to find it.

Automatic context reloading, as supported by Tomcat, works in all cases, you can change your classes how ever you want and it will pick them up, as it fully reloads the whole webapp. It also doesn't require a debugger to be attached.

The Tomcat developers didn't spend their effort to create this feature for nothing, it is there for a reason - it really saves developers time and nerves.

It's a real shame that IDEA doesn't support this simplest of features, when you obviously went to great trouble to implement much more complex features in order to increase developer comfort.

It would be trivial to provide a user-definable template for the <Context> tag instead of the current hard-coded one, and then just override the 'docBase', 'path' and 'work' attributes to point to the temporary directories that IDEA creates.

This is the <Context> tag I use for my web application development outside of IDEA:

<Context docBase="..." path="..." reloadable="true" backgroundProcessorDelay="1">
    <Manager className="org.apache.catalina.session.PersistentManager">
        <Store className="org.apache.catalina.session.FileStore"/>
    </Manager>
</Context>


The 'reloadable' flag above combined with the persistent session manager allows for trully transparent modification of both JSPs and classes/jars without ever having to restart Tomcat.

If there was any way to specify this flag outside of the <Context> tag, I wouldn't even bother you, but so far I haven't found a way.



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Hope this isn't a hijacking here, but...

How do you use conf\Catalina? When I set the config path to conf\Catalina\localhost IDEA gives an error that the server.xml can't be found. I don't suppose I'm supposed to copy it to the dir. Also, and this is probably solved once I get the first part working, I notice that it doesn't list the available webapps as it does if I have the contexts added to the server.xml directly.

0

Hi,
Use base dir = dir that contain conf

Cary Beuershausen wrote:

Hope this isn't a hijacking here, but...

How do you use conf\Catalina? When I set the config path to conf\Catalina\localhost IDEA gives an error that the server.xml can't be found. I don't suppose I'm supposed to copy it to the dir. Also, and this is probably solved once I get the first part working, I notice that it doesn't list the available webapps as it does if I have the contexts added to the server.xml directly.



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Please sign in to leave a comment.