15

When trying to launch a Web project from within Eclipse I get:


SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3877)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Project started to fail when I switched to Fedora 12 x64. The project worked on WinXP with same configuration.

Googling around I found posts claiming that going to Project Properties -> Java EE Module Dependencies and checking the Maven Dependencies box fixes the issue. Sadly it didn't worked for me.

I'm using Spring 2.5.6, Maven2, Eclipse 3.5 (with the m2e 0.10.0 plugin), Tomcat 6 and Java 6 running on Fedora 12 x64.

Has anyone seen this problem?

In case it helps here is my .classpath file


<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    <classpathentry kind="src" output="target/classes" path="target/generated-sources/gpb"/>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>

    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>

    <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.iam.jdt.core.mavenClasspathContainer">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>

Update: I don't have any problems building or running the project outside Eclipse.

1
  • Just a guess: could it be becuase org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER and org.eclipse.iam.jdt.core.mavenClasspathContainer conflict in some way? Apr 7, 2010 at 19:42

4 Answers 4

18

You seem to have both Eclipse IAM and M2Eclipse stuff in your .classpath. I would do some cleanup:

  • Use only one of these plugin (I suggest using M2Eclipse).
  • Delete your project from Eclipse's workspace, delete the .classpath and .project and Import the project as a Maven project again.

Update: To get WTP support with M2Eclipse, you need to install the Maven Integration for WTP from the m2eclipse Extras update site: http://download.eclipse.org/m2e-wtp/releases/ as illustrated below:

enter image description here

7
  • @pascalthivent, It seems that I was using Eclipse IAM before the switch without noticing. Anyway, did what you suggested, but now the project is not seen by Eclipse like a Web App. So now I don't even have the Run As -> Run on Server option. Apr 7, 2010 at 21:00
  • @Elliot That's because you didn't install the Maven Integration for WTP when you installed M2Eclipse. I'll update my answer to cover this. Apr 7, 2010 at 21:50
  • Thanks Pascal, that last info solved my problem. I removed the project, installed the integration for WTP and imported the project again. Only detail was that I had to disable the Maven plugin, build the project in a terminal and then enable the plugin again. Everything is working smoothly now. One thought, it seems to me that Eclipse is really lagging behind NetBeans on Maven support. I feel more productive in Eclipse, but cannot afford to lose time with things like this in my workplace. I think Eclipse's image is tarnished by the current state of the Maven plugins. Apr 8, 2010 at 14:13
  • @Elliot Glad it's solved. I can understand your perception after a problem like this one even if it was more a user issue at the end (if I may). Personally, I find that Eclipse has very decent Maven support with M2Eclipse now, but feedback from others is always interesting. Apr 8, 2010 at 15:17
  • @Pascal The m2eclipse docs could at least have a note saying "if you are planning on using WTP you better install the WTP integration from the extras repo". This means the first time I setup this project on WinXP I got it right by sheer luck. Which is really bad because I was fooled into thinking I mastered Maven projects in Eclipse (as you could see I didn't). Now if it weren't for SO I would have to decide between spending more time solving the issue or moving to NetBeans where my co-workers haven't had a problem yet. Guess what would have won.. Thanks for your help and SO rocks!. Apr 8, 2010 at 19:53
9

I had the same symptom with a different cause. I had to edit my .classpath file. The maven entry:

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
</classpathentry>

...was lacking the attributes tag shown here. When I added the attributes tag the problem went away. I'm very curious how to configure that in the eclipse ui.

2
  • yep... that definitively changed the error message so something application related... I guess it was a move in the right direction
    – Newtopian
    Oct 27, 2011 at 6:57
  • 1
    ah thank you this worked for me, just added <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> and its ok now
    – tomasb
    Jul 19, 2012 at 11:33
4

Note that the steps to install the WTP integration have changed.

See: Maven/Tomcat Projects In Eclipse Indigo/3.7

1

From time to time, face with same problem.

For some strange reason, this problem could be fixed this way

1) Right mouse click on project Maven -> Disable Maven Dependencies

2) Right mouse click on project Maven -> Enable Maven Dependencies

1
  • 1
    I do not have such options in Eclipse 3.7.2, did you mean Disable Maven Nature?
    – Betlista
    May 23, 2012 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.