在我的GWT应用程序的服务器端,我使用org.apache.commons.httpclient
包中的类。这些类可以方便地打包在与GWT一起分发的gwt-dev.jar
中。我在战争的gwt-servlet.jar
中包含了这个罐子(沿WEB-INF/lib
)。
在glassfish上部署生成的war文件并调用页面时,我在服务器日志中得到以下异常(并且RPC失败)
NoClassDefFoundError: org/apache/commons/httpclient/HttpException
我该怎么做才能让glassfish找到gwt-dev.jar
中的类?
- 更多细节 -
作为再现问题的SSCCE,我修改了GWT示例的类GreetingServiceImpl:
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
这是战争的内容
> 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
完整的异常堆栈跟踪
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)
gwt-dev.jar的内容,(总共11000个类和包)
> 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...
答案 0 :(得分:0)
您应该将 commons-httpclient.jar (或httpclient-4.0.1.jar - 取决于发行版)添加到“ WEB-INF / lib目录”
您可以从here
下载