我创建了一个最近使用wicket REST functionality升级的Wicket应用程序。在开发它并通过Jetty运行时,我能够正确地将消息发布到REST服务。但是,当它部署到tomcat时,转到REST URL会出现404错误,并且“请求的资源不可用”'响应。
Pom条目: wicketstuff-annotation,wicketstuff-restannotations,wicketstuff-restannotations-json(所有jar / compile,版本与wicket版本6.24.0相同)
其余课程中的代码
public class Webhook extends AbstractRestResource<JsonWebSerialDeserial> {
@MethodMapping(value="/notification", httpMethod=HttpMethod.POST, consumes= RestMimeTypes.APPLICATION_JSON, produces = RestMimeTypes.TEXT_PLAIN)
public String notification( @RequestBody Notification data ) {
// do some things
return "received successfully";
}
@Override
public String getMountPath() {
return "/emailcampaign/webhook";
}
}
REST类在WicketApplication中初始化:
public void init() {
final Webhook hook = new Webhook();
mountResource( hook.getMountPath(), new ResourceReference( hook.getClass().getSimpleName() ) {
private static final long serialVersionUID = 1L;
public IResource getResource() {
return hook;
}
});
}
tomcat localhost_access_logs有这个:
`XX.XX.XX.XX - - [01 / Feb / 2018:06:46:10 +0000]&#34; POST / emailcampaign / webhook / notification HTTP / 1.1&#34; 404 1041
系统启动正常,因此我似乎在部署时似乎缺少任何jar文件,所以我不知所措。有人可以帮忙吗?
Tomcat 7.0.67,Jetty 7.6.3,Wicket 6.24,Spring 4.1.4
编辑:这是web.xml的内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>system-ui</display-name>
<context-param>
<param-name>configuration</param-name>
<param-value>deployment</param-value>
</context-param>
<filter>
<filter-name>wicket.system-ui</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.sw.system.ui.WicketApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wicket.system-ui</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
答案 0 :(得分:1)
.... aaand这是一个新秀的疏忽。
在我的开发机器上,jetty上应用程序的路径是http://localhost:8080。在部署计算机上,它是http://[server_name]/theapp。所以我将客户端REST URL设置为指向http://[server_name]/theapp/emailcampaign/webhook/notification(即添加theapp子路径)并且它有效!
Doh但希望它可以帮助其他人。