eclipsetomcatstrutsmetadata

Could not find or load main class in both Tomcat and Workspace


I've been tasked with adding some new features in a project I worked on a while back. It's been given some new features since I last worked on it, and the development environment has changed. I'm having a lot of troubles bringing my environment up to date with all the dependencies and external folders.

After solving a host of problems, when running the Tomcat 7 Server in Eclipse I was coming across a message:

Error: Could not find or load main class Path\To\Workspace\.metadata\plugins\cont

I tried deleted the Tomcat Server and then recreating it with the same settings, as well as deleting my .metadata folder from the workspace. Now I can't even get Tomcat to configure right:

Error: Could not find or load main class Files\ApacheSoftwareFoundation\apache-tomcat-7.0.26.

Why isn't this working? It worked before I added a couple of needed subdirectories but I'm stumped now.


Solution

  • Just was searching for the same problem in Eclipse("Could not find or load main class").

    It turned out in my case that there was an extra space in launch configuration arguments tab. (In Java EE perspective go to Servers, click on Tomcat server, in Overview window select 'Open launch configuration' and then go to Arguments tab). Arguments are listed as

    -Dx.y.z=1 -Da.b.c=2 ...
    

    and so on, but as the dialog itself is small and arguments go across multiple lines it's not always clear where there is a space and where there is a new line. In my case it was

    -Dx.y.z =1 -Da.b.c=2 ...
    

    (there is a space before =1) which confused Tomcat and I got "Could not find or load main class" error.

    It's not necessarily your case but somebody else can come across this and find it to be the answer.