問題はいくつかのエラーメッセージが間違っているようです。TomEEとEclipse(IllegalArgumentException)を使用して簡単なJAX-RSサービスを公開することはできません
私は、これは、このアプリ
package study;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath(value="/jaxrs")
public class JaxRSApplication extends Application{
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> set = new HashSet<>();
set.add(NotSingletonResource.class);
return set ;
}
//
// @Override
// public Set<Object> getSingletons() {
// Set<Object> set = new HashSet<>();
// set.add(new SingletonResource());
// return set ;
// }
}
発行元
package study;
import java.io.IOException;
import java.net.InetSocketAddress;
import javax.ws.rs.ext.RuntimeDelegate;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class StandaloneJaxRsServer {
public static void main(String[] args) throws IOException {
HttpServer server = HttpServer.create(new InetSocketAddress(
"localhost", 8765), 8);
HttpHandler requestHandler = RuntimeDelegate.getInstance()
.createEndpoint(new JaxRSApplication(), HttpHandler.class); //<<<<< line 15
server.createContext("/jaxrs/", requestHandler);
server.start();
}
}
であるEclipseの動的なWebアプリケーションプロジェクトを作成し、ランタイムがTomEE + 1.7.2で
ましたこれはリソースです
package study;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/notSingletonResource")
public class NotSingletonResource {
private volatile int counter = 0;
@GET
@Produces({MediaType.TEXT_HTML})
public String getHello() {
return "Not singleton resource " + counter++;
}
}
は私が私がしかし
Exception in thread "main" java.lang.IllegalArgumentException
at org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl.createEndpoint(RuntimeDelegateImpl.java:104)
at study.StandaloneJaxRsServer.main(StandaloneJaxRsServer.java:15)
を取得)StandaloneJaxRsServer.mainを(実行しようとすると、IllegalArgumentExceptionがあまりわかりません。私は間違って何をしていますか?