1

I realize there are similar questions out there, but I am at a loss. I have a maven, JSF2 webapp that no-matter-what will not run on Tomcat from within Eclipse. I've tried the "Deployment Assembly" trick and the "build path trick" as many have mentioned, but neither works.

I am confident it does not have to do with the output in C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps. This directory mimics what is deployed when I deploy a war to the same tomcat instance including all property files, xhtml files, and libs. The only exception is that my war includes .class files whereas the source .java files are in wtpwebapps. Deploying directly to tomcat works correctly - all servlets found and loaded.

Before I get answers on JSF2 installation, it isn't that... I am getting errors when Tomcat tries to load up my custom servlets. For example:

Sep 21, 2012 10:16:27 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /webapp threw load() exception
java.lang.ClassNotFoundException: com.webapp.ui.Log4JInitServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
    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.StandardWrapper.loadServlet(StandardWrapper.java:1136)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
    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:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

In the above stack, the class Log4JInitServlet is found in ...\wtpwebapps\webapp\WEB-INF\classes\com\webapp\ui\Log4JInitServlet.java

Some specifics:

  • Eclipse Juno
  • Eclipse WTP 3.4.0 with the "WTP Patches for org.eclipse.jst.web_core.feature"
  • Maven 3.0.3
  • Tomcat 7.0.29
  • JSF - MyFaces 2.1.5
  • JDK - 1.7.0_05

As a final FYI, I've tried older versions of Eclipse as well as older versions of Tomcat (going back to 6).

Community
  • 1
  • 1
Domenic D.
  • 5,276
  • 4
  • 30
  • 41

1 Answers1

1

You should not have a .java file in WEB-INF/classes; that's where compiled byte code in .class files goes.

Your Eclipse project should have .java source files in a /src directory. You then ask it to write your compiled .class files to either an exploded or packaged WAR file and its WEB-INF/classes folder.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • Very interesting... I found that the issue was that a jar (of mine) that I depended on I had set to provided as it is meant to be in the servers' /lib folder (it supports JAAS login). Once I reverted my code to an earlier version where scope was "compile" it all worked again. Since after doing this, it generated .class files in the wtpwebapps folder as opposed to .java files, you get the points for answering correctly. Go figure. Thanks for the help. – Domenic D. Sep 21 '12 at 15:58