Skip to content
JackSparrow414
Go back

A Painful Web Project Deployment on a Mac

Table of contents

Open Table of contents

Article body

Environment: Mac + Eclipse + Tomcat 7 + JDK 7

The painful process:

After downloading Eclipse and installing the SVN plugin, I checked out the project from our company repository. Then the problems began.

Problem 1: the project was covered in ❌ markers. This is a familiar issue: configure the JDK and web versions under Project Facets.

Problem 2: after step 1, I still got a “the type of javax.servlet” error. Another familiar issue: add servlet.jar from Tomcat’s lib directory through Build Path → Add External JARs. The project then compiled successfully.

Problem 3: on my Mac, startup failed with “can’t assign requested address,” which I had never encountered on Windows. I spent a long time searching online, and the suggestions all said to disable IPv6 on the Mac. But what if I needed to enable it again? I looked up how to do that, found it cumbersome, and abandoned the idea. The eventual solution was simple: add -Djava.net.preferIPv4Stack=true to the JVM options. Thanks to this contributor for sharing.

Problem 4: Tomcat’s default startup timeout is 45, which is rather short. Increase it by double-clicking the server and changing the timeout setting on the right.

Problem 5: starting Tomcat produced a PermGen space exception. This is another familiar issue, so I will keep it brief: configure the JVM options. You can use this reference

Tip: before compiling the project, set the Java compiler version under Java Compiler in Eclipse or MyEclipse to match the Java version you have configured.

Problem 6: here comes the most frustrating one. If you have the same issue, read on. After deploying the project to Tomcat and starting it, I got a long list of missing-JAR errors, even though all the JARs had been added. Most answers online recommended configuring Deployment Assembly. I tried that too, but it led to this strange result:Tomcat deployment list containing two versions of the spring-web JAR

Before configuring Deployment Assembly, there was only one Spring-web-4.0.0.RELEASE.jar here. After configuring it, there were two. In about 90% of the answers I found online, configuring Deployment Assembly left only one JAR and the project ran normally.

At this point, starting the project from Eclipse produced no errors. However, shortly after Tomcat successfully published the project, it published another identical copy, and another spring-web-4.0.0.RELEASE.jar appeared under the server. Soon after that deployment succeeded, Tomcat published it again. If I left Tomcat running, it stayed in an endless deployment loop, accumulating more copies of the same JAR.

I searched online for days without finding a solution. Today, while looking through posts around the time I finished work, I finally found one that solved it.

First, many thanks for this blog post. The solution is to open server.xml under Servers on the left in Eclipse and set reloadable to false on the inside .

The project finally ran normally.

Thanks to all the bloggers whose posts helped me along the way.

To learn about the difference between Build Path and Deployment Assembly, see this blogger’s post. Thank you.

Note: the project now runs correctly in Eclipse, but I still have the same problem in MyEclipse 2017 and IntelliJ IDEA. In MyEclipse 2017, after following the steps above except for the XML change, starting Tomcat reports that it cannot find the WebXmlapplicationContext class. I suspect Deployment Assembly still creates multiple JAR copies, resulting in multiple containers and an error. I have not found a solution yet.

An unresolved question:

The local Tomcat server.xml has no Context under Host, but the Tomcat server.xml in Eclipse does. I have not figured out why. I am recording this here and will add an explanation once I understand it.


Share this post:

Previous Post
Installing and Using Docker (Part 1)
Next Post
Using jQuery zTree

Comments

Questions, corrections, and experiences are welcome. Sign in with GitHub to comment; both language versions share this discussion.

Comments are available on the live site only.