【发布时间】:2013-06-15 09:05:20
【问题描述】:
我已将我的 GWT 应用程序组装为我在嵌入式 Jetty 中运行的 war 文件-
String confFile = System.getProperty("configFilename");
config = new XMLConfiguration(configFilename);
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext();
webapp.setAttribute("config", config);
webapp.setContextPath("/");
webapp.setWar("file.war");
server.setHandler(webapp);
server.start();
server.join();
我正在尝试在 GWT 服务器端代码中访问我的“配置”对象-
public class MyServiceImpl extends RemoteServiceServlet implements
MyService {
config = (XMLConfiguration) this.getThreadLocalRequest().getAttribute("config");
}
在这里,config 始终为空。
我做错了什么?我试过config =(XMLConfiguration) this.getServletContext().getAttribute("config"); 但这也不起作用 - 我收到错误 -
org.apache.commons.configuration.XMLConfiguration cannot be cast to org.apache.commons.configuration.XMLConfiguration
【问题讨论】:
-
该错误告诉我,您必须将 XMLConfiguration 类放在 2 个单独的 jar 中。一个可能部署为 Jetty 的一部分,另一个部署为您的应用程序的一部分。
-
@LavieTobey - 这是正确的
-
你在使用 maven 进行依赖管理吗?
-
尝试专门导入该 jar 并将其标记为已提供,看看该演员是否有效。
-
刚试过-没用:(同样的错误
标签: java gwt servlets jetty embedded-jetty