On the server side of my GWT app I use classes from the org.apache.commons.httpclient
package. These classes are conveniently packaged in gwt-dev.jar
distributed with GWT. I include this jar (along the gwt-servlet.jar
) in the WEB-INF/lib
of the war.
When deploying the produced war file on glassfish and calling the page I get the following exception in the server logs (and an RPC fail)
NoClassDefFoundError: org/apache/commons/httpclient/HttpException
What should I do so that glassfish finds the classes in the gwt-dev.jar
?
-- more details --
As an SSCCE which reproduces the problem, I have modified class GreetingServiceImpl of the GWT example:
import org.apache.commons.httpclient.HttpException;
public String greetServer(String input) throws IllegalArgumentException {
try {
if(input.equals("hello")){
throw new HttpException();
}
} catch (HttpException e) {
throw new RuntimeException(e);
}
... the rest of the GWT example app
Here's the content of the war
> jar -tf mytest.war
META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/com/
WEB-INF/classes/com/mytest/
WEB-INF/classes/com/mytest/client/
WEB-INF/classes/com/mytest/server/
WEB-INF/classes/com/mytest/shared/
WEB-INF/lib/
mytest/
mytest/gwt/
mytest/gwt/standard/
mytest/gwt/standard/images/
mytest/gwt/standard/images/ie6/
MyTest.css
MyTest.html
WEB-INF/classes/com/mytest/MyTest.gwt.xml
WEB-INF/classes/com/mytest/client/GreetingService.class
WEB-INF/classes/com/mytest/client/GreetingServiceAsync.cla
WEB-INF/classes/com/mytest/client/MyTest$1.class
WEB-INF/classes/com/mytest/client/MyTest$1MyHandler$1.clas
WEB-INF/classes/com/mytest/client/MyTest$1MyHandler.class
WEB-INF/classes/com/mytest/client/MyTest.class
WEB-INF/classes/com/mytest/server/GreetingServiceImpl.clas
WEB-INF/classes/com/mytest/shared/FieldVerifier.class
WEB-INF/lib/gwt-dev.jar
WEB-INF/lib/gwt-servlet.jar
WEB-INF/web.xml
mytest/0A9476898799A150D840F0B1C3672921.cache.png
mytest/2E5321B05D040C654474157464A1320D.cache.html
mytest/342DCE11554A2ED2AAE7C85966745477.cache.html
mytest/396F806CD63ABD414BFBB9D57429F05B.cache.png
mytest/505B1AEFC510FA6C8E519C08BD073CE0.cache.html
mytest/8C8B81BFBAD2494F16B95F537039AC9C.gwt.rpc
mytest/B33A642CF9F25C17BB1B43D744B059AE.cache.html
mytest/C8061F2305971473D1402197D362AAFE.cache.html
mytest/DF7764EEC1903CD03C9545B354D8D8E4.cache.png
mytest/E224554766C17094274FFD5F9B5E2DCC.cache.html
mytest/E44767377485D18D6B6864F65BA8EF73.cache.png
mytest/EDC7827FEEA59EE44AD790B1C6430C45.cache.png
mytest/clear.cache.gif
mytest/gwt/standard/images/corner.png
mytest/gwt/standard/images/corner_ie6.png
mytest/gwt/standard/images/hborder.png
mytest/gwt/standard/images/hborder_ie6.png
mytest/gwt/standard/images/ie6/corner_dialog_topleft.png
mytest/gwt/standard/images/ie6/corner_dialog_topright.png
mytest/gwt/standard/images/ie6/hborder_blue_shadow.png
mytest/gwt/standard/images/ie6/hborder_gray_shadow.png
mytest/gwt/standard/images/ie6/vborder_blue_shadow.png
mytest/gwt/standard/images/ie6/vborder_gray_shadow.png
mytest/gwt/standard/images/splitPanelThumb.png
mytest/gwt/standard/images/vborder.png
mytest/gwt/standard/images/vborder_ie6.png
mytest/gwt/standard/standard.css
mytest/gwt/standard/standard_rtl.css
mytest/hosted.html
mytest/mytest.nocache.js
And the full exception stacktrace
PWC1382: Allocate exception for servlet greetServlet java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpException at
java.lang.Class.getDeclaredConstructors0(Native Method) at
java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at
java.lang.Class.getConstructor0(Class.java:2699) at
java.lang.Class.newInstance0(Class.java:326) at
java.lang.Class.newInstance(Class.java:308) at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1132) at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:832) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272) at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637) at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568) at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813) at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341) at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263) at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214) at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) at
com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Content of gwt-dev.jar, (total of 11000 classes and packages)
> jar -tf gwt-dev.jar
META-INF/MANIFEST.MF
LICENSE.txt
META-INF/
META-INF/LICENSE
...
com/gargoylesoftware/htmlunit/...
com/google/gwt/core/...
com/google/gwt/dev/...
com/steadystate/css/...
java_cup/runtime/...
javax/management/...
javax/servlet/...
javax/xml/...
mx4j/...
net/sourceforge/htmlunit/...
org/apache/bcel/...
org/apache/catalina/...
org/apache/commons/...
org/apache/commons/httpclient/
...
org/apache/commons/httpclient/HttpContentTooLargeException.class
org/apache/commons/httpclient/HttpException.class
org/apache/commons/httpclient/HttpHost.class
...
org/apache/coyote/...
org/apache/html/...
org/apache/jasper/...
org/apache/tomcat/...
etc...