Ido Barash
Ido Barash

Reputation: 5142

Eclipse + tomcat - ClassNotFound exception on deploy

I am facing a weird problem with eclipse.

I have a multi-module maven project with CXF, hibernate and spring. If I take the war produced after maven package, and deploy it manually on tomcat 7 - everything works fine. But if I am trying to work with eclipse (Servers -> tomcat) I get the following error:

    SEVERE: Exception starting filter datasourceFilter
java.lang.ClassNotFoundException: com.X.X.X.X.filter.DataSourceFilter
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:256)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

It is worth mentioning that the tomcat which I am trying to integrate with eclipse is the same stand alone tomcat, I deployed the war on manualy. I use eclipse Juno.. if it matters..

on my web.xml:

<filter>
        <filter-name>datasourceFilter</filter-name>
        <filter-class>com.X.X.X.X.filter.DataSourceFilter</filter-class>
    </filter>
        <filter-mapping>
        <filter-name>datasourceFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Can anyone help me?

Idob

Upvotes: 2

Views: 12586

Answers (1)

betomontejo
betomontejo

Reputation: 1675

If you have installed both the Maven Eclipse Plugin and the Maven WTP Plugin this is automatic. If you don't have these installed, go ahead and install them and then once Eclipse restarts right-click on the project and do a Maven > Update project.... This will internally change the project configuration so the Maven dependencies are copied to the /WEB-INF/lib folder on your deployment target.

If you don't want to use any of these plug-ins, then you have to go to the Project properties > Deployment Assembly configuration and add your dependencies manually, but again, this is done automatically by these plug-ins.

Upvotes: 4

Related Questions