在web.xml -error中定义的初步Servlet应用

时间:2018-10-08 12:29:59

标签: java-ee jersey jax-rs weblogic weblogic12c

当我尝试在WebLogic中部署JAX-RS应用程序时,出现以下异常

The preliminary servlet App defined in web.xml or web-fragment.xml has not been completed through the ServletContext.addServlet() API by any ServletContextListener or ServletContainerInitializer

这是什么意思,为什么会出现此错误?

这是应用程序类

import java.util.HashSet;
import java.util.Set;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/test")
public class App extends Application {

    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> set = new HashSet<>();
        set.add(EchoEndpoint.class);
        return set;
    }

}

端点

import javax.ejb.EJB;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import weblogicspringsecurity.service.EchoService;

@Path("/echo")
public class EchoEndpoint {

//  @EJB
    private EchoService service;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String echo(@QueryParam("foo") String foo) {
        return service.echo(foo);
    }
}

和web.xml

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <servlet>
        <display-name>Echo REST Servlet</display-name>
        <servlet-name>App</servlet-name>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>weblogicspringsecurity.rest.App</param-value>
        </init-param>
    </servlet>
</web-app>

0 个答案:

没有答案