Search code examples
javaeclipseclasspathweb.xmleclipse-juno

Switched to Eclipse Juno and Filter class not found


I'm trying to get a project running in the server in Springsource Tool Suite (based on Eclipse Juno.) It used to run in an earlier version of Eclipse. It's a maven project, and it builds fine from the command line.

The problem I'm seeing right now is that it can't find a filter class referenced in web.xml though in the previous release of Eclipse, it had no problem finding this class. The web.xml filter clause looks like this:

<filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>com.foo.bar.dao.hibernate.HibernateSessionFilter</filter-class>
    <init-param>
        <param-name>sessionFactoryBeanName</param-name>
        <param-value>sessionFactory</param-value>
    </init-param>
</filter>

When I try to run it in the internal Tomcat 6 server, I get the following error:

SEVERE: Exception starting filter hibernateFilter
java.lang.ClassNotFoundException: com.foo.bar.dao.hibernate.HibernateSessionFilter

When I run jar tf app.war | grep HibernateSessionFilter the class is there in the war file:

$ jar tf imagewar.war | grep HibernateSessionFilter
WEB-INF/classes/com/foo/bar/dao/hibernate/HibernateSessionFilter.class

Perhaps it doesn't belong in WEB-INF/classes?

As I said, this app used to build and run in the internal server. What do I need to do with Juno to tell it where my app's classes are?


Solution

  • If you deploy through Eclipse, you should check if Eclipse deployed your application correctly - Eclipse does not deploy using a WAR file, rather it copies right into the appservers webapp location the necessary files.

    Sometimes though Eclipse messes up with this - there are known bugs of WTP for deployment.

    You should check the .metadata/.plugins/org.eclipse.wst.server.core- folder and its subfolders (each subfolder represents a registered server instance).

    Sometimes you need to completeley erase the deployment in webapps and redeploy in Eclipse. It's magic but it works.

    The one thing you should NOT check: your WAR file: Eclipse does not deploy from the WAR file. Please check the deployed classes first.

    And a last hint: If you are using m2e for Maven, you should install the m2e-wtp plugin for WTP support.