0

I just want to test my web services, I'm in Java 1.6 and I use jerseyTest 2.6 for that but I keep getting the error 500 and I don't know why. My test class extends JerseyTest and I have a configure fonction which look like that:

@Override
protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);

    ResourceConfig config = new ResourceConfig(); 
    config.register(OrderService.class);

    return config;
}

And a simple java class to call the web services :

@XmlRootElement
@Path("/orders")
public class OrderService {
    public OrderService() {

    }

    @GET
    public String test() {
        return "test";
    }

    @POST
    @Produces({ MediaType.APPLICATION_JSON })
    public String echo() {
        System.out.println("je suis dans le post");
        return "je suis post";
    }

    @GET
    @Produces({ MediaType.TEXT_PLAIN })
    @Path("/{orderId}")
    public String getOrders(@PathParam("orderId") String orderId) {
        System.out.println("je suis passé");
        return "orderId: " + orderId;
    }

    @GET
    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    @Path("/summary")
    public Response getOrdersSummary() {

        return Response.status(Status.OK).entity("orders summary").build();
    }

But when I execute the JUnit test I always get

"javax.ws.rs.InternalServerErrorException: HTTP 500 Request Failed"

Can you help me because I'm kinda lost now.

EDIT 1 : The exact trace of the error is :

java.lang.Error: HTTP 500 Request failed.
    at com.ideosante.rh.rest.v10.implementation.RessourceSituationFamilialeTest.hello(RessourceSituationFamilialeTest.java:76)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

So I don't get what is the problem precisely.

andrewJames
  • 19,570
  • 8
  • 19
  • 51
xok
  • 1
  • 1
  • Possible duplicate of [HTTP 500 Internal Server Error in simple REST based program](https://stackoverflow.com/q/31289470/12567365). There are troubleshooting steps in the answers to that question. – andrewJames Jul 12 '22 at 16:01
  • Thankx for your answer, I tried the things described but it dididn't worked. IS it because of my java version who is 1.6, and so I have conflict with another package ? – xok Jul 13 '22 at 07:09
  • Java 6 was released in 2006 - that's sixteen years ago. That version is not even officially supported any more. Upgrade, if you can. – andrewJames Jul 13 '22 at 12:46
  • Yes it would be easily if i can just change the Java version but I can't do that actually My goal is just to test the web services of the application, so when I looked over internet I found Jerseytest and I thought it was a good thing but I can't make it worked. Do you have any solutions or help for me ? – xok Jul 13 '22 at 12:54
  • (1) I know you can't upgrade, but... you should find a way to upgrade (sorry!). (2) Maybe you can downgrade your version of JUnit to one which is compatible with Java 6 (assuming you are using a later version of JUnit at the moment). And maybe you need to downgrade additional tools/libraries also. – andrewJames Jul 13 '22 at 13:05
  • Yes okey I can try to use JUnit 3 and see if it works with Jerseytest – xok Jul 13 '22 at 13:06

0 Answers0