Liferay和Jersey该ResourceConfig实例不包含任何根资源类

时间:2018-12-13 06:25:01

标签: java jsf liferay-6

我试图在应用程序中添加rest api,所以我添加了两个servlet,一个用于处理JSF请求,另一个用于处理Rest API请求。

web.xml

<?xml version="1.0"?>
<web-app
    version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
 <context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>-1</param-value>
</context-param> 
    <context-param>
       <param-name>primefaces.THEME</param-name>
       <param-value>redmond</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>

  <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>
                     com.sun.jersey.spi.container.servlet.ServletContainer
                </servlet-class>
        <init-param>
              <param-name>com.sun.jersey.config.property.packages</param-name>
             <param-value>com.infinite.npsc.webapi</param-value>
        </init-param>
        <init-param>
        <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
            <param-value>com.infinite.npsc.webapi.CorsFilter</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>

</web-app>

例如,我想将api称为

http://localhost:5081/ApplicationFormFillingProcess-portlet/api/savePayment/2075-531345

但是现在我收到com.sun.jersey.api.container.ContainerException的错误:ResourceConfig实例不包含任何根资源类。

如果我从以下位置更改了jersey servlet网址映射

<url-pattern>/api/*</url-pattern>

<url-pattern>/*</url-pattern> 

我可以调用api。但我的图像和其他静态内容未加载。

0 个答案:

没有答案