Problem with java.lang.ClassNotFoundException only when deployed

513 views
Skip to first unread message

Keith

unread,
Sep 18, 2008, 11:40:23 AM9/18/08
to Google Web Toolkit
Hi all,

First off, I am a new user and have built a very simple application.
It works fine under hosted mode. It compiles with no errors. When I
deploy it to the web server and point a browser at it, it throws a
ClassNotFoundException. I suspect this is a really simple problem
(probably caused by a really stupid error). This is driving me crazy
and I would really appreciate ANY help or suggestions anyone could
throw my way.

I have included a lot of error logs, copies of web.xml, directory
structures etc. below.

Trying to work through this is a learning experience, but I am
stumped. The fact that the server is able to sort out the URL sent
from the client enough to know the name of the object is
ca.KeithFuller.server.CorpusServiceImpl suggests to me that the server
is finding the web.xml file, which suggests that it should be able to
find the object since I believe that WEB-INF/classes is always on the
search path. The file CorpusServiceImpl.class is in WEB-INF/classes,
and the corresponding java file starts with:

package ca.KeithFuller.server;

import java.util.*; // for Scanner
import java.io.*; // for println

import ca.KeithFuller.client.CorpusSearchReturns;
import ca.KeithFuller.client.CorpusSearchService;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class CorpusServiceImpl extends RemoteServiceServlet
implements CorpusSearchService
{
...

A whole pile of details follow:

I use GWT 1.4.61

I use Eclipse 3.2.2

My webserver uses Linux, Tomcat and Apache.

I use FireFox 3.0.1 and the URL is http://www.keithfuller.ca:9108/CorpusSearch/CorpusSearch.html

The client code contains:
...
// Create the proxy object
final CorpusSearchServiceAsync serviceProxy =
(CorpusSearchServiceAsync) GWT.create(CorpusSearchService.class);

// Cast the proxy object to ServiceDefTarget
String serviceUrl = GWT.getModuleBaseURL() + "corpus-search";
// if (GWT.isScript()){
// serviceUrl = "/corpus-search";
// }
((ServiceDefTarget)serviceProxy).setServiceEntryPoint(serviceUrl);
...



The localhost.2008-09-18.log file contains:
Sep 18, 2008 10:21:04 AM org.apache.catalina.core.ApplicationContext
log
INFO: Marking servlet corpus-search as unavailable
Sep 18, 2008 10:21:04 AM org.apache.catalina.core.ApplicationContext
log
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@148662
ca.KeithFuller.server.CorpusServiceImpl
java.lang.ClassNotFoundException:
ca.KeithFuller.server.CorpusServiceImpl
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1362)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1208)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:
1068)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:
791)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
127)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
874)
at org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:
528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:
81)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Sep 18, 2008 10:21:04 AM org.apache.catalina.core.StandardWrapperValve
invoke
SEVERE: Allocate exception for servlet corpus-search
java.lang.ClassNotFoundException:
ca.KeithFuller.server.CorpusServiceImpl
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1362)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1208)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:
1068)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:
791)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
127)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
874)
at org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:
528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:
81)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)

The web server has the directory structure:
apache-tomcat-5.5.25/webapps
CorpusSearch
... a pile of html, rpc, js, html, css, and...
web.xml
WEB-INF
classes
CorpusSearch.class
CorpusSearchReturns.class
CorpusSearchServiceAsync.class
CorpusSearchData.class
CorpusSearchService.class
CorpusServiceImpl.class
web.xml
lib
gwt-servlet.jar
web.xml


The dev machine directory structure is:
Eclipse Workspace
.metadata
SearchProject
...
src
ca
KeithFuller
CorpusSearch.gwt.xml
client
CorpusSearch.java
CorpusSearchReturns.java
CorpusSearchServiceAsync.java
CorpusSearchData.java
CorpusSearchService.java
server
CorpusServiceImpl.java
public
CorpusSearch.html
SearchProject.css

The Eclipse Package Explorer shows:
SearchProject
src
ca.KeithFuller
client (a package)
CorpusSearch.java
CorpusSearchReturns.java
CorpusSearchServiceAsync.java
CorpusSearchData.java
CorpusSearchService.java
server (a package)
CorpusServiceImpl.java
public (a folder)
CorpusSearch.html
CorpusSearch.gwt.xml

CorpusSearch.gwt.xml contains:
<module>

<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<!-- Specify the app entry point class. -->
<entry-point class='ca.KeithFuller.client.CorpusSearch'/>

<servlet path="/corpus-search"
class="ca.KeithFuller.server.CorpusServiceImpl"/>

<stylesheet src="SearchProject.css"/>

</module>

web.xml (all of them!) contain:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>

<servlet>
<servlet-name>corpus-search</servlet-name>
<servlet-class>ca.KeithFuller.server.CorpusServiceImpl</servlet-
class>
</servlet>

<servlet-mapping>
<servlet-name>corpus-search</servlet-name>
<!-- <url-pattern>/CorpusSearch</url-pattern> -->
<url-pattern>/corpus-search</url-pattern>
</servlet-mapping>

</web-app>

If you got this far and have any ideas, then please let me know.

Thanks

gregor

unread,
Sep 19, 2008, 7:45:44 AM9/19/08
to Google Web Toolkit
Hi Keith,

Looking at your deployment structure:

The web server has the directory structure:
apache-tomcat-5.5.25/webapps
CorpusSearch
... a pile of html, rpc, js, html, css, and...
web.xml
WEB-INF
classes
CorpusSearch.class
CorpusSearchReturns.class
CorpusSearchServiceAsync.class
CorpusSearchData.class
CorpusSearchService.class
CorpusServiceImpl.class
web.xml
lib
gwt-servlet.jar
web.xml

the package structure ca.KeithFuller.server seems to be missing which
would explain why you get a ClassNotFoundException for
ca.KeithFuller.server.CorpusServiceImpl. I think you should copy the
entire directory structure under WEB-INF\classes.

Also I would recommend you take a little time to make an Ant build
script that creates a WAR file for you application and copies it
straight to your Tomcat deployment directory where it will
automatically redeploy. This will kill problems like this (because Ant
doesn't make mistakes) and save you a lot of time in the long run.
There are lots of examples of how to do this in the group - just
search for ant build WAR.

regards
gregor
> I use FireFox 3.0.1 and the URL ishttp://www.keithfuller.ca:9108/CorpusSearch/CorpusSearch.html

Keith Fuller

unread,
Sep 19, 2008, 12:15:01 PM9/19/08
to Google-We...@googlegroups.com
Hi Gregor,

Yup, that fixed it. Stupid newbie error - fortunately the sort of
error that only gets made once. Now I can start putting back in the
server functionality that I took out to debug it.

Thank you very much for your help,

Keith

--
____________________________________

G. Keith Fuller, Ph.D., P.Eng.

g.keith...@gmail.com
keith....@utoronto.ca

http://www.KeithFuller.ca/
(Due to mail filters outside of my control, mail sent from yahoo or
hotmail accounts may not be delivered to me.)

Reply all
Reply to author
Forward
0 new messages