Two Laptop Bag
The moose likes JForum and the fly likes Developing with Eclipse and Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Developing with Eclipse and Tomcat" Watch "Developing with Eclipse and Tomcat" New topic

Developing with Eclipse and Tomcat

Migrated From
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi everybody,
I downloaded the source code of jforum 2.1.8 and now I have to modify some issue of it.
I need to integrate jforum on Eclipse and then, from Eclipse, launch jforum to test my modify. Actually I imported the jforum source on Eclipse, but this is a normal eclipse project and not a web dynamic project in this way I do not know how launch jforum on tomcat from eclipse.
Could someone tell me how I can launch jforum on tomcat from eclipse?
Thanks, bye bye.
[originally posted on by abdujaparov]
Migrated From
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I do this by having Eclipse compile classes to the WEB-INF/classes directory in the jForum project. Then
using a Tomcat context file in the config/Catalina/localhost directory. Just name the same as the context URL you want (e.g. jforum.xml) and have something like:

FYI - docBase points to your jforum project directory (assuming you just imported the source directly in to it). Calls to /jforum will use this as the app root (instead of assuming a directory under the webapp dir.)

Also, the reloadable option will cause TC to monitor for changes to many of the class files and automatically restart the web app if they change. Just note that some classes may not trigger this. You may have to do a manual stop / start to reload the new code. (TC's service monitor works fine for this).

For extra credit you can combine this with some of the Eclipse tools that can run TC "inside" Eclipse.
[originally posted on by monroe]
Migrated From
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
There is a way to convert JForum into a Dynamic Web Project. It involves manually adding additional <natures> to the .project file which allows the necessary facet configuration on the project's property page. Unfortunately though, JForum's directory setup is not entirely compatible with Eclipse's Dynamic Web Project support. The configuration of the docBase requires all deployment files to live in a sub-directory of the .project folder (default is "/WebContent"). In JForum, they're located at the project root level. Unless, you restructure the project layout this approach won't work.

Here's a more basic approach:

- After importing the .project into the workspace, add a new Server (right click in the Servers panel -> "New" -> "Server").
- Choose "Apache/Tomcat v6.0"
- If this is the first server you add, you will have to specify the installation path of an existing Tomcat installation. I would suggest to go with the offered "Download and Install..." of 6.0.14, since the latest version has slight compatibility issues. As a side benefit, it's a non-install, stand-alone version, which is only executed as needed.
- Next, right-click the newly created server and choose "Open".
- Select "Serve modules without publishing".
- Switch to the "Modules" screen (tab at the bottom of the window).
- Click "Add External Web Module...".
- Enter your JForum source location as the Document Base. Additionally, I use "/JForum" for the Path.
- Hit "OK" and save the Tomcat Configuration.
- Done!

This way, the Tomcat configuration is handled directly by Eclipse on a per-project basis and does not affect your global Tomcat setup. This makes working with Tomcat when switching projects and workspaces more straightforward, especially if you're dealing with multiple branches.

Now, you're done. You can start the server directly from the Servers panel in various modes. If you run it in debug with breakpoints set, you may be asked to add your source path for the debugger to work.


[originally posted on by drematic]
I agree. Here's the link:
subject: Developing with Eclipse and Tomcat
It's not a secret anymore!