Deploying jersey web services on Payara 4 doesn´t

2019-06-05 18:30发布

问题:

I developed a Maven Web Project to expose some jersey web services through Payara 4, the project builds fine, but my web methods are not exposed.

Here is the main class:

package br.com.ainstec.cfrjob.api.resources;

import br.com.concil.cfrimporter.controller.CfrImport;
import br.com.concil.cfrimporter.model.PojoTest;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Recurso REST para tratar chamadas
 *
 */
@Path("test")
//@RequestScoped
public class TestResource {

    private static final Logger logger = LoggerFactory.getLogger(TestResource.class);

    @GET
    @Path("run")
    @Consumes(MediaType.TEXT_PLAIN)
    public void run(PojoTest pojoBody) {
        logger.info("Starting Camel Job Test#1");

What could be the problem? The service needs to be registered somewhere?

Thanks in advance!

回答1:

Do you have defined an Application for your JAX-RS resources? If you put it in the same folder as your resources this should be sufficient:

@javax.ws.rs.ApplicationPath("API_PATH_FOR_JAXRS")
public class SampleApplication extends Application {

}

Your web service will then be availble under API_PATH_FOR_JAXRS/test