HTTP 500 Erreur Interne de Servlet中的异常

时间:2019-06-15 10:31:06

标签: java rest jersey jax-rs

我想调用Web服务rest的方法(我正在使用Jersey。) 我正在使用服务器apache tomcat。 这是“ ListenerImp”类的方法:

package cuWasteCollection;

import java.io.IOException;

import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.osoa.sca.annotations.Reference;
@Path("/listenerc")
@Produces(MediaType.TEXT_PLAIN)
public class ListenerImp implements Listener{

    static
    CUManager CUWasteCollection=new CUManagerImp();

    @Override
    public void Receive(int idU, float level, double latitude, double longitude) throws IOException {
        System.out.println("Listener CU waste Ok!");
        CUWasteCollection.lanch(idU, level, latitude, longitude);

    }

}

这是接口代码“监听器”:

package cuWasteCollection;

import java.io.IOException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

public interface Listener {
    @GET
    @Path("/receiveCU/{id}/{level}/{latitude}/{longitude}")
    void Receive(@PathParam("id")int id, @PathParam("level") float level, @PathParam("latitude") double latitude, @PathParam("longitude") double longitude) throws IOException;

}

这是客户端方法:

public void handle(int id, float level, double latitude, double longitude) {
        ClientConfig config = new ClientConfig();
        Client client2 = ClientBuilder.newClient(config);
        WebTarget target = client2.target(getBaseURI());
        System.out.println("CUProbe Ok!");
        String R= target.path("listenerc")
                .path("receiveCU/"+id+"/"+level+"/"+latitude+"/"+longitude).request()
                .accept(MediaType.TEXT_PLAIN).get(String.class);

    }
    private static URI getBaseURI() {
        return UriBuilder.fromUri("http://localhost:8083/CUWasteCollecting")
                .build();
    }

这是启动handle()方法的主要方法:

static
    CUManagerImp UP = new CUManagerImp();
    public static void main(String[] args) throws InterruptedException, IOException {

            System.out.println("start process");


                UP.handle(0,120,241,2541);
    }

在执行main方法期间 我收到以下异常:

start process
CUProbe Ok!
Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Erreur Interne de Servlet
    at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1074)
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:859)
    at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:743)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:741)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:404)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:300)
    at cuUltrasoundProbe.CUManagerImp.handle(CUManagerImp.java:45)
    at cuUltrasoundProbe.Test.main(Test.java:18)

谢谢。

0 个答案:

没有答案