【发布时间】:2017-07-29 16:44:28
【问题描述】:
一段时间以来,我一直在阅读关于 SO 的主题,但我无法确定这是 WildFly 部署问题还是 RESTEASY 问题。任何帮助,将不胜感激。
当我尝试访问时:http://localhost:8080/HelloWorld-1.0-SNAPSHOT/json/hi
错误信息:
12:27:04,159 错误 [org.jboss.resteasy.resteasy_jaxrs.i18n](默认任务 1)RESTEASY002010:执行失败:javax.ws.rs.NotFoundException:RESTEASY003210:找不到完整路径的资源: http://localhost:8080/HelloWorld-1.0-SNAPSHOT/json/hi
JAXActivator.java
package com.sentiment360.helloworld;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/")
public class JAXActivator extends Application {
}
web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>hello</display-name>
</web-app>
index.html
<!DOCTYPE html>
<html>
<head>
<title>Start Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Hello World WOO!</h1>
</body>
</html>
HelloWorld.java
package com.sentiment360.helloworld;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
public class HelloWorld {
//@Inject
//HelloService helloService;
@GET
@Path("/json/{p}")
@Produces({ "application/json" })
public String getHelloWorldJSON(@PathParam("p") String param) {
return "{\"result\":\"" + param + "\"}";
//return "{\"result\":\"" + helloService.createHelloMessage(param) + "\"}";
}
@GET
@Path("/xml/{p}")
@Produces({ "application/xml" })
public String getHelloWorldXML(@PathParam("p") String param) {
return "<xml><result>" +param+ "</result></xml>";
//return "<xml><result>" + helloService.createHelloMessage(param) + "</result></xml>";
}
}
WildFly 服务器命令
1号航站楼:
/etc/opt/wildfly-10.0.0.Final/bin/standalone.sh
2号航站楼:
/etc/opt/wildfly-10.0.0.Final/bin/jboss-cli.sh --connect --command="deploy --force /home/king/NetBeansProjects/HelloWorld/target/HelloWorld-1.0-SNAPSHOT.war"
【问题讨论】:
标签: java xml jboss wildfly wildfly-10